首页 > 解决方案 > DiscordAPIError:未知消息(请帮助)

问题描述

早上好,很抱歉给您带来不便。

我正在尝试编辑几天前通过我的机器人发送的消息,但它不允许我编辑它。

我确定这是因为它已经大约 7 天了,但即便如此,我想知道是否有办法编辑该消息。

再次感谢,给您带来的不便深表歉意。

      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:未知消息

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

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

在异步 MessageManager._fetchId (/home/bungee/Discord-Bots/Uniito-bot/node_modules/discord.js/src/managers/MessageManager.js:135

在异步客户端。(/home/bungee/Discord-Bots/Uniito-bot/client.js:105:33){方法:'get',路径:'/channels/738226897690820680/messages/815522275344252928',代码:10008,httpStatus:404}

标签: javascriptnode.jsdiscord.js

解决方案


错误是正确的,但您没有发现错误,因为您的逻辑有误。

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

我相信你的 if 应该是

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

这种情况将检查获取请求的响应..


推荐阅读