该代码应该返回一条消息,告诉您添加了哪个反应以及发送该反应的用户。
import discord
import random
from discord.ext import commands
client = commands.Bot(command_prefix = 'cr!')
##Main program
#Bootup
@client.event
async def on_ready():
print('bot online')
#Reactions
@client.event
async def on_reaction_add(reaction, user):
channel = reaction.message.channel
await client.send_message(channel, '{} has added {} to the message: {}'.format(user.name,reaction.emoji))
client.run("{hid the token}")
显示为输出的错误是:
Traceback (most recent call last):
File "C:\Users\titif\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "C:\Users\titif\Desktop\Discord bot\Fight em .py", line 20, in on_reaction_add
await client.send_message(channel, '{} has added {} to the message: {}'.format(user.name,reaction.emoji))
AttributeError: 'Bot' object has no attribute 'send_message'