我的问题是我想在用户反应后删除d_msg
。但是它忘记了d_msg
是什么并且无法删除它。我该如何解决?
function English(thechannel, message) {
client.channels.cache.get(thechannel).send("Do u speak English?").then(d_msg => {
d_msg.react("✅");
d_msg.react("❌");
client.on('messageReactionAdd', async (reaction, user) => {
if (user.tag === theuser) {
if (reaction.emoji.name === '✅') {
var role = message.guild.roles.cache.find(role => role.name === "English");
message.member.roles.add(role);
}
}
d_msg.delete();
});
});
}
答案 0 :(得分:0)
const Filter = (reaction, user) => {return (reaction.emoji.name == "✅" || reaction.emoji.name == "❌") && user.id == message.author.id};
message.reply("Do you speak English? \n\n *This prompt will disappear in 30 seconds.*").then(async messageSent => {
await messageSent.react("✅");
await messageSent.react("❌");
messageSent.awaitReactions(Filter, {max: 1, time: 30000, errors: ["time"]}).then(collected => {
messageSent.reactions.removeAll();
if (collected.first().emoji.name == "✅") {
messageSent.edit("You do speak English!");
} else if (collected.first().emoji.name == "❌") {
messageSent.edit("You do not speak English!");
}
}).catch(e => {
messageSent.edit("This prompt expired.");
messageSent.reactions.removeAll();
});
});