@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"
我该怎么办?
答案 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)