question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bot on ready event send message

See original GitHub issue

Hey guys! I’m currently writing a small git bot, and yeah.

I’m trying to send a message on ready event. That’s my current code: bot.on('ready', () => { console.log('ready!'); bot.sendMessage('general', 'test'); });

yeah… I don’t receive a message. What I did wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JoeRoddycommented, Jun 8, 2017

@GlitchMasta47 Hey dude, not sure if you’re still trying to accomplish this, but I was searching for a way to do it too.

You need to call sendmessage() on a channel object rather than the client.

client.on('ready', () => {
  var channel = client.channels.get('my-unique-channel-id');
  channel.sendMessage("Hello world");
});
1reaction
acdenisSKcommented, May 24, 2016

bot.sendMessage() only takes a resolvable so either put a channel object or an actual id in it

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to a send message in a channel when the bot is ready?
fetch and this function returns a promise that resolves to a channel. Here is your new ready event. client.on('ready', () => { client....
Read more >
Events & The Documentation · A Guide to Discord Bots - Maah
The full list can be seen here, under the "Events" category. We can see the "ready" and "message" events that we used earlier....
Read more >
Event handling - discord.js Guide
Client#event:ready open in new window emits once when the Client becomes ready for use, and Client#event:interactionCreate open in new window ...
Read more >
Quickstart - Discord.py - Read the Docs
In our case, the on_ready() event is called when the bot has finished logging in and setting things up and the on_message() event...
Read more >
How to Make a Discord Bot: An Overview and Tutorial - Toptal
log('Connected and ready.'); }); // Every time a message is sent anywhere the bot is present, // this event will fire and we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found