<tfoot id='FjNf7'></tfoot>
      <legend id='FjNf7'><style id='FjNf7'><dir id='FjNf7'><q id='FjNf7'></q></dir></style></legend>
        <bdo id='FjNf7'></bdo><ul id='FjNf7'></ul>
    1. <i id='FjNf7'><tr id='FjNf7'><dt id='FjNf7'><q id='FjNf7'><span id='FjNf7'><b id='FjNf7'><form id='FjNf7'><ins id='FjNf7'></ins><ul id='FjNf7'></ul><sub id='FjNf7'></sub></form><legend id='FjNf7'></legend><bdo id='FjNf7'><pre id='FjNf7'><center id='FjNf7'></center></pre></bdo></b><th id='FjNf7'></th></span></q></dt></tr></i><div id='FjNf7'><tfoot id='FjNf7'></tfoot><dl id='FjNf7'><fieldset id='FjNf7'></fieldset></dl></div>

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

      discord.py 机器人可以不区分大小写吗?

      时间:2023-10-11

      <tfoot id='jO4JX'></tfoot>

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

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

              • 本文介绍了discord.py 机器人可以不区分大小写吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我现在正在制作一个不和谐机器人,如果我使用大写字母/不使用大写字母,它不会响应.机器人有没有办法检测消息,即使它们是大写/小写的?机器人还有没有办法对空格做同样的事情(如果我不小心忘记放空格,或者不小心将两个单词合并在一起......)?

                I'm making a discord bot right now, and it won't respond if I use capitals/don't use capitals. Is there a way for a bot to detect messages even if they're capital/lowercase? Is there also a way for a bot to be able to do the same with spaces (if I accidentally forget to put a space, or accidentally merge two words together...)?

                还是我必须对 if 语句进行无穷无尽的跟踪?

                Or do I have to make an endless trail of if statements?

                推荐答案

                假设你在 msg 变量中得到你的消息,那么如果你使用 msg.lower()您将获得小写版本的响应,您可以检查它以查看命令是什么.

                assuming you get your message in the msg variable, then if you use msg.lower() you'll get the lowercase version of the response and you can check on that to see what the command was.

                另外,运行 msg.replace(' ', '') 将创建一个删除所有空格的值,您可以检查此变量的相应值而不是原始值.

                also, running msg.replace(' ', '') would create a value where all spaces are removed, and you can check the corresponding value of this variable instead of the original one.

                例如:

                msg = 'HeLlO wOrLd'
                print(msg.lower().replace(' ', ''))
                >> helloworld
                

                假设这是一个命令行界面,我真的建议您遵循内置 argparse 库中的指南.

                assuming this is a command line interface, I truly suggest you follow the guidelines in the builtin argparse library.

                请参见此处:https://docs.python.org/3.3/library/argparse.html

                这篇关于discord.py 机器人可以不区分大小写吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 discord.py 事件处理程序 on_voice_state_upd 下一篇:当用户对某个频道中的消息做出反应时分配不和

                相关文章

                最新文章

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

                    <legend id='gze2Q'><style id='gze2Q'><dir id='gze2Q'><q id='gze2Q'></q></dir></style></legend>

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

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