• <legend id='PpxSF'><style id='PpxSF'><dir id='PpxSF'><q id='PpxSF'></q></dir></style></legend>
    <tfoot id='PpxSF'></tfoot>

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

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

        我需要帮助在 discord py 中创建 discord py temp 静音命

        时间:2023-10-11

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

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

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

                  <tfoot id='mDzOR'></tfoot>

                    <tbody id='mDzOR'></tbody>
                  本文介绍了我需要帮助在 discord py 中创建 discord py temp 静音命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  I got my discord bot to have a mute command but you have to unmute the user yourself at a later time, I want to have another command called "tempmute" that mutes a member for a certain number of minutes/hours/ or days, this is my code so far, how would I make a temp mute command out of this?

                  #mute command 
                  @client.command()
                  @commands.has_permissions(kick_members=True)
                  async def mute(ctx, member: discord.Member=None):
                      if not member:
                          await ctx.send("Who do you want me to mute?")
                          return
                      role = discord.utils.get(ctx.guild.roles, name="muted")
                      await member.add_roles(role)
                      await ctx.send("ok I did it")
                  

                  解决方案

                  Similar to how you gave them a role to mute them, just add another parameter to take in how long you want them to be muted in seconds. Then you can use await asyncio.sleep(mute_time) before removing that role.

                  The code will look something like:

                  import asyncio
                  
                  #mute command 
                  @client.command()
                  @commands.has_permissions(kick_members=True)
                  async def mute(ctx, member: discord.Member=None, mute_time : int):
                      if not member:
                          await ctx.send("Who do you want me to mute?")
                          return
                      role = discord.utils.get(ctx.guild.roles, name="muted")
                      await member.add_roles(role)
                      await ctx.send("ok I did it")
                  
                      await asyncio.sleep(mute_time)
                      await member.remove_roles(role)
                      await ctx.send("ok times up")
                  
                  

                  这篇关于我需要帮助在 discord py 中创建 discord py temp 静音命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:ModuleNotFoundError:没有名为“不和谐"的模块 下一篇:传递了不正确的令牌

                  相关文章

                  最新文章

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

                    • <bdo id='vh9Mn'></bdo><ul id='vh9Mn'></ul>
                  1. <small id='vh9Mn'></small><noframes id='vh9Mn'>

                  2. <legend id='vh9Mn'><style id='vh9Mn'><dir id='vh9Mn'><q id='vh9Mn'></q></dir></style></legend>
                    <tfoot id='vh9Mn'></tfoot>