久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <i id='fQRyE'><tr id='fQRyE'><dt id='fQRyE'><q id='fQRyE'><span id='fQRyE'><b id='fQRyE'><form id='fQRyE'><ins id='fQRyE'></ins><ul id='fQRyE'></ul><sub id='fQRyE'></sub></form><legend id='fQRyE'></legend><bdo id='fQRyE'><pre id='fQRyE'><center id='fQRyE'></center></pre></bdo></b><th id='fQRyE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fQRyE'><tfoot id='fQRyE'></tfoot><dl id='fQRyE'><fieldset id='fQRyE'></fieldset></dl></div>

    <tfoot id='fQRyE'></tfoot>
  1. <legend id='fQRyE'><style id='fQRyE'><dir id='fQRyE'><q id='fQRyE'></q></dir></style></legend>
    1. <small id='fQRyE'></small><noframes id='fQRyE'>

      • <bdo id='fQRyE'></bdo><ul id='fQRyE'></ul>

      當用戶對某個頻道中的消息做出反應時分配不和

      Assign discord role when user reacts to message in certain channel(當用戶對某個頻道中的消息做出反應時分配不和諧角色)

      1. <small id='Yb5Hi'></small><noframes id='Yb5Hi'>

          <i id='Yb5Hi'><tr id='Yb5Hi'><dt id='Yb5Hi'><q id='Yb5Hi'><span id='Yb5Hi'><b id='Yb5Hi'><form id='Yb5Hi'><ins id='Yb5Hi'></ins><ul id='Yb5Hi'></ul><sub id='Yb5Hi'></sub></form><legend id='Yb5Hi'></legend><bdo id='Yb5Hi'><pre id='Yb5Hi'><center id='Yb5Hi'></center></pre></bdo></b><th id='Yb5Hi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Yb5Hi'><tfoot id='Yb5Hi'></tfoot><dl id='Yb5Hi'><fieldset id='Yb5Hi'></fieldset></dl></div>
            <bdo id='Yb5Hi'></bdo><ul id='Yb5Hi'></ul>
                <legend id='Yb5Hi'><style id='Yb5Hi'><dir id='Yb5Hi'><q id='Yb5Hi'></q></dir></style></legend>

                  <tbody id='Yb5Hi'></tbody>
                <tfoot id='Yb5Hi'></tfoot>
                本文介紹了當用戶對某個頻道中的消息做出反應時分配不和諧角色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我希望用戶在我的歡迎和角色不和諧頻道中選擇某個反應時被分配一個角色.我到處尋找,在 python 中找不到適用于最新版本 discord.py 的代碼.這是我目前所擁有的:

                I want a user to be assigned a role when they choose a certain reaction in my welcome-and-roles discord channel. I've looked everywhere and can't find code in python that works with the most up-to-date version of discord.py. Here is what I have so far:

                import discord
                
                client = discord.Client()
                
                TOKEN = os.getenv('METABOT_DISCORD_TOKEN')
                
                
                @client.event
                async def on_reaction_add(reaction, user):
                    role_channel_id = '700895165665247325'
                    if reaction.message.channel.id != role_channel_id:
                        return
                    if str(reaction.emoji) == "<:WarThunder:745425772944162907>":
                        await client.add_roles(user, name='War Thunder')
                
                
                print("Server Running")
                
                client.run(TOKEN)
                

                推薦答案

                使用 on_raw_reaction_add 而不是 on_reaction_add,因為 on_reaction_add 只有在消息在 bot 的緩存中,而 on_raw_reaction_add 將工作,無論內部消息緩存的狀態如何.

                Use on_raw_reaction_add instead of on_reaction_add, As on_reaction_add will only work if the message is in bot's cache while on_raw_reaction_add will work regardless of the state of the internal message cache.

                所有的 IDS、角色 ID、頻道 ID、消息 ID...,都是 INTEGER 而不是 STRING,這就是您的代碼無法正常工作的原因,因為它將 INT 與 STR 進行比較.

                All the IDS, Role IDs, Channel IDs, Message IDs..., are INTEGER not STRING, that is a reason why your code not works, as its comparing INT with STR.

                另外還要獲取角色,不能只傳入角色的名字

                Also you need to get the role, you can't just pass in the name of the role

                下面是工作代碼

                @client.event
                async def on_raw_reaction_add(payload):
                    if payload.channel_id == 123131 and payload.message_id == 12121212: #channel and message IDs should be integer:
                        if str(payload.emoji) == "<:WarThunder:745425772944162907>":
                            role = discord.utils.get(payload.member.guild.roles, name='War Thunder')
                            await payload.member.add_roles(role)
                

                對于 on_raw_reaction_remove

                @client.event
                async def on_raw_reaction_remove(payload):
                    if payload.channel_id == 123131 and payload.message_id == 12121212: #channel and message IDs should be integer:
                        if str(payload.emoji) == "<:WarThunder:745425772944162907>":
                            #we can't use payload.member as its not a thing for on_raw_reaction_remove
                            guild = bot.get_guild(payload.guild_id)
                            member = guild.get_member(payload.user_id)
                            role = discord.utils.get(guild.roles, name='War Thunder')
                            await member.add_roles(role)
                

                這篇關于當用戶對某個頻道中的消息做出反應時分配不和諧角色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                message.channel.id Discord PY(message.channel.id Discord PY)
                How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

                  <i id='sv8dw'><tr id='sv8dw'><dt id='sv8dw'><q id='sv8dw'><span id='sv8dw'><b id='sv8dw'><form id='sv8dw'><ins id='sv8dw'></ins><ul id='sv8dw'></ul><sub id='sv8dw'></sub></form><legend id='sv8dw'></legend><bdo id='sv8dw'><pre id='sv8dw'><center id='sv8dw'></center></pre></bdo></b><th id='sv8dw'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sv8dw'><tfoot id='sv8dw'></tfoot><dl id='sv8dw'><fieldset id='sv8dw'></fieldset></dl></div>

                  <small id='sv8dw'></small><noframes id='sv8dw'>

                  • <bdo id='sv8dw'></bdo><ul id='sv8dw'></ul>
                    <legend id='sv8dw'><style id='sv8dw'><dir id='sv8dw'><q id='sv8dw'></q></dir></style></legend>

                      • <tfoot id='sv8dw'></tfoot>
                            <tbody id='sv8dw'></tbody>
                          主站蜘蛛池模板: 日本天堂一区 | 亚洲视频在线看 | 久久精品这里精品 | 精品久久99 | 国产福利在线视频 | 精品一区国产 | 91精品国产综合久久精品图片 | 亚洲免费在线 | 在线观看国产视频 | 香蕉久久a毛片 | 91亚洲国产成人久久精品网站 | 一区二区三区视频在线 | 日韩欧美精品 | 欧美国产一区二区三区 | 91在线观看免费 | 久久久久久国产精品免费 | 99精品国产一区二区三区 | 日韩中文在线视频 | 日韩av高清在线 | 精品国产免费人成在线观看 | 国产综合精品一区二区三区 | av国产精品| 国产精品一区二区在线 | 色www精品视频在线观看 | 免费久久99精品国产婷婷六月 | 特级黄一级播放 | 日韩在线观看中文字幕 | 久久久精选 | 久久久久黄色 | 在线一区二区三区 | 日韩av电影在线观看 | 欧美日韩精品综合 | 欧美福利 | 精品欧美乱码久久久久久 | 操久久 | 国产亚洲日本精品 | 中文字幕亚洲视频 | 国产在线观看av | 成人美女免费网站视频 | 欧美日韩国产精品激情在线播放 | 欧美精品欧美精品系列 |