本文介紹了discord.py 檢查是否有大規模加入(raid)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想讓我的機器人使用 discord.py 檢查是否有超過 10 人在 15 秒內進入服務器
I would like to have my bot check if more than 10 people enter in 15 seconds in a server with discord.py
discord.py有默認功能還是我自己創建?
Is there a default function of discord.py or do I have to create it myself?
推薦答案
找不到這樣的功能!但是制作一個并不難:
I couldn't find such a function! However making one is not so hard:
import time
...
THRESHOLD = 10
m = []
time_ = time.time()
def antiraid(member):
global m
global time_
m.append(member)
if time.time() - time_ >= 15.0:
time_ = time.time()
if len(m) >= THRESHOLD:
return True
else:
return False
m = []
@bot.event
async def on_member_join(member):
bool_ = antiraid(member)
print('Raid state: %s' % bool_)
注意:這只是一個想法如何制作這個功能!您也可以使用可能更好的線程來實現這一點.
Note: This is only an idea how to make this function! You can also implement this with threads which might be better.
這篇關于discord.py 檢查是否有大規模加入(raid)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!