[英]TypeError: member is not a function when using `${member}`
我有一个 function 在用户加入时在 Discord 上发送随机选择的欢迎消息,并为其添加角色并且它曾经可以工作,但是在更新到 Z4B7D45BF672279F0CF0911EA9E94F37 后,我得到了错误
Welcome ${member}, that will be 6,99 $. Wanna pay cash or credit card?
^类型错误:成员不是函数*
当用户加入时。 有人可以帮我吗? 这是我的代码。
// When a member joins, this function executes.
bot.on('guildMemberAdd', (member) => {
console.log('User ' + member.id + ' has joined the guild.');
// Welcome messages possible options.
let welcomeMessages = [`${member}, welcome to our server :wave:!\n\nNow you're **one of us** :new_moon_with_face:! \n\n`,
`Welcome, ${member}. Hope you enjoy your stay.`, `Look who showed up... ${member}`, `Welcome ${member}, have a pleasant time.`,
`So... ${member} just arrived.`, `Great... ${member} is here!`, `Everyone stand up! ${member} is here.`, `Hello daddy ${member}...`
`Welcome ${member}, that will be 6,99 $. Wanna pay cash or credit card?`
];
let welcomeChannel = member.guild.channels.cache.get(serverData.welcomeChannelId);
let defaultRole = member.guild.roles.cache.get(serverData.defaultRoleId);
// Both the welcome message and GIFs will be chosen randomly.
let welcomeGif = welcomeGifs[Math.floor(Math.random() * welcomeGifs.length)];
let welcomeMessage = welcomeMessages[Math.floor(Math.random() * welcomeMessages.length)];
// This is the variable that stores the user profile picture for later use.
let newUserIcon = member.user.displayAvatarURL;
welcomeChannel.send(`${member}`);
// This is my embedded message, which allows loads of customization.
let welcomeMessageEmbed = new Discord.MessageEmbed()
.setColor(Math.floor(Math.random() * 16777214) + 1) // The color will be random.
.setDescription(welcomeMessage) // A message will be chosen randomly from the welcome messages tab.
.setImage(welcomeGif) // Same with the GIF.
.setThumbnail(newUserIcon) // The icon of the embedded message will be the user profile picture.
// Send in the embed.
welcomeChannel.send(welcomeMessageEmbed);
// This is the default role.
member.roles.add(defaultRole);
});
member
是 object 并且您需要一个字符串。 尝试在模板文字中使用member.displayName
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.