Skip to content

PendragonLore/discord-timers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discord-timers

A simple extension for discord.py which provides basic timer support.

Installing

pip install discord-timers -U

Example

import datetime

from discord.ext import commands, timers


bot = commands.Bot(command_prefix="!")
bot.timer_manager = timers.TimerManager(bot)


@bot.command(name="remind")
async def remind(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 manager
    timers.Timer(bot, "reminder", date, args=(ctx.channel.id, ctx.author.id, text)).start()

@bot.event
async def on_reminder(channel_id, author_id, text):
    channel = bot.get_channel(channel_id)
    
    await channel.send("Hey, <@{0}>, remember to: {1}".format(author_id, text))


bot.run("token")

About

Timers for discord.py powered bots.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages