'I'm Trying to Build a Discord Bot that Sends a Message once Every Scheduled Interval
import discord
import time
import random
import schedule
import asyncio
async def run_scheduled_tasks():
while True:
schedule.run_pending()
await asyncio.sleep(1)
client = discord.Client()
client.loop.create_task(run_scheduled_tasks())
@client.event
async def on_ready():
print("Bot Online")
@client.event
async def reminder():
channel = client.get_channel(REDACTED)
seniors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sender = random.randint(0, len(seniors) - 1)
channel.send(seniors[sender], 'please send out the weekly email for this week')
print("success")
schedule.every().thursday.at("11:49").do(reminder)
client.run(REDACTED)
that's my code so far it should every week send out a message with a value from the list, but all is does now is print in the console that the bot is online
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
