1

I want to use discord.py on python3 to create a message that can be reacted to only by the person who sent the command.

However, I also want this message to be sent in a chat and then be reacted to, so I cannot just make the bot check for a message ID unless it is passed through to the raw_on_reaction event, and I do not know how to do that.

I need to create something similar to reaction roles, except it edits the message to create a sort of text-based game.

Here is what I have so far:

import discord
from discord.ext import commands


class Adventure(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command(name="Adventure")
    async def adventure(self, ctx):
        embed = discord.Embed(
            title="Where to go, where to go?",
            description="Choose where to start your text-based adventure!",
            color=discord.Colour.red()
        )
        embed.add_field(
            name="The wild forest",
            value="A wild and unpredictable forest, where anything could happen! Beware of creatures as you attempt to escape!",
            inline=False
        )
        message = await ctx.channel.send(embed=embed)
        await message.add_reaction("")


def setup(bot):
    bot.add_cog(Adventure(bot))

Note that this is inside of a Cog and I need the code to be written to work inside of a cog. I couldn't find any sources that did this inside of a cog without needless JSON databases, and I want to avoid those.

  • 2
    Wait for a reaction of the author? You can simply use `wait_for` and then edit the embed after the reaction. – Dominik Dec 11 '21 at 20:17
  • Would you mind posting this as an answer and adding in an implementation, or pointing me towards some documentation? Thank you very much. – David Avarage Dec 11 '21 at 20:22
  • 3
    [Discord.py-rewrite wait_for() how do i use?](https://stackoverflow.com/questions/52571844/discord-py-rewrite-wait-for-how-do-i-use) is a good post, also explaining how to `wait_for` a reaction. Also check out the [docs](https://discordpy.readthedocs.io/en/stable/api.html?highlight=wait_for#discord.Client.wait_for) – Dominik Dec 11 '21 at 20:26

0 Answers0