-3

This is my code

const botID = '986945043849945088'
let msgID = await message.channel.messages.fetch(args[0]).catch(() => undefined);
      if (msgID.includes(botID)) return message.reply(`This message does not belong to <@${client.user.id}>`)      
      if (msgID === undefined) {
        return message.reply('Wrong Message ID!')      
      } else {
        await msgID.edit(args[1]).then(() => message.delete())

This is error:

TypeError: msgID.includes is not a function at Object.exports.callback (/home/runner/J-Bot/Commands/edit.js:30:17)

Julian-V
  • 13
  • 1
  • 6
  • If I edit a message dose not belong to bot this is error: `DiscordAPIError: Cannot edit a message authored by another user at RequestHandler.execute (/home/runner/J-V-Bot/node_modules/discord.js/src/rest/RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (/home/runner/J-V-Bot/node_modules/discord.js/src/rest/RequestHandler.js:51:14) at async MessageManager.edit (/home/runner/J-V-Bot/node_modules/discord.js/src/managers/MessageManager.js:132:15)` How to fix it? – Julian-V Jul 14 '22 at 07:28

1 Answers1

0

msgID is a message. So there's no includes function. Just easily do.

const botID = '986945043849945088'
let msgID = await message.channel.messages.fetch(args[0]).catch(() => undefined);
      if (msgID.author.id != botID) return message.reply(`This message does not belong to <@${client.user.id}>`)      
      if (msgID === undefined) {
        return message.reply('Wrong Message ID!')      
      } else {
        await msgID.edit(args[1]).then(() => message.delete())
Chang Alex
  • 505
  • 3
  • 11