当有人将我的机器人添加到他们的服务器上时,机器人会在我的支持服务器上发送一条消息,该服务器的信息被加入。像嵌入:标题: Bot加入了一个新的服务器描述:公会名称,公会id,公会邀请链接或服务器邀请链接
发布于 2021-12-11 21:41:51
为此,您应该使用guildCreate类的Client事件。(https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-guildCreate)
guildCreate事件返回回调中的guild参数,这是添加bot的公会。下面是一个可以使用此事件的小示例:
const client = new Client({intents: ['Your Intents Here']});
client.on('guildCreate', guild => {
const mainguild = client.guilds.cache.get('Your Guild ID Here');
const channel = mainguild.channels.cache.get('Your Channel ID Here');
const embed = new MessageEmbed()
.setColor(`GREEN`)
.setTitle(`Bot has been added`)
.setAuthor(guild.name, guild.iconURL({dynamic: true}))
.setDescription(`I've been added to the server '${guild.name}'. Here you have some more info...`)
.setTimestamp();
channel.send({ embeds: [embed] });
});您可以看到这里可用于嵌入的属性和函数。
https://stackoverflow.com/questions/70318086
复制相似问题