Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

python - Discordpy timed message or ban or role, WITH bot restart | discordpy

I want to code a timed ban or mute, but with that I can restart my bot. Is there a nice libary or anyone has an idea to code it?

Thank you very much!

I code with discordpy cogs

question from:https://stackoverflow.com/questions/65860119/discordpy-timed-message-or-ban-or-role-with-bot-restart-discordpy

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You would have to use a database system such as MongoDB or MySQL. You will have to store the active timed ban/mute in a record/document or another table/collection. Then if you are using MySQL you would only select user's that are timed by using Tasks. In MongoDB, you just search for any users that are timed.

You would either make a separate cog or keep it in your moderation cog, it must be executed when it's ready and execute every 5-30 minutes checking if the time is older than the current time. You could use timestamps to accomplish this. Then just update the document/record once the time is up and remove their id from a ban list.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...