[英]I'm trying to write a discord bot in python but my code is not working
I'm trying to code my first discord bot in python and I need a bit of help with this piece of code, keep in mind im new to python and I started learning about 2 weeks ago. 我正在尝试用Python编写我的第一个Discord机器人,并且在这部分代码上我需要一些帮助,请记住我是python的新手,大约2周前我开始学习。
@bot.event
async def on_message(message):
content = message.content
author = message.author
if content == "example yes":
bot.say("example @%s" % (author))
I want the bot to write "example2 @user" if a user says "example yes" 如果用户说“ example yes”,我希望机器人写“ example2 @user”
You're not await
ing bot.say
, and that's not how you mention a user (you use the User.mention
attribute instead) 您不是
await
bot.say
,那不是您提到用户的方式(而是使用User.mention
属性)
@bot.event
async def on_message(message):
content = message.content
author = message.author
if content == "example yes":
await bot.say("example {}".format(author.mention))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.