0

Basically, I'm trying to create a poll/vote command that allows you to add the reactions ":thumbsup:" for agree and ":thumbsdown:" for disagree. For example:

User: Am I male?

Reactions: :thumbsup:, :thumbsdown:

Meaning of Reactions: [yes:no]

This is my full code:

@client.command()
async def poll(ctx, *, message):
    await ctx.send(f"{message}")
    await Message.add_reaction(emoji=u"\U0001F44D")

Whenever I call the command, the message is sent but the reaction is not added. This error pops up instead

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_reaction() missing 1 required positional argument: 'self'

The full error is here:

Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\danie\Documents\Scripts\Bots\DiscordBot\skybot.py", line 53, in poll
    await discord.Message.add_reaction(emoji=u"\U0001F44D")
TypeError: add_reaction() missing 1 required positional argument: 'self'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\danie\Documents\Scripts\Bots\DiscordBot\skybot.py", line 189, in on_command_error
    raise error
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_reaction() missing 1 required positional argument: 'self'
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\danie\Documents\Scripts\Bots\DiscordBot\skybot.py", line 53, in poll
    await discord.Message.add_reaction(emoji=u"\U0001F44D")
TypeError: add_reaction() missing 1 required positional argument: 'self'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\danie\Documents\Scripts\Bots\DiscordBot\skybot.py", line 189, in on_command_error
    raise error
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_reaction() missing 1 required positional argument: 'self'

This is my source for the emoji unicode

2 Answers 2

2

The discord.py send() function returns a Message, so all you should have to do is set your send function to a variable.

@client.command()
async def poll(ctx, *, message):
    message = await ctx.send(message)
    await message.add_reaction(u"\U0001F44D")
Sign up to request clarification or add additional context in comments.

Comments

2

You need an instance of a message not a class, store your message in a variable. In this case the variable is msg:

@client.command()
async def poll(ctx, *, message):
    msg = await ctx.send(f"{message}")
    await msg.add_reaction(emoji=u"\U0001F44D")

2 Comments

Thanks for the answer, really appreciate it. I accepted the other guy since he had a lower reputation. Hope you understand. :)
No problem, glad you found your answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.