禁止特定时间的人,然后在该时间用完后取消禁止人。但是,当同时禁止更多用户该怎么办?

时间:2020-05-14 08:45:56

标签: python

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

我需要帮助,因此每个玩家都有自己的时间。现在,它完成一个计时器,然后启动另一个计时器。我尝试了穿线,但我不知道如何。我该如何解决?

0 个答案:

没有答案