0
votes

So the code show below is meant to send an embeded message to the discord channel the command was sent in. Once there it is to add emojis of the number 1 to 3 as reactions.

    # Start
    @client.command()
    async def start(self, ctx):
        # Main Message
        em = discord.Embed(title="Welcome to the Escape Room Test")
        em.add_field(name="To Continue React to the 1.", value="Ignore this", inline=False)
        message = await ctx.channel.send(embed=em)
        # Add Reactions
        number_of_responses = 3
        for counter in range(number_of_responses):
            await message.add_reaction(emoji_numbers[counter])
    # End Start
emoji_numbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]

However after adding the first emoji I get this error and havent been able to find a way to get past it. Any suggestions would be amazing. Thanks.

Traceback (most recent call last):
  File "d:/aab_dev/aaa_NewDev/EscapeRoomBot/bot.py", line 21, in <module>
    client.run("CLIENT-TOKEN-WAS-HERE")
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\client.py", line 574, in run
    return task.result()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\client.py", line 494, in _silence_gathered
    fut.result()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\client.py", line 482, in start
    await self.connect(reconnect=reconnect)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\client.py", line 404, in connect
    await self._connect()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\client.py", line 369, in _connect
    await self.ws.poll_event()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\gateway.py", line 447, in poll_event
    await self.received_message(msg)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\gateway.py", line 401, in received_message
    func(data)
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\discord\state.py", line 391, in parse_message_reaction_add
    emoji = PartialEmoji(animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x055704D0>
1
How do you run the bot? - Xnero
Perhaps try making the for loop for adding reactions an async for loop? async for counter in range(number_of_resonses): - plum 0
Sadly the Async doesnt work and I have a main file that will run the bot. - Skye

1 Answers

1
votes

That code worked, but I edited it little bit.

Your code:

@client.command()
async def start(self, ctx):
    # Main Message
    em = discord.Embed(title="Welcome to the Escape Room Test")
    em.add_field(name="To Continue React to the 1.", value="Ignore this", inline=False)
    # Add Reactions
    number_of_responses = 3
    emoji_numbers = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]

    message = await ctx.send(embed=em)
    for i in range(number_of_responses):
        await message.add_reaction(emoji_numbers[i])