我正在我的 discord.js bot 上发出欢迎命令,但它不起作用我猜问题出在缓存部分
我的代码:
client.on('guildMemberAdd', async(member, guild) => {
welcomeSchema.findOne({ guildId: member.guild.id }, async(err, data) => {
if (!data) return;
const user = member.user;
if (data.channelId === "") return;
const channel = member.guild.channels.cache.get(data.channelId);
let welcomeimg = await canva.welcome(member, { link: "http://www.beach-backgrounds.com/wallpapers/view-from-the-hill-on-the-monaco-wallpaper-1920x600-461.jpg" })
const userEmbed = new Discord.MessageEmbed()
.setTitle(`Welcome ${user.username} to ${member.guild.name} the discord server`)
.setThumbnail(`${user.displayAvatarURL()}`)
.setColor("RANDOM")
.addField(`About you`, `\n USER TAG: ${user} \n USER NO: ${member.guild.memberCount}`)
.addField(`About us`, `\n SERVER NAME: ${member.guild.name} \n TOTAL MEMBERS WITH YOU: ${member.guild.memberCount}`)
const attachment = new Discord.MessageAttachment(
welcomeimg,
"welcome-image.png"
);
channel.send(`Hey ${user} welcome to our server **${member.guild.name}** \n`);
channel.send(userEmbed);
channel.send(attachment);
})
});
ps:我也在使用 mongodb