Why does it give an UnknownMessage error?

  • 0
    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)
                    }
            }
        },
    };

    Throws an error:
    (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.
    JavaScript Anonymous, Jul 17, 2020

  • 1 Answers
  • 0
    wangyu because of the repeated call to delete the message, that is, you have this condition.

    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
    Noah Grimes

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!