Discord.js反应问题



当我对通道中的消息做出反应时"idere";whith👍则它将消息发送到";idere接受了";当我与👎则它将消息发送到";idere拒绝了";这就是我制作的

但当我都准备好对一条消息做出反应,并想对另一条发送的消息做出反应时,这就是问题所在;idere";具有👍则它在"0"中发送消息2次;idere接受了";当我第三次做出反应时,它会发送3次消息👎

const emojiChannelName = "idere";
const emojiChannelNameAccepted = "idere-accepted";
const emojiChannelNameDeclined = "idere-declined";
client.on("message", async (message) => {
if (message.guild.id === guildID) {
if (message.channel.name === emojiChannelName) {
if (message.author.id !== botID) {
await message.react("👍");
await message.react("👎");
}
}
client.on("messageReactionAdd", async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
let channelAccept = message.guild.channels.cache.find(
(channel) => channel.name === emojiChannelNameAccepted
);
let channelDeclined = message.guild.channels.cache.find(
(channel) => channel.name === emojiChannelNameDeclined
);
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.name === emojiChannelName) {
if (reaction.emoji.name === "👍") {
if (user.id === config.owner) {
if(message.author.id !== botID) {
let accept = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle("Ide accepted")
.setDescription(
`${message.author} Havde en ide som ern**${reaction.message.content}**n(Testing)`
)
.setTimestamp()
.setFooter(`Accepted af ${user.username}`);
await channelAccept.send(accept);
reaction.message.delete();
}
} else {
reaction.message.reactions
.resolve("👍")
.users.remove(reaction.users.cache.keyArray()[1]);
}
}
if (reaction.emoji.name === "👎") {
if (user.id === config.owner) {
let declined = new Discord.MessageEmbed()
.setColor("RED")
.setTitle("Ide declined")
.setDescription(
`${message.author} Havde en ide som ern**${reaction.message.content}**n(Testing)`
)
.setTimestamp()
.setFooter(`Declined af ${user.username}`);
await channelDeclined.send(declined);
reaction.message.delete();
} else {
reaction.message.reactions
.resolve("👎")
.users.remove(reaction.users.cache.keyArray()[1]);
}
}
}
});
}
});```

在发送消息的地方,可以尝试返回消息。

试试这个:

const emojiChannelName = "idere";
const emojiChannelNameAccepted = "idere-accepted";
const emojiChannelNameDeclined = "idere-declined";
client.on("message", async (message) => {
if (message.guild.id === guildID) {
if (message.channel.name === emojiChannelName) {
if (message.author.id !== botID) {
await message.react("👍");
await message.react("👎");
}
}
client.on("messageReactionAdd", async (reaction, user) => {
if (reaction.message.partial) await reaction.message.fetch();
if (reaction.partial) await reaction.fetch();
let channelAccept = message.guild.channels.cache.find(
(channel) => channel.name === emojiChannelNameAccepted
);
let channelDeclined = message.guild.channels.cache.find(
(channel) => channel.name === emojiChannelNameDeclined
);
if (user.bot) return;
if (!reaction.message.guild) return;
if (reaction.message.channel.name === emojiChannelName) {
if (reaction.emoji.name === "👍") {
if (user.id === config.owner) {
if(message.author.id !== botID) {
let accept = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle("Ide accepted")
.setDescription(
`${message.author} Havde en ide som ern**${reaction.message.content}**n(Testing)`
)
.setTimestamp()
.setFooter(`Accepted af ${user.username}`);
await channelAccept.send(accept);
return reaction.message.delete(); //returns the message delete
}
} else {
reaction.message.reactions
.resolve("👍")
.users.remove(reaction.users.cache.keyArray()[1]);
}
}
if (reaction.emoji.name === "👎") {
if (user.id === config.owner) {
let declined = new Discord.MessageEmbed()
.setColor("RED")
.setTitle("Ide declined")
.setDescription(
`${message.author} Havde en ide som ern**${reaction.message.content}**n(Testing)`
)
.setTimestamp()
.setFooter(`Declined af ${user.username}`);
await channelDeclined.send(declined);
return reaction.message.delete(); //returns the message delete
} else {
reaction.message.reactions
.resolve("👎")
.users.remove(reaction.users.cache.keyArray()[1]);
}
}
}
});
}
});

最新更新