不和.pybot.send_消息()未转到已调用的频道

2024-10-01 11:36:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我做了一个不和.py不和谐的机器人名为JMKBot(4.0版)。 当我使用不,说吧()函数,例如,无论用户调用它,它都会显示它

@bot.command()
async def example():
    bot.say("example")
    print("example command run!")

会在我称之为>;example的同一频道中说。在

但是bot.send_消息()需要目标变量,我无法使其自动转到调用该命令的通道。在

如何使目标变量转到调用命令的通道?在


Tags: 函数run用户py命令目标asyncexample
1条回答
网友
1楼 · 发布于 2024-10-01 11:36:12
@bot.command(pass_context=True)
async def example(ctx):
    await bot.send_message(ctx.message.channel, 'Example')

将上下文传递到命令中,然后从message属性获取通道。在

相关问题 更多 >