javascript - 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}
解决方案
错误是正确的,但您没有发现错误,因为您的逻辑有误。
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.');
这种情况将检查获取请求的响应..
推荐阅读
- html - 当值改变jquery时改变bg-color
- php - 更新所有类依赖项中的控制器路径
- php - 如何在 docker 设置上使用令牌从 laravel 访问 API 路由?
- python - 使用包含重复列标题的 pandas 更新数据框
- excel - 使用 Resume Next 在循环中处理错误
- c# - 尝试在 VS C# 中保存图像退出,代码为 -2147483645 (0x80000003)
- php - 如何最好地从另一个 Php 文件访问 Php 静态变量
- python - 在 for 循环中更新字典的问题(不是唯一的)
- r - 使用类似 purrr 的函数循环遍历列表的元素
- elasticsearch - Elasticsearch 仅匹配标签数组中给定的标签