const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on("guildCreate", guild => {
let channelID;
let channels = guild.channels.cache;
for (let key in channels) {
let c = channels[key];
if (c.type === "text") {
channelID = c.id;
break;
}
}
let channel = guild.channels.cache.get(guild.systemChannelID || channelID);
channel.send(`Thanks for inviting me into this server!`);
});