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

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

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

        Python discord bot 離開語音頻道

        Python discord bot leave voice channel(Python discord bot 離開語音頻道)
          • <bdo id='LoxSR'></bdo><ul id='LoxSR'></ul>

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

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

                1. 本文介紹了Python discord bot 離開語音頻道的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我已經讓機器人加入我的語音服務器,如下所示

                  I've made bot to join my voice server like below

                   if message.content.startswith("?join"):
                      channel = message.author.voice.channel
                      await channel.connect()
                      await message.channel.send('bot joined')
                  

                  但我不能讓機器人離開頻道.. 我該如何編寫代碼來做到這一點?和有什么區別

                  but i can't make bot to leave the channel.. how can i code to do it?? and what is the difference between

                  @bot.event
                   async def on_message(message):
                   if message.content.startswith('~'):
                  

                  @bot.command()
                  async def ~(ctx):
                  

                  推薦答案

                  你可以通過兩種方式執行這兩個命令(加入和離開頻道命令),一種是使用on_message,另一種是使用@bot.commands.最好使用 bot.command 而不是 on_message 作為命令,因為 bot.commands 具有更多功能,而且我認為它是為命令而構建的,它的速度很快.因此,我將使用 bot.command 重寫您的兩個命令,并在此處使用 on_message 以防您不想使用 bot.command.根據您的消息,我假設 ? 是您的前綴

                  You can do both of these commands (the join and leave channel commands) in two ways, one is by using on_message, and the other is by using @bot.commands. It's is best to use bot.command instead of on_message for commands as bot.commands has more features plus I think it's fast after all it was built for commands. So I'll rewrite both of your commands using bot.command and also put using on_message there incase you don't want to use bot.command. According to your message, I'm assuming ? is your prefix

                  @bot.event
                  async def on_message(message):
                      if (message.content.startswith('?join')):
                          if (message.author.voice): # If the person is in a channel
                              channel = message.author.voice.channel
                              await channel.connect()
                              await message.channel.send('Bot joined')
                          else: #But is (s)he isn't in a voice channel
                              await message.channel.send("You must be in a voice channel first so I can join it.")
                  
                      elif message.content.startswith('?~'): # Saying ?~ will make bot leave channel
                          if (message.guild.voice_client): # If the bot is in a voice channel 
                              await message.guild.voice_client.disconnect() # Leave the channel
                              await message.channel.send('Bot left')
                          else: # But if it isn't
                              await message.channel.send("I'm not in a voice channel, use the join command to make me join")
                      await bot.process_commands(message) # Always put this at the bottom of on_message to make commands work properly
                  

                  使用 bot.command

                  @bot.command()
                  async def join(ctx):
                      if (ctx.author.voice): # If the person is in a channel
                          channel = ctx.author.voice.channel
                          await channel.connect()
                          await ctx.send('Bot joined')
                      else: #But is (s)he isn't in a voice channel
                          await ctx.send("You must be in a voice channel first so I can join it.")
                  
                  @bot.command(name = ["~"])
                  async def leave(ctx): # Note: ?leave won't work, only ?~ will work unless you change  `name = ["~"]` to `aliases = ["~"]` so both can work.
                      if (ctx.voice_client): # If the bot is in a voice channel 
                          await ctx.guild.voice_client.disconnect() # Leave the channel
                          await ctx.send('Bot left')
                      else: # But if it isn't
                          await ctx.send("I'm not in a voice channel, use the join command to make me join")
                  
                  

                  這篇關于Python discord bot 離開語音頻道的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='G7Zfr'></small><noframes id='G7Zfr'>

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

                            <tfoot id='G7Zfr'></tfoot>
                          • <i id='G7Zfr'><tr id='G7Zfr'><dt id='G7Zfr'><q id='G7Zfr'><span id='G7Zfr'><b id='G7Zfr'><form id='G7Zfr'><ins id='G7Zfr'></ins><ul id='G7Zfr'></ul><sub id='G7Zfr'></sub></form><legend id='G7Zfr'></legend><bdo id='G7Zfr'><pre id='G7Zfr'><center id='G7Zfr'></center></pre></bdo></b><th id='G7Zfr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='G7Zfr'><tfoot id='G7Zfr'></tfoot><dl id='G7Zfr'><fieldset id='G7Zfr'></fieldset></dl></div>
                            主站蜘蛛池模板: 国产精品久久久久久久午夜片 | 男女羞羞的网站 | 国产精品一区二区在线 | 美女视频一区二区三区 | 91在线免费观看网站 | 欧美激情a∨在线视频播放 成人免费共享视频 | av激情在线| 国产精品一区二区三区在线 | 国产视频一区二区 | 国产午夜视频 | 久久一日本道色综合久久 | 久久久久久久久久久高潮一区二区 | 欧美一区二区三 | 一起操网站 | 国产欧美综合在线 | a级在线免费视频 | 狠狠综合网 | 国产一区二区三区视频免费观看 | 国产羞羞视频在线观看 | 成人av一区二区在线观看 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | 成人精品国产免费网站 | 国产成人一区 | 国产精品色 | av免费观看在线 | 男人午夜视频 | 视频一区二区在线观看 | 国产精品综合一区二区 | 国产午夜精品一区二区三区嫩草 | 久久久国产精品一区 | 国产午夜精品久久久 | 99久久国产 | 91色综合| 81精品国产乱码久久久久久 | 九九精品在线 | 三区四区在线观看 | 欧美一区二区在线观看 | 国产亚洲网站 | 日p视频免费看 | 黄色网址免费看 | 久久久久久久av麻豆果冻 |