Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

python 3.x - Adding a emoji reaction to command line in discord

I want the bot reacting to my command line. For example: -suggest suggestion < i want to add a thumb up emoji to that sentence. I already know how to add reactions to the outcome of command but i have no idea how to react to the command line

i got this simple suggest command and it gives now a reaction to the outcome of the command:

@commands.cooldown(1, 5, commands.BucketType.user)
async def suggest(ctx,*, suggestion):
    channel = client.get_channel(754640430670413835)
    embed = discord.Embed(color=0x55f7b1, timestamp=ctx.message.created_at)
    embed.set_author(name="{}".format(ctx.author),icon_url="{}".format(ctx.author.avatar_url))
    embed.add_field(name="Suggestion:", value="{}".format(suggestion), inline=False)
    embed.set_footer(text="{}.".format(ctx.author))
    embed1 = await channel.send(embed=embed)
    emoji1 = 'N{THUMBS DOWN SIGN}'
    emoji2 = 'N{THUMBS UP SIGN}'
    await embed1.add_reaction(emoji2)
    await embed1.add_reaction(emoji1)
    await ctx.send("Thank you for your suggestion {}".format(ctx.author.mention)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

ctx.message is what you are looking for (command message) then add the wanted reactions to that.

For example:

await ctx.message.add_reaction("?")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...