标题几乎总结了一下,但是我将添加更多信息。我正在尝试使一个机器人在有人加入时发送味精。该味精将嵌入新帐户的一些信息。味精需要在2个不同的通道上编写,并向新用户发送PM。
我已经尝试过这样做,但是我不知道为什么它不发送消息:
module.exports = (client) => {
const Discord = require("discord.js")
const moment = require("moment");
require('moment-duration-format');
moment.locale('es');
client.on("guildMemberAdd", (member) => {
const embedGMA = new Discord.MessageEmbed()
.setTitle("? **NEW MEMBER**")
.setDescription('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬')
.setThumbnail(member.avatarURL())
.addField('USER:',member.tag, true)
.addField('MEMBER:', member.user, true)
.addField('ID:', member.id, true)
.addField('ACCOUNT CREATED:', member.createdAt.toDateString(), true)
.setColor("GREEN")
.addField('NOW WE ARE ' + member.guild.memberCount + ' MEMBERS.', true )
.setTimestamp()
.setFooter(server.name, server.iconURL())
member.send("HERE GOES THE PM")
let channel1 = client.channels.cache.get('CHANNEL ID');
let channel2 = client.channels.cache.get('CHANNEL ID');
channel1.send({ embed : embedGMA})
channel2.send({ embed : embedGMA})
});
}
答案 0 :(得分:0)
据我所知,您正在尝试在Embed内发送Embed,因为您在此处声明了Embed:“ const embedGMA = new Discord.MessageEmbed()”,然后尝试在此处再次将其作为Embed发送: channel1.send({embed:embedGMA})”。请参阅here以供参考。 要修复它,只需尝试
编辑:您需要将下面的代码放入index.js文件(或任何您命名为启动bot的文件)
const Discord = require("discord.js");
/* We can ignore this for the most part as this has nothing to do with the code below
const moment = require("moment");
require('moment-duration-format');
moment.locale('es'); */
client.on("guildMemberAdd", (member) => {
//here we declare a new Embed
const embedGMA = new Discord.MessageEmbed()
.setTitle("? **NEW MEMBER**")
.setDescription('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬')
.setThumbnail(member.user.displayAvatarURL()) //**
.addField('USER:', member.displayName, true) //**
.addField('MEMBER:', member.user, true)
.addField('ID:', member.id, true)
.addField('ACCOUNT CREATED:', member.createdAt.toDateString(), true) // This might give you trouble if you don't have this function defined somewhere
.setColor("GREEN")
.addField('NOW WE ARE ' + member.guild.memberCount + ' MEMBERS.', `\u200b`, true) //**
.setTimestamp()
.setFooter(server.name, server.iconURL()); // You need to define server somewhere
member.send("HERE GOES THE PM")
let channel1 = client.channels.cache.get('CHANNEL ID');
let channel2 = client.channels.cache.get('CHANNEL ID');
//here we just send the Embed
channel1.send(embedGMA);
channel2.send(embedGMA);
});
ps。我还纠正了一些嵌入设置,我用// **
标记了它们