Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

python - Discord bot update message. (Discord.py)

Windows 10 VSCode Discord.py Python 3

Hey guys, I want my bot to send a message to a specific channel every time it logs on, here is the code:

@client.event
async def on_ready():
    channel = client.get_channel(788532498724290641)
    await channel.send('I have been updated and am now online again.')

There are no errors however no message gets sent when the program is run.

The whole program can be found here but beware it's uncommented and janky: https://github.com/DavisStanko/Discord-Bot

question from:https://stackoverflow.com/questions/66066101/discord-bot-update-message-discord-py

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's because you have multiple on_ready events. You can only have 1 type of each event, otherwise the last interpreted event will be the only one recognized. Merge the two on_ready events into 1 function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...