不和谐机器人计时器.py
discord-timers的Python项目详细描述
不和谐计时器
discord.py的一个简单扩展,提供基本的计时器支持。
安装
pip install discord-timers -U
示例
importdatetimefromdiscord.extimportcommands,timersbot=commands.Bot(command_prefix="!")bot.timer_manager=timers.TimerManager(bot)@bot.command(name="remind")asyncdefremind(ctx,time,*,text):"""Remind to do something on a date. The date must be in ``Y/M/D`` format."""date=datetime.datetime(*map(int,time.split("/")))bot.timer_manager.create_timer("reminder",date,args=(ctx.channel.id,ctx.author.id,text))# or without the managertimers.Timer(bot,"reminder",date,args=(ctx.channel.id,ctx.author.id,text)).start()@bot.eventasyncdefon_reminder(channel_id,author_id,text):channel=bot.get_channel(channel_id)awaitchannel.send("Hey, <@{0}>, remember to: {1}".format(author_id,text))bot.run("token")