import discord
from discord.ext import commands
import discord.utils
import time
import threading
@client.command()
@commands.has_permissions(view_audit_log=True)
async def ban(ctx, member: discord.Member, minutes):
guild = ctx.guild
await ctx.send(f"{member} was banned for{minutes}.")
guild = member.guild
role = discord.utils.get(guild.roles, name="BANNED")
await member.add_roles(role)
seconds = float(minutes) * float(60)
print(seconds)
seconds = float(seconds) + time.time()
await unbaan(ctx, member, seconds)
async def unbaan(ctx, member, seconds):
should_wait = True
guild = member.guild
role = discord.utils.get(guild.roles, name="BANNED")
while should_wait:
time.sleep(1)
print(seconds)
print(time.time())
if time.time() > seconds:
await member.remove_roles(role)
await ctx.send("User unbanned")
should_wait = False
我需要帮助,因此每个玩家都有自己的时间。现在,它完成一个计时器,然后启动另一个计时器。我尝试了穿线,但我不知道如何。我该如何解决?