如何在特定时间内捕获所有被禁止的成员?

8i9zcol2  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(213)

我正在设计某种raid机器人,并在stackoverflow上为它找到了一个函数。
您可以在这里找到:discord.py检查是否存在大规模连接(raid)
我根据自己的意愿重写了这个函数,但每次用户被禁止时,都会单独发送一个嵌入,这意味着不会收集ID,而是单独发送。
是否有一种方法可以在60秒内捕获所有用户,然后将其作为一个嵌入包发送?
我已经尝试了以下方法:

allowed = 2 # Allowed joins
m = [] # Create the empty list
time_ = time.time()

def raid(member):
    global m
    global time_
    m.append(member)
    if time.time() - time_ <= 60: # If users join under 60 seconds
        time_ = time.time()
        if len(m) >= allowed:
            return True
        else:
            return False

    @commands.Cog.listener()
    async def on_member_join(self, member):
        if settings == True and KeyError: # Can be ignored, my own function
            bool_ = raid(member)
            print('Raid state: %s' % bool_)
            print(m) # Prints every information
            if bool_ == True:
                for member in m: # Loop over the whole list that gets more entries | IF-statement NOT possible
                    await member.ban(reason="Raid detected!")
                    owner = member.guild.owner
                    embed = discord.Embed(color=discord.Color.red())
                    embed.title = "Raid detected!"
                    embed.description = f"**Banned:**{member.id}" # Shows the correct ID for every ban
                    embed.set_footer(text="XXX")
                    embed.timestamp = datetime.datetime.utcnow()
                    await owner.send(embed=embed) # Embed-"Spam" for every ID
                    await member.ban(reason="Raid detected!") # Works, every user is banned
            else:
                return

我已经试过了 .join(member.id) ,但你不能重复。此外,我还尝试定义禁止用户的函数,但最终还是失败了 None .

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题