Reputation: 29
So, when I was making my bot project, I wanted to add a feature in which sends a message after being invited to a server, as a way of thanking the owner for the invitation, however, I cannot seem to find a way to get this since most of the solutions are outdated, due to the version of the library. Any suggestions?
*User Invites the bot*
Bot: "Thanks for inviting me blah blah blah"
Upvotes: 1
Views: 129
Reputation: 1187
You can use the guildCreate event, that gets triggered every time the bot joins a server, example:
client.on('guildCreate', guild => {
let channel = guild.channels.cache.first();
if(channel) channel.send('Hey!');
}
In this example we get a random channel from the guild and send a message in it, you might also check if the bot has the permission to send messages.
Upvotes: 1