I’m trying to simply create a function that sends a discord message to a specific channel when the bot runs. I want to later call this function in a separate python script.
The code below seems to run fine, and the bot appears online – but it is fails to send the message:
import discord client = discord.Client() client.run("ABCDeFGHIjklMNOP.QrSTuV-HIjklMNOP") # the token @client.event async def on_ready(): logs_channel = client.get_channel(12345689123456789) # the channel ID await logs_channel.send("Bot is up and running") on_ready()
I’m sure I’m missing something basic but I cannot figure out what it is. I’ve tried a similar function in Node.js and it works fine however, I would prefer the bot to work in python. Discord.py is up to date, python is v3.10.
Any help would be greatly appreciated.