Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...