我正试图用python编写一个discord bot,但我的代码不起作用

2024-04-25 16:31:16 发布

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

我正在尝试用python编写我的第一个discord bot,我需要一些关于这段代码的帮助,请记住,我是python的新手,大约2周前开始学习。你知道吗

    @bot.event
async def on_message(message):
    content = message.content
    author = message.author
    if content == "example yes":
        bot.say("example @%s" % (author))

如果用户说“example yes”,我希望bot写“example2@user”


Tags: 代码eventmessageasyncifonexampledef
1条回答
网友
1楼 · 发布于 2024-04-25 16:31:16

你不是awaitbot.say,这不是你提到用户的方式(你用^{}属性代替)

@bot.event
async def on_message(message):
    content = message.content
    author = message.author
    if content == "example yes":
        await bot.say("example {}".format(author.mention))

相关问题 更多 >

    热门问题