如何向特定频道发送消息?

@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") 它给出了typerror 我尝试将其转换为 int 但仍然不起作用。 你能帮我吗?


繁星淼淼
浏览 91回答 1
1回答

开心每一天1111

将检索到的数据发送到特定的公会和频道specific_guild = client.get_guild( guild_id )#guild_id must be a integerspecific_channel = specific_guild.get_channel( channel_id )#channel_id must be a integerawait specific_channel.send("{}: {}".format(author, content))将检索到的数据发送到同一行会的特定频道specific_channel = message.guild.get_channel( channel_id )#channel_id must be a integerawait specific_channel.send("{}: {}".format(author, content))
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python