Description
The command add_messages collects messages from the C4GT Discord server and saves data in a database.
There is a need to have this task be automated so that it repeats at regular intervals (or at specific times) in the background while the bot is active
An illustration of a possible implementation for reference:
@tasks.loop(seconds=60) # Runs every 60 seconds
async def my_task():
guild_id = 1234567890 # Replace with the actual guild ID
guild = bot.get_guild(guild_id)
channel_id = 1234567890 # Replace with the actual channel ID
channel = guild.get_channel(channel_id)
start_command = bot.get_command('start_task')
stop_command = bot.get_command('stop_task')
ctx = await bot.get_context(channel)
await start_command.invoke(ctx)
await asyncio.sleep(10) # Wait for 10 seconds
await stop_command.invoke(ctx)
@bot.command()
async def start_task(ctx):
my_task.start()
await ctx.send('Task started!')
@bot.command()
async def stop_task(ctx):
my_task.stop()
await ctx.send('Task stopped!')
bot.run('YOUR_BOT_TOKEN')
Goals:
Product Name:
C4GT
Project
Official Code4GovTech Discord Bot
Organization Name:
Samagra
Tech Skills Needed:
Python, Quart
Mentor(s)
@KDwevedi
Complexity
Low
Category
Feature
Sub Category
Refactoring, Beginner Friendly
Description
The command add_messages collects messages from the C4GT Discord server and saves data in a database.
There is a need to have this task be automated so that it repeats at regular intervals (or at specific times) in the background while the bot is active
An illustration of a possible implementation for reference:
Goals:
Product Name:
C4GT
Project
Official Code4GovTech Discord Bot
Organization Name:
Samagra
Tech Skills Needed:
Python, Quart
Mentor(s)
@KDwevedi
Complexity
Low
Category
Feature
Sub Category
Refactoring, Beginner Friendly