我制作了一个名为JMKBot(版本4.0)的Discord.py Discord机器人。当我使用bot.say()函数时,它会在用户调用它的任何地方说出它
@bot.command()
async def example():
bot.say("example")
print("example command run!")
会在我称之为例子的同一频道中说出来。
但是bot.send_message()需要一个目标变量,我不能让它自动转到命令所在的通道。
如何将目标变量转到命令所在的通道?
@bot.command(pass_context=True)
async def example(ctx):
await bot.send_message(ctx.message.channel, 'Example')
将上下文传递给命令,然后从message
属性中获取通道。