python 3 Discord 我如何将用户 dm 响应发送到特定的服务器频道

时间:2021-01-10 19:57:54

标签: python discord.py

async def on_message(message: discord.Message):
    if message.guild is None and not message.author.bot:
        msg = message.content
        print(msg)
        channel = (796761485996982302)
        await Bot.channel.send(msg)
        await Bot.process_commands(message)

当用户向机器人发送消息时,它会在终端中弹出,但我已尝试将其发送到我选择的服务器频道,但每次都失败

1 个答案:

答案 0 :(得分:0)

您需要获取频道然后发送消息

@bot.event
async def on_message(m):
    if not m.guild and not m.author.bot:
        await bot.get_channel(CHANNEL_ID).send(m.content)
    await bot.process_commands(m)