This Snippet makes it easy for you to log on wich server your bot is joining, with some details about the server.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const channelLogID = process.env.JOIN_SERVER_LOG_CHANNEL_ID;
const guildID = context.params.event.id;
const guildName = context.params.event.name;
const guildIcon = context.params.event.icon;
const memberCount = context.params.event.member_count;
const ownerID = context.params.event.owner_id;
const guildIconURL = `https://cdn.discordapp.com/icons/${guildID}/${guildIcon}.png`;
let servers = await lib.discord.guilds['@0.1.0'].list({
limit: 100,
});
let owner = await lib.discord.users['@0.1.6'].retrieve({
user_id: ownerID,
});
const ownerUsername = owner.username;
const ownerDiscriminator = owner.discriminator;
let message = {
channel_id: `${channelLogID}`,
content: '',
tts: false,
embeds: [
{
type: 'rich',
title: `Bot joined a new Guild`,
description: `I am now in \`${
servers.length === 100 ? servers.length + '+' : servers.length
}\` guilds`,
color: 0xffff,
fields: [
{
name: `GuildName`,
value: `${guildName}`,
},
{
name: `GuildID`,
value: `${guildID}`,
},
{
name: `Owner`,
value: `Name: ${ownerUsername}#${ownerDiscriminator}\nID: ${ownerID}\n<@${ownerID}>`,
},
{
name: `Membercount`,
value: `${memberCount}`,
},
],
thumbnail: {
url: `${guildIconURL}`,
height: 0,
width: 0,
},
},
],
};
await lib.discord.channels['@0.2.2'].messages.create(message);