首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当用户对discord.py重写中的消息作出反应时,如何进行嵌入更改?

当用户对discord.py重写中的消息作出反应时,如何进行嵌入更改?
EN

Stack Overflow用户
提问于 2020-06-25 00:26:39
回答 2查看 2.6K关注 0票数 0

当用户与交互时,如何使嵌入描述发生更改?这是我目前使用的代码-

代码语言:javascript
复制
@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)

另外,当用户对消息作出反应时,我想清除用户的反应。此外,我希望只向拥有权限管理员的用户显示第三次嵌入(Mod命令)。任何帮助都是非常感谢的。

编辑-我知道如何改变嵌入正常,我只是不知道如何改变当作者添加一个反应.

EN

回答 2

Stack Overflow用户

发布于 2020-06-25 10:51:05

也许这能帮你。文档

代码语言:javascript
复制
@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
票数 0
EN

Stack Overflow用户

发布于 2021-04-17 19:03:50

我也在想同样的事情。我现在可以获取用户的反应,但不能清除他们,所以他们必须按两次(一次是为了清除,然后是反应),而且这里发送的所有嵌入编辑都是我的代码供参考:

代码语言:javascript
复制
def check(reaction, user):
        return user == author and str(reaction.emoji) in ["➡","⬅"]

    help_list=[help_embed,server_embed,greet_embed,fun_embed,music_embed,utility_embed]
    count=0
    help_msg=await ctx.send(embed=help_list[count])
    await help_msg.add_reaction("⬅")
    await help_msg.add_reaction("➡")
    
    while True:
        reaction, user = await self.bot.wait_for('reaction_add',check=check)
        print(str(reaction))
        if str(reaction.emoji) == "➡":
            count+=1
            if count>len(help_list)-1:
                count=0
            await help_msg.edit(embed=help_list[count])
            await help_msg.add_reaction("⬅")
            await help_msg.add_reaction("➡")
    
        elif str(reaction.emoji) == "⬅":
            count-=1
            if count<0:
                count=len(help_list)-1
            await help_msg.edit(embed=help_list[count])
            await help_msg.add_reaction("⬅")
            await help_msg.add_reaction("➡")

注意: help_list只是一个嵌入的列表。

谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62566038

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档