pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

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

    1. <legend id='C2YdX'><style id='C2YdX'><dir id='C2YdX'><q id='C2YdX'></q></dir></style></legend>

      前綴和非前綴命令在 python discord bot 上不能一起工

      Prefixed and non prefix commands are not working together on python discord bot(前綴和非前綴命令在 python discord bot 上不能一起工作)
      <tfoot id='ewMWo'></tfoot>

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

            • <bdo id='ewMWo'></bdo><ul id='ewMWo'></ul>
                <tbody id='ewMWo'></tbody>
            • <i id='ewMWo'><tr id='ewMWo'><dt id='ewMWo'><q id='ewMWo'><span id='ewMWo'><b id='ewMWo'><form id='ewMWo'><ins id='ewMWo'></ins><ul id='ewMWo'></ul><sub id='ewMWo'></sub></form><legend id='ewMWo'></legend><bdo id='ewMWo'><pre id='ewMWo'><center id='ewMWo'></center></pre></bdo></b><th id='ewMWo'></th></span></q></dt></tr></i><div class="0iimmwm" id='ewMWo'><tfoot id='ewMWo'></tfoot><dl id='ewMWo'><fieldset id='ewMWo'></fieldset></dl></div>
                <legend id='ewMWo'><style id='ewMWo'><dir id='ewMWo'><q id='ewMWo'></q></dir></style></legend>
                本文介紹了前綴和非前綴命令在 python discord bot 上不能一起工作的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                import asyncio
                import discord
                from discord.ext import commands
                from discord.ext.commands import Bot
                import chalk
                
                
                bot = commands.Bot(command_prefix='!')
                
                @bot.event
                async def on_ready():
                    await bot.change_presence(game=discord.Game(name='Test'))
                    print("All systems online and working " + bot.user.name)
                    await bot.send_message(discord.Object(id=386518608550952965), "All systems online and working")
                
                @bot.command(pass_context=True)
                async def hel(ctx):
                    await bot.say("A help message is sent to user")
                
                
                @bot.command
                async def on_message(message):
                    if message.content.startswith("ping"):
                        await bot.send_message(message.channel, "Pong")
                
                
                
                
                bot.run("TOKEN", bot=True)
                

                我試圖在我的 discord 測試服務(wù)器上完成這項(xiàng)工作,但是當(dāng)我像這樣使用它時(shí),只有第一個(gè)on_ready"和 !hel 命令有效,ping 不打印任何內(nèi)容,但是當(dāng)我刪除 !hel命令代碼部分,ping 有效,有什么方法可以讓它們一起工作嗎?

                I'm trying to get this work on my discord test server but when I use it like this, only the first "on_ready" and !hel command works, ping doesn't print anything, but when I delete the !hel commands code part, ping works, is there any way that I can make them work together?

                推薦答案

                使用on_message@bot.command改為@bot.event>

                Change @bot.command to @bot.event when using on_message

                在使用on_message時(shí)添加bot.process_commands

                為什么 on_message 會(huì)讓我的命令停止工作?

                覆蓋默認(rèn)提供的 on_message 會(huì)禁止運(yùn)行任何額外的命令.要解決此問題,請(qǐng)?jiān)?on_message 末尾添加 bot.process_commands(message) 行.例如:

                Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message. For example:

                @bot.event
                async def on_message(message):
                    # do some extra stuff here
                
                    await bot.process_commands(message)
                

                http://discordpy.readthedocs.io/en/latest/faq.html#why-does-on-message-make-my-commands-stop-working

                您的代碼應(yīng)如下所示:

                import asyncio
                import discord
                from discord.ext import commands
                from discord.ext.commands import Bot
                import chalk
                
                
                bot = commands.Bot(command_prefix='!')
                
                @bot.event
                async def on_ready():
                    await bot.change_presence(game=discord.Game(name='Test'))
                    print("All systems online and working " + bot.user.name)
                    await bot.send_message(discord.Object(id=386518608550952965), "All systems online and working")
                
                @bot.command(pass_context=True)
                async def hel(ctx):
                    await bot.say("A help message is sent to user")
                
                
                @bot.event
                async def on_message(message):
                    if message.content.startswith("ping"):
                        await bot.send_message(message.channel, "Pong")
                
                    await bot.process_commands(message)
                
                
                bot.run("TOKEN", bot=True)
                

                這篇關(guān)于前綴和非前綴命令在 python discord bot 上不能一起工作的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

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

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

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

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

                        <tfoot id='ggdly'></tfoot>
                          <tbody id='ggdly'></tbody>

                          主站蜘蛛池模板: 广域铭岛Geega(际嘉)工业互联网平台-以数字科技引领行业跃迁 | 东莞压铸厂_精密压铸_锌合金压铸_铝合金压铸_压铸件加工_东莞祥宇金属制品 | 诸城网站建设-网络推广-网站优化-阿里巴巴托管-诸城恒泰互联 | 低温柔性试验仪-土工布淤堵-沥青车辙试验仪-莱博特(天津)试验机有限公司 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 青岛侦探_青岛侦探事务所_青岛劝退小三_青岛调查出轨取证公司_青岛婚外情取证-青岛探真调查事务所 | 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 西安微信朋友圈广告投放_微信朋友圈推广_西安度娘网络科技有限公司 | 彭世修脚_修脚加盟_彭世修脚加盟_彭世足疗加盟_足疗加盟连锁_彭世修脚技术培训_彭世足疗 | PE一体化污水处理设备_地埋式生活污水净化槽定制厂家-岩康塑业 | 拖链电缆_柔性电缆_伺服电缆_坦克链电缆-深圳市顺电工业电缆有限公司 | 吊篮式|移动式冷热冲击试验箱-二槽冷热冲击试验箱-广东科宝 | 新疆散热器,新疆暖气片,新疆电锅炉,光耀暖通公司 | 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 青岛侦探调查_青岛侦探事务所_青岛调查事务所_青岛婚外情取证-青岛狄仁杰国际侦探公司 | 济南宣传册设计-画册设计_济南莫都品牌设计公司 | 龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司_龙门加工中心-数控龙门加工中心厂家价格-山东海特数控机床有限公司 | 伸缩节_伸缩器_传力接头_伸缩接头_巩义市联通管道厂 | 超声波_清洗机_超声波清洗机专业生产厂家-深圳市好顺超声设备有限公司 | 合肥角钢_合肥槽钢_安徽镀锌管厂家-昆瑟商贸有限公司 | 台湾阳明固态继电器-奥托尼克斯光电传感器-接近开关-温控器-光纤传感器-编码器一级代理商江苏用之宜电气 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 上海租车公司_上海包车_奔驰租赁_上海商务租车_上海谐焕租车 | 低合金板|安阳低合金板|河南低合金板|高强度板|桥梁板_安阳润兴 北京租车牌|京牌指标租赁|小客车指标出租 | 电缆故障测试仪_电缆故障定位仪_探测仪_检测仪器_陕西意联电气厂家 | 全自动包装机_灌装机生产厂家-迈驰包装设备有限公司 | 湖州织里童装_女童男童中大童装_款式多尺码全_织里儿童网【官网】-嘉兴嘉乐网络科技有限公司 | 短信营销平台_短信群发平台_106短信发送平台-河南路尚 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | 石英砂矿石色选机_履带辣椒色选机_X光异物检测机-合肥幼狮光电科技 | 管理会计网-PCMA初级管理会计,中级管理会计考试网站 | 商用绞肉机-熟肉切片机-冻肉切丁机-猪肉开条机 - 广州市正盈机械设备有限公司 | 自动气象站_农业气象站_超声波气象站_防爆气象站-山东万象环境科技有限公司 | 微妙网,专业的动画师、特效师、CG模型设计师网站! - wmiao.com 超声波电磁流量计-液位计-孔板流量计-料位计-江苏信仪自动化仪表有限公司 | 聚氨酯催化剂K15,延迟催化剂SA-1,叔胺延迟催化剂,DBU,二甲基哌嗪,催化剂TMR-2,-聚氨酯催化剂生产厂家 | 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | EPK超声波测厚仪,德国EPK测厚仪维修-上海树信仪器仪表有限公司 |