Paper
Paper

Reputation: 13

How do I have a bot that can have timer instructions?

I want to make a bot that has a timer command, like !timing 00:00:00

then the bot says @user The alarm time you set is up!

how can I do it?

Upvotes: 0

Views: 111

Answers (1)

Bigdude68
Bigdude68

Reputation: 46

This will let you type !timings 10

NOTE the time is in seconds

Creating the bot

import discord
import time
from discord.ext import commands

client = commands.Bot(command_prefix = '!')  # Setting the command prefix

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

     
client.run('INSERT BOT TOKEN HERE')

Next with the bot you created lest create the command Command:

@client.command(help=('Set a timer or reminder'))
async def timings(ctx, *, wait:int):
    user = ctx.author  # Getting the user

    if wait:  # If a number is given
        time.sleep(wait)  # Waiting the number of seconds given
        await ctx.send(f'Hey {user.mention} your timer is going off')
        return

Add the command below the @Client.event

Upvotes: 1

Related Questions