【问题标题】:hello i do command to tempmute and i have one problem你好,我做了临时命令,我有一个问题
【发布时间】:2021-09-14 14:52:05
【问题描述】:

在我的所有代码中,我只有一个问题,时间不会结束,也不会在时间结束时取消静音播放器:

class DurationConverter(commands.Converter):
  async def convert(self, ctx, argument):
    amount = argument[:-1]
    unit = argument[-1]

    if amount.isdigit() and unit in ['s', 'm', 'h', 'd']:
      return (int(amount), unit)

    raise commands.BadArgument(message='Not a valid duration')

@client.command(name='mute')
@commands.has_permissions(manage_messages=True)
async def tempmute(ctx, member: commands.MemberConverter, duration: DurationConverter, reason):
  channel = client.get_channel(841075670233776149)


  multiplier = {'s': 1, 'm': 60, 'h': 3600}
  amount, unit = duration

  guild = ctx.guild
  mutedRole = discord.utils.get(guild.roles, name="Muted")



  if not mutedRole:
    mutedRole = await guild.create_role(name="Muted")

    for channel in guild.channels:
      await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
  await member.add_roles(mutedRole, reason=reason)
  embed = discord.Embed(title=f'Wyciszony!', description=f"{member.mention} został wyciszony. ", colour=discord.Colour.light_gray())
  embed.add_field(name="Powód:", value=reason, inline=False)
  embed.add_field(name="Wyciszenie zostanie usunięte za:", value=f"{amount}{unit}", inline=False)
  await ctx.send(embed=embed)
  await asyncio.sleep(duration)
  await member.remove_roles(mutedRole)

有人可以帮助我吗?我尝试了很多,但仍然没有。我想我的数据库可能有问题。

【问题讨论】:

  • 我无法真正理解一件事,请您重新表述整个问题,也许格式更好一点?
  • SO 是一个英文网站
  • 好吧,翻译一下,然后说英语写信给我
  • 你输入时间了吗?

标签: python discord command discord.py


【解决方案1】:

你输入时间了吗?会有很大帮助

import time

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 2020-12-02
    • 2020-08-13
    • 2021-08-30
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多