久久久久久久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精品观看 | 亚洲免费一区二区 | 日韩不卡在线观看 | 成人精品一区二区三区 | 国产美女在线免费观看 | 99久久久久久 | av中文字幕在线观看 | 中文字幕av一区二区三区 | 国产激情91久久精品导航 | 天天综合操 | 国产成人高清 | 久久国产一区二区三区 | 一级免费毛片 | 美女视频网站久久 | 伊人精品国产 | 国产高清久久久 | 欧美日韩免费在线 | 瑟瑟激情 | 99re视频 | 久久久精品| 亚洲精品一二三区 | 日本久久黄色 | 蜜桃视频一区二区三区 | 在线视频一区二区 | 亚洲毛片在线观看 | 日日操夜夜干 | 日韩高清在线 | 日韩在线视频免费观看 | 国产精品二区三区 | 日韩国产一区二区三区 | 欧美日韩国产在线观看 | 玖玖操| 亚洲 欧美 日韩在线 | a级黄色毛片免费播放视频 国产精品视频在线观看 | 99久久久无码国产精品 | 亚洲一区二区中文字幕在线观看 | 成人激情视频免费观看 | 91 久久 | 男女免费视频网站 | 亚洲精品一区二区三区中文字幕 | 久久精品国产一区二区三区 |