你好,我命令tempmute,我有一个问题



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

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)

有人能帮我吗?我试了很多,但还是一无所获。我想我的数据库可能有问题。

您导入时间了吗?这将对有很大帮助

import time

最新更新