如何将消息发送到特定频道?

时间:2020-09-15 07:02:36

标签: python discord.py

@client.event
async def on_message_delete(message):
    content = message.content
    author = message.author
    await message.channel.send("{}: {}".format(author, content))

我搜索了它,但找不到任何结果。我尝试使用client.get_channel(“ id”),但出现打字错误,我尝试将其转换为int,但仍然无法正常工作。 你能帮忙吗?

1 个答案:

答案 0 :(得分:0)

要将检索到的数据发送到特定的公会和频道

specific_guild = client.get_guild( guild_id )#guild_id must be a integer
specific_channel = specific_guild.get_channel( channel_id )#channel_id must be a integer
await specific_channel.send("{}: {}".format(author, content))

要将检索到的数据发送到同一个公会中的特定频道

specific_channel = message.guild.get_channel( channel_id )#channel_id must be a integer
await specific_channel.send("{}: {}".format(author, content))