问题
How do I make the embed description change when a user reacts with ▶
or ◀
?
This is the code I currently am using, -
@client.command(aliases=['commands', 'info', 'cmds'])
async def help(ctx):
embed1 = discord.Embed(title=f"Everyone/Fun Commands-",description=f"```!vx userinfo [Member]```\n"
f"**- Shows the info of the user mentioned.**\n\n"
f"```!vx ping```\n"
f"**- Shows the ping of the bot.**\n\n"
f"```!vx help```\n"
f"**- Shows a list of all commands.**\n\n"
f"```!vx avatar [Member]```\n"
f"**- Shows the Avatar of the mentioned user.**\n\n"
f"```!vx hello```\n"
f"**- Shows a hello message.**\n\n"
f"```!vx bye```\n"
f"**- Shows a bye message.**\n\n"
f"```!vx mention [Member]```\n"
f"**- Mentions the user in the server and also in DMs.**\n\n"
f"```!vx dankmeme```\n"
f"**- Sends a dank meme generated from r/dankmemes2.**\n\n"
f"```!vx dm [Member] [Message Content]```\n"
f"**- DMs the Message content to the Member mentioned.**\n\n"
f"```!vx embed [Message Title] [Message]```\n"
f"**- Sends an embed message in the channel.**\n\n", color=0x40cc88)
embed1.set_thumbnail(url='https://cdn.probot.io/agdJCAIfLR.png')
await ctx.send(embed=embed1)
embed2 = discord.Embed(title="VX Commands-", description=f"```!vx prices```\n"
f"**- Show the official VX Price list.**\n\n"
f"```!vx portfolios```\n"
f"**- Shows the list of portfolios of VX Members.**\n\n"
f"```!vx order [Product]```\n"
f"**- Creates a ticket for you to order a product.**\n\n"
f"```!vx apply```\n"
f"**- Sends a Dm regarding info to apply for VX.**\n\n", colour=0x40cc88)
embed2.set_thumbnail(url='https://cdn.probot.io/agdJCAIfLR.png')
await ctx.send(embed=embed2)
embed3 = discord.Embed(title="Mod Commands", description=f"```!vx kick [Member]```\n"
f"**- Kicks the member mentioned.**\n\n"
f"```!vx ban [Member]```\n"
f"**- Bans the member mentioned.**\n\n"
f"```!vx unban [MemberName#1234]```\n"
f"**- Unbans the member tagged.**\n\n"
f"```!vx clear [No. Of Messages]```\n"
f"**- Clears the number of messages specified.**\n\n"
f"```!vx nuke```\n"
f"**- Nukes the channel**\n\n"
f"```!vx register [Member] [Portfolio URL]```\n"
f"**- Adds the Member's Portfolio to the !vx portfolio command.**\n\n"
f"```!vx close```\n"
f"**- Closes the ticket created by a member.**\n\n"
f"```!vx spam [Member]```\n"
f"**- Spams the user in the channel and also in his dms, Only use when required.**"
f"```!vx add [Member] [Role]```\n"
f"**- Gives the role mentioned to the member.**\n\n"
f"```!vx remove [Member] [Role]```\n"
f"**- Removes the role mentioned from the meber.**", colour=0x40cc88)
embed3.set_thumbnail(url='https://cdn.probot.io/agdJCAIfLR.png')
embed3.set_footer(text=f"Commands requested by {ctx.author.display_name}", icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed3)
Also, I want to clear the reactions of the user when the user reacts on the message. Moreover, I want to display the 3rd embed(Mod Commands) to only a user who has the permission - administrator. Any Help is appreciated.
EDIT - I know how to change an embed normally, I just cant figure out how to change it when the author adds a reaction...
回答1:
Maybe it's help you. Docs:
@bot.event
async def on_reaction_add(reaction, user):
for role in user.roles:
# administrator role name = 'test_role'
if role.name == 'test_role':
# if user is administrator
# do something
break
else:
# if user is not administrator
# and add emoji ▶ or ◀ for any message
if reaction.emoji == '▶':
# if user add reaction emoji - ▶
# do something
pass
elif reaction.emoji == '◀':
# if user add reaction emoji - ◀
# do something
pass
来源:https://stackoverflow.com/questions/62566038/how-to-make-the-embed-change-when-a-user-reacts-on-the-message-in-discord-py-rew