Discord Send Message To Guild Upon Join Help?

Hello I’d like to make a bot send a message to the guild when it’s added like thanks for adding me or something like that I currently have this code


module.exports = (client, guild) => {
	// We need to add this guild to our settings!
	wait(1000); // eslint-disable-line no-undef
	client.log('log', `Joined guild ${guild.name} (${guild.id})`, 'GUILD');
	client.settings.set(guild.id, client.config.defaultSettings);

	var gCount = client.guilds.size;
	var game = client.config.playingGame.replace('{{prefix}}', client.config.defaultSettings.prefix).replace('{{guilds}}', gCount);
	client.user.setPresence({ status: client.config.status, game: { name: game, type: 0 } });
};

Hi @KyleBurnip! Can you provide some more context for what’s giving you trouble? Are there are any errors you’re encountering?

No errors I just want to make that code send a message to the channel of a server that adds the bot @househaunt

Use the guildCreate event, Might that will help you

    let channelID;
    let channels = guild.channels;
    channelLoop:
    for (let c of channels) {
        let channelType = c[1].type;
        if (channelType === "text") {
            channelID = c[0];
            break channelLoop;
        }
    }

    let channel = client.channels.get(guild.systemChannelID || channelID);
    channel.send(`Your message here!`);

put this code inside your “guildCreate” event, and everytime your bot joins a new server, it will send whatever message you specified, to the first channel in the server!

@Callum-OKane what about making this an embed with Multiple lines of text

Yep, you can do that!

underneath let channel = ... have your embed code, then for channel.send just have channel.send(embed) replace embed with whatever you defined your embed as.

you need a GuildMemberAdd event