chrsmlls333 / ketchum-discord-bot

A simple bot to scrape Discord for download links
MIT License
0 stars 0 forks source link

PM2 Error: message.channel.permissionsFor is not a function #20

Open chrsmlls333 opened 3 years ago

chrsmlls333 commented 3 years ago

ERROR DETECTED ON KETCHUM-DOWNLOADER

  AT: October 11, 2021 1:49 AM APP: ketchum-downloader

STACK TRACE

TypeError: message.channel.permissionsFor is not a function
    at Client. (/app/index.js:51:39)
    at Client.emit (events.js:314:20)
    at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/app/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (/app/node_modules/ws/lib/websocket.js:825:20)

CODE LINES

client.on('message', async message => {

  // Check message for basic validity
>>const perms = await message.channel.permissionsFor(client.user);
  if (
    !message.content.startsWith(prefix) || 
    message.author.bot ||
    !perms.has('SEND_MESSAGES')
  ) return;
chrsmlls333 commented 3 years ago

I think this is related to the bot getting DMs