问题
I want to add a reaction to a message that gets send in one channel. I get the error code:
discord.errors.InvalidArgument: emoji argument must be str, Emoji, or Reaction not NoneType.
Here is my code:
client = discord.Client()
if message.channel.id == 737668230012862514:
emoji = client.get_emoji(310177266011340803)
await message.add_reaction(emoji)
回答1:
The line: emoji argument must be str, Emoji, or Reaction not NoneType
indicates that the emoji
was set to None
, meaning that the client could not find the emoji of id 310177266011340803
.
As you can see from the documentation, get_emoji returns None
if no emoji was found.
Please make sure that 310177266011340803
is a valid emoji id and that the bot has access to the server where the emoji is.
To access all emoji names and IDs, you can write:
@client.event
async def on_ready():
for emoji in client.emojis:
print("Name:", emoji.name + ",", "ID:", emoji.id)
来源:https://stackoverflow.com/questions/63137643/add-reaction-to-a-message-discord-py