Skip to content Skip to sidebar Skip to footer

Discord.py Schedule

This is what I have so far... is does work for the amount delay seconds I want, but how to I add the time module or shedule module to make it work.. Just in case I want the bot to

Solution 1:

You can do this using discord.ext.tasks.

import discord
import asyncio
from discord.ext import commands
from discord.ext import tasks
import time

TOKEN = 'xxxxx'

client = commands.Bot(command_prefix = '.')

channel_id = '515994xxxxx5036697'

@client.event
async def on_ready():
    print('Bot Online.')

@tasks.loop(days=1)
async def alarm_message():
    await client.wait_until_ready()
    channel = client.get_channel(channel_id)
    message = 'test'
    await channel.send(message)

alarm_message.start()

client.run(TOKEN)

Post a Comment for "Discord.py Schedule"