List of guilds bot is in – Code snippet

List of guilds bot is in – Code snippet

So, using Discord.js and Node.js have you wondered what guilds your bot is in?
If so, the this little snippet might interest you:

if (message.author.id != 'YOUR_USERID_HERE') {
    message.client.channels.cache.get('CHANNEL_ID').send(`${message.author} tried to ask what guilds I'm in!`);
    message.channel.send(`This function is reserved for the bots owner!`);
    return;
} else {
    let sicon = message.guild.iconURL();
    let guilds = message.client.guilds.cache.map(guild => guild.name)
    let guildEmbed = new Discord.MessageEmbed()
        .setDescription("I can be found in the following guilds:")
        .setColor('#0099ff')
        .setThumbnail(sicon)
        .addField('Guilds:', guilds)
    message.channel.send(guildEmbed);
}

Replace YOUR_USERID_HERE with your own user id, and CHANNEL_ID with the ID of your logchannel (if you have one). If not, then comment out or remove this line.
This will list every guild your bot is in, and only for you! If someone else wants to use it, they simply get the message : Reserved for bot owner!

I will be posting snippets and maybe also complete codes for functions and/or games I create. For now, it’s just snippets like this one.
I have also implemented the KICK and BAN functions in my bot CodeLog, so this is now Live!

Leave a Reply

Your email address will not be published. Required fields are marked *