Skip to content
Live countdown bot for Discord
Profile icon

I'm trying to develope a bot that can live countdown in the channel.

If a user type '!t', then the bot will send a message with 'Timer is running - 5 seconds' and it keeps mentioning exactly the time remaining in the same message every time the time passes by 1 second such "Timer is running - 3 seconds, Timer is running - 1 seconds"....
And when it reaches 0 seconds then the message will be 'Timer ends - 0'

I just google it and found some code to apply this function, but have no idea if it's correct. Could anyone help one this?

import discord
import random
import os
import time

client = discord.Client()

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

async def on_message(message):
if == client.user:

if message.content.startswith('!t'): Text = "" learn = message.content.split(" ") vrsize = len(learn) vrsize = int(vrsize) for i in range(1, vrsize): Text = Text + " " + learn[i] secint = int(Text) sec = secint for i in range(sec, 0, -1): print(i) await client.send_message(, embed=discord.Embed(description='Timer is running : '+str(i)+'second')) time.sleep(1) else: print("GO") await client.send_message(, embed=discord.Embed(description='Timer ends'))'TOKEN'))

You are viewing a single comment. View All
Profile icon


, yes I did but the console has shown the following error msg when I type !t in the channel.
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/", line 343, in _run_event
await coro(*args, **kwargs)
File "", line 27, in on_message
secint = int(Text)
ValueError: invalid literal for int() with base 10: ''