client = discord.Client()
noticeme = 'notice me senpai'
@bot.event
async def on_message(message):
author = message.author
authorid = message.author.id
print ("@{} user sent a message. (id: {})".format(author, authorid))
if message.content == noticeme:
print ('I noticed you @{}!'.format(authorid))
await client.send_message(message.channel, 'I noticed you @{}!'.format(authorid))
我正在尝试制作一个响应“我注意到你@username!”的命令当你说“注意我senpai”但它不起作用。 (印刷品工作)
答案 0 :(得分:1)
client = discord.Client()
noticeme = 'notice me senpai'
@client.event
async def on_message(message):
author = message.author
authorid = message.author.id
print ("@{} user sent a message. (id: {})".format(author, authorid))
if message.content == noticeme:
print ('I noticed you @{}!'.format(authorid))
await client.send_message(message.channel, 'I noticed you @{}!'.format(author))
这应该是你的代码。
您使用的@bot.event
应由@client.event
替换。
我测试了您的代码,如果您想使用@
提及,则需要使用author
变量而不是authorid
变量。
希望这有帮助。
答案 1 :(得分:0)
您正在使用await client.send_message()
而不是await bot.send_message()
。
答案 2 :(得分:0)
也许不是await client.send_message(message.channel, 'I noticed you @{}!'.format(author))
,而是尝试await message.send('I noticed you @{}!'.format(author))