Search code examples
javascriptdiscorddiscord.jsbotsreplit

;[discord.js] How to check author id of a message id equal bot id or not


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)


Solution

  • 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())