Так что я пропустил или что я забыл? Я хочу, чтобы бот отправлял новое сообщение, когда пользователь реагирует на старое. Бот уже отреагировал на свое сообщение, так что пользователю нужно только нажать A или B. чтобы отреагировать.
const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.on('ready', () => {
console.log('Ready!');
})
client.on("guildMemberAdd", async member => {
const dmErr = false;
try {
await member.send(`Hello ${member}, welcome to the PotatoHost Server!
I want to help you and so my question is: Do you want to buy a server or do you need more informations first? \n
A: I want to buy a server
B: I need more informations first \n
Please react to this message with A or B.`)
.then(function (message) {
message.react("?")
message.react("?")
const filter = (reaction, user) => {
return ['?', '?'].includes(reaction.emoji.name) && user.id === message.author.id;
};
})
message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '?') {
message.reply('Ok, so you want to buy a server. Let me recommend you to visit <#699374469977735208>.');
}
else {
message.reply(`Ok, so you need more informations first. Let me recommend you to visit <#699374469977735208>.`);
}
})
.catch(function (message) {
console.error('One of the emojis failed to react, or the user has dms disabled.')
})
} catch (error) {
dmErr = true;
} if (dmErr === true) {
console.log(error)
}
});
client.login(token);
Это ошибка:
(node:19044) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
at Client.<anonymous> (C:\Users\nicos\OneDrive\Documents\Discord Bots\PotatoHost Bot\index.js:41:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:19044) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19044) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.