Skip to main content

Timers for bots made with discord.py

Project description

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord-timers-0.1.0.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distributions

discord_timers-0.1.0-py3.7.egg (8.9 kB view hashes)

Uploaded Source

discord_timers-0.1.0-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page