所以我正在研究一个像投票嵌入的命令,但它并没有真正起作用。 当我使用(在我的情况下($repvote @user
它无法识别用户或任何东西时..,请告诉我任何解决方案!
如果 (message.author.bot( 返回; if (message.content.startsWith(prefix + "repvote"(( { if (!message.member.hasPermission("MANAGE_ROLES"(( 返回 message.channel.send('You not have that permission! :x:'(.then(message.react('❌'((; let repUser = message.mentions.members.first(( if(!repUser( 返回 message.channel.send("请提及您要为其设置投票的用户!"(.then(message.react(''❌((.then(msg => { msg.delete({ timeout: 5000 }(; const repVoteEmbed = new Discord.MessageEmbed(( repVoteEmbed.setTitle("Vote for Representative Members :crown:"( repVoteEmbed.setDescription('User ${repUser} 希望接收 代表成员 :crown: role!你同意吗? repVoteEmbed.setFooter('Vote by: ${message.author.tag}, start on : ${message.createdAt}'( message.channel.send({repVoteEmbed}(.then(message.react(''((.then(message.react(''✔ ❌(( }) }})```
你错过了message.channel.send(embed).then(msg =>....
Message channel send
返回已发送消息的承诺,因此您需要使用它来做出反应
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('message', async (message) => {
if (message.author.bot) return;
if (message.content.startsWith(prefix + 'repvote')) {
if (!message.member.hasPermission('MANAGE_ROLES')) return message.channel.send('You do not have that permission! :x:').then(message.react('❌'));
let repUser = message.mentions.members.first();
if (!repUser) {
message.channel.send('Please mention the user you want to setup the vote for!').then((declineMsg) => {
message.react('❌');
declineMsg.delete({
timeout: 5000,
});
});
return;
}
const repVoteEmbed = new Discord.MessageEmbed();
repVoteEmbed.setTitle('Vote for Representative Members :crown:');
repVoteEmbed.setDescription(`User ${repUser} wants to recieve Representative Members :crown: role! Do you agree?`);
repVoteEmbed.setFooter(`Vote by: ${message.author.tag}, started on : ${message.createdAt}`);
message.channel.send(repVoteEmbed).then((msg) => {
msg.react(`✔`).then(() => msg.react('❌'));
});
}
});