#add reaction

2 messages · Page 1 of 1 (latest)

undone river
#
@bot.slash_command(name="list_servers_and_invites", description="Lists the servers the bot is in, and an invite to them, if there are any!")
async def list_servers_and_invites(interaction):
    await interaction.send("Gathering information")
    guilds = interaction.bot.guilds
    output = []
    for guild in guilds:
        invites = await guild.invites()
        if invites:
            output.append(f"Server: {guild.name}\nInvite: {invites[0].url}")
        else:
            output.append(f"Server: {guild.name}\nInvite: None found")

    pages = []
    for i in range(0, len(output), 10):
        page = "\n".join(output[i:i + 10])
        pages.append(disnake.Embed(description=page))

    await interaction.send(embed=pages[0])

    def check(reaction, user):
        return user == interaction.author and str(reaction.emoji) in ['⏮', '⏭', '⏯']

    for page in pages[1:]:
        message = await interaction.send(embed=page)
        for emoji in ['⏮', '⏭', '⏯']:
            await message.add_reaction(emoji)

        reaction, user = await interaction.bot.wait_for('reaction_add', check=check)
        if str(reaction.emoji) == '⏮':
            i = pages.index(page)
            await message.edit(embed=pages[i - 1])
        elif str(reaction.emoji) == '⏭':
            i = pages.index(page)
            if i == len(pages) - 1:
                await message.edit(embed=pages[0])
            else:
                await message.edit(embed=pages[i + 1])
        elif str(reaction.emoji) == '⏯':
            break
        await message.clear_reactions()``` so I need a little help fixing this error ` AttributeError: 'ApplicationCommandInteraction' object has no attribute 'add_reaction'`
fast acorn
#

use an IDE that allows you to inspect the message variable and see what methods it has. Insure that "add_reaction" is listed. The line is "await message.add_reaction(emoji)"

What is the library you are using to instantiate the "interaction" object?