3
votes

Good morning, I'm sorry for the inconvenience.

I'm trying to edit a message that I sent with my bot a few days ago, but it won't let me edit it.

I'm sure it's because it's been about 7 days, but even so, I would like to know if there is a way to edit that message.

Thanks and again, sorry for the inconvenience.

      client.on('message', async (message) => {
    if (message.content === '!update-info') {
        if (!message.member.hasPermission('MANAGE_MESSAGES')) {
            return message.channel.send('Only server moderators can run this command!')
        }
        const guild = client.guilds.cache.get('734517639732396122');
        if (!guild) return console.log('Unable to find guild.');
        
        const channel = guild.channels.cache.find(c => c.id === '737363248126492772' && c.type === 'text');
        if (!channel) return console.log('Unable to find channel.');
        
        try {
            const messageedit = await message.channel.messages.fetch('815522275344252928');
            if (!message) return console.log('Unable to find message.');
        
             await messageedit.edit("__**Reacciona para activar notificacioness**__\n\n`Actualizaciones:` <:update:815505836880429087> \n`Twitter:` <:twitter:815505836842942474> \n`Facebook:` <:facebook:815505775278424084>\n`Instagram:` <:instagram:815505836608454667>");
            console.log('Mensaje de informacion actualizado.');
        } catch(err) {
            console.error(err);
        }
        message.delete();
    }
  });

DiscordAPIError: Unknown Message

at RequestHandler.execute (/home/bungee/Discord-Bots/Uniito-bot/node_modules/discord.js/src/rest/RequestHandler.js:154:13)

at processTicksAndRejections (internal/process/task_queues.js:97:5) at async RequestHandler.push (/home/bungee/Discord-Bots/Uniito-bot/node_modules/discord.js/src/rest/RequestHandler.js:39:14)

at async MessageManager._fetchId (/home/bungee/Discord-Bots/Uniito-bot/node_modules/discord.js/src/managers/MessageManager.js:135

at async Client. (/home/bungee/Discord-Bots/Uniito-bot/client.js:105:33) { method: 'get', path: '/channels/738226897690820680/messages/815522275344252928', code: 10008, httpStatus: 404 }

1
in your request to that channel - getting that message you're getting a 404 error.. That message doesn't exist.. It might have been deleted ? But the error is correct.. The API is telling you there is no message there.Pogrindis
also you're checking if message is defined after calling it.. Maybe you mean messageedit ?Pogrindis
No, the message has not been deleted, it is there.Zhenk

1 Answers

1
votes

The error is correct, but you're not catching your error because you have a mixup in your logic.

        const messageedit = await message.channel.messages.fetch('815522275344252928');
        if (!message) return console.log('Unable to find message.');

I believe your if should be

        const messageedit = await message.channel.messages.fetch('815522275344252928');
        if (!messageedit) return console.log('Unable to find message.');

This case would check the response of the fetch request..