发送指定频道/ Python Discord的消息

时间:2018-10-14 07:40:58

标签: python discord discord.py

@Bot.command(pass_context = True)
async def xsend(ctx, *, message):
    await Bot.delete_message(ctx.message)
    await Bot.send_message(discord.Object(id='408104999038746635'), message)

我有此命令根据其ID将消息发送到特定频道,但是我希望能够选择要将消息发送到哪个频道,例如:

xsend "#namechannel" "mymessage"

我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可以使用频道converter将频道参数自动转换为discord.Channel对象:

@bot.command(pass_context=True)
async def xsend(ctx, channel: discord.Channel, *, message):
    await bot.delete_message(ctx.message)
    await bot.send_message(channel, message)
相关问题