Reputation:
Here's the code:
FUNAI.on('guildCreate', joinedGuild => {
joinedGuild.send(`Hello ${joinedGuild.guild.name}!`)
});
I've tried everything
Upvotes: 0
Views: 230
Reputation: 429
Your code tries to send a message to a guild/server, which is not possible. However, you can try to send it to the #general channel if it exists (since Discord has removed the default channel function in 2017) :
const getDefaultChannel = (guild) => {
// Check for a "general" channel, which is often default chat
const generalChannel = guild.channels.cache.find(channel => channel.name === "general");
if (generalChannel)
return generalChannel;
}
FUNAI.on('guildCreate', joinedGuild => {
var defChannel = getDefaultChannel(joinedGuild);
console.log(joinedGuild)
if (defChannel) defChannel.send(`Hello ${joinedGuild.name}!`)
});
Upvotes: 1