简体   繁体   English

如何在Discord Bot中添加时间?

[英]How to add Time in Discord Bot?

How do you make a bot function so that the bot deletes the chat at 0 o'clock (the channel) how do you include times in the bot (Discord.py)你如何制作一个机器人 function 以便机器人删除 0 点钟的聊天(频道)你如何在机器人中包含时间(Discord.py)

Please with example:)请举个例子:)

thanks谢谢

I tried it with google but didnt work so please help我用谷歌试过但没有用所以请帮忙

Just use the discord.ext.tasks extension!只需使用 discord.ext.tasks 扩展名! Just implement this example in your code and modify it so that it fits your variables!只需在您的代码中实现此示例并对其进行修改,使其适合您的变量!

from discord.ext import tasks
from datetime import time #This at your import statements

purge_loop.start() # This cog_load function

@tasks.loop(time=time(hour=0, minute=0)) #this function in your cog
async def purge_loop(self):
   await channel.purge(limit=1000)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM