in

Unable to send a message to Discord using discord.py


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.



Source: https://stackoverflow.com/questions/70718105/unable-to-send-a-message-to-discord-using-discord-py

test with firebase database throwing error

AirPods 3 return to all-time low of $140 in today’s best deals, plus iPhone 12 cases from $10, more thumbnail

AirPods 3 return to all-time low of $140 in today’s best deals, plus iPhone 12 cases from $10, more