K
K
Kirill2020-11-01 18:00:39
JavaScript
Kirill, 2020-11-01 18:00:39

Why is it throwing an UnknownMessage error?

module.exports = {
  name: 'verify',
  description: 'Verifing the user',
  execute(message, args) {
        const channel = `<#741329939336527902>`
        if(message.author.bot) return;
        if(message.channel.id === '741584167728316477') 
            message.delete();
        if(message.content.toLowerCase() === '!verify' && message.channel.id === '741584167728316477')
        {
            message.delete().catch(err => console.log(err));
            const role = message.guild.roles.cache.get('688192159811108907');
            if (role) {
            message.member.roles.add(role);
            console.log("Role added!");
            if (args[1]) {
                if (!message.guild.me.hasPermission('MANAGE_NICKNAMES')) return message.channel.send('I don\'t have permission to change your nickname!');
                message.member.setNickname(args[1]);
            }
            else {
                return message.author.send(`Пожалуйста, напишите свой игровой ник в канале ${channel}!`)
            }
            }
            try{
                something
                } catch (err) {
                console.log(err)
                }
        }
    },
};

Gives an error message:
(node:14888) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
    at RequestHandler.execute (C:\Users\Кирилл\Documents\discord-bots\verification-bot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:14888) 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:14888) [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.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitry-toster, 2020-11-02
@KIRIK12

wang due to the repeated call to delete the message, i.e. this condition works for you

if(message.channel.id === '741584167728316477') message.delete();

and what goes below
if(message.content.toLowerCase() === '!verify' && message.channel.id === '741584167728316477')
   message.delete().catch(err => console.log(err));

you need to combine these two conditions into one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question