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

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

    1. <legend id='yL7FZ'><style id='yL7FZ'><dir id='yL7FZ'><q id='yL7FZ'></q></dir></style></legend>
    2. <small id='yL7FZ'></small><noframes id='yL7FZ'>

    3. <tfoot id='yL7FZ'></tfoot>

        <bdo id='yL7FZ'></bdo><ul id='yL7FZ'></ul>

      我怎樣才能有兩個相互對抗的命令裝飾器?

      How can I have two command decorators that go against each other?(我怎樣才能有兩個相互對抗的命令裝飾器?)

        <bdo id='YY2FM'></bdo><ul id='YY2FM'></ul>

                <tbody id='YY2FM'></tbody>

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

              3. <legend id='YY2FM'><style id='YY2FM'><dir id='YY2FM'><q id='YY2FM'></q></dir></style></legend>
              4. 本文介紹了我怎樣才能有兩個相互對抗的命令裝飾器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個命令可以刪除用戶輸入的指定數量的消息.我希望只有我和具有管理員角色的人才能訪問此命令.我以前用 if 語句實現過這個,它工作得很好.但是,現在我正在嘗試使用命令裝飾器來做同樣的事情,它只允許管理員使用命令 - 而不是我.這是我正在使用的代碼:

                I have a command that deletes a specified number of messages entered in by the user. I want this command to be accessible only to me and those with the administrator role. I had implemented this before with if-statements, and it was working perfectly fine. However, now I'm trying to use command decorators to do the same, and it only lets administrators use the command - not me. Here's the code I'm working with:

                @bot.command(description="clears entered amount of messages")
                @commands.is_owner() # checks if user is owner
                @commands.has_permissions(administrator=True) # checks if user is admin
                async def delete(ctx, amount : int):
                    await ctx.channel.purge(limit = amount + 1)
                

                我認為 @commands.has_permissions(administrator=True) 阻止了我使用該命令,因為我不是其中一臺服務器的管理員.我試過切換他們的訂單,is_owner() 檢查低于 has_permissions() 檢查;盡管如此,它仍然不允許我使用該命令.如何使用裝飾器克服這個問題?

                The @commands.has_permissions(administrator=True), I think, is blocking me from using the command, since I'm not an administrator in one of the servers. I've tried switching their orders, with the is_owner() check being below the has_permissions() check; nonetheless, it still doesn't allow me to use the command. How can I overcome this using decorators?

                推薦答案

                您可以創建一個自定義裝飾器來檢查您是機器人的所有者還是管理員

                You can create a custom decorator that will check if you're either the owner of the bot, or you are an admin

                def owner_or_admin():
                    def predicate(ctx):
                        owner = ctx.author.id == bot.owner_id # Comparing the author of the message with the owner of the bot
                        perms = ctx.author.guild_permissions.administrator # Checking for admin perms
                        return owner or perms
                    return commands.check(predicate)
                
                
                @bot.command(description="clears entered amount of messages")
                @owner_or_admin()
                async def delete(ctx, amount : int):
                    await ctx.channel.purge(limit = amount + 1)
                

                我剛剛發現 commands.check_any - 檢查是否有任何通過的檢查將通過,即使用邏輯 OR.

                @bot.command()
                @commands.check_any(commands.is_owner(), commands.has_permissions(administrator=True))
                async def delete(ctx, amount: int):
                    await ctx.channel.purge(limit=amount + 1)
                

                這篇關于我怎樣才能有兩個相互對抗的命令裝飾器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 - 自動更改角色顏色)

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

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

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

                        • 主站蜘蛛池模板: 福利一区二区 | 亚洲一区在线播放 | 欧美久久一区 | 在线国产视频 | 综合色久| 一区二区免费高清视频 | 国产99热 | 伊人免费在线观看高清 | 人妖videosex高潮另类 | 日韩精品一区二区三区中文字幕 | 久久精品亚洲一区二区三区浴池 | 国产精品一级在线观看 | 成人网视频 | 人人艹人人爽 | av毛片| 狠狠躁夜夜躁人人爽天天高潮 | 国产精品免费一区二区三区 | 欧美一级二级在线观看 | 国产一区二区日韩 | 日韩视频福利 | 亚洲免费人成在线视频观看 | 免费高潮视频95在线观看网站 | 国产成人免费视频 | 亚洲欧洲国产视频 | 国产黄色大片网站 | 影音先锋中文在线 | 亚洲精品乱码久久久久久久久久 | 亚洲二区在线观看 | 一区二区不卡视频 | 国产96色在线 | 天天干视频 | 在线视频成人 | www.一区二区三区 | 免费v片 | 久久精品亚洲精品国产欧美kt∨ | 羞羞的视频免费看 | 欧美精品一区三区 | 国产一区二区在线免费观看 | www.国产视频 | 国产欧美精品一区二区色综合 | 精品一区国产 |