discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.38k stars 3.97k forks source link

find is not a function #3920

Closed ninkertje closed 4 years ago

ninkertje commented 4 years ago

heey new on coding so kinda noob in this.... but still im coding an discord bot an want to make an command where you need an certain rank for just like "moderator" but when i start the bot it works but when i doe +clear 5 it says:

TypeError: message.member.roles.find is not a function
    at Client.<anonymous> (D:\Gebruikers\snicker\Bureaublad\discord bot\index.js:31:39)
    at Client.emit (events.js:311:20)
    at MessageCreateAction.handle (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:435:22)
    at WebSocketShard.onMessage (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:311:20)
    at Receiver.receiverOnMessage (D:\Gebruikers\snicker\Bureaublad\discord bot\node_modules\ws\lib\websocket.js:801:20)

this is the code:

const Discord = require('discord.js');
const bot = new Discord.Client();

const token = '';

const PREFIX = '+'; 

bot.on('ready', () =>{
    console.log('bot is online')
})

bot.on('message', message=>{

    let args = message.content.substring(PREFIX.length).split(" ");

    switch(args[0]){
        case 'ping':
            message.channel.send('pong!');
        break;
        case 'ip':
            message.channel.send('IPADRESS');
        break;
        case 'info':
            if(args[1] === 'staff'){
                message.channel.send('Owner: Raul \nCo-owner: Nick')
            }else{
                message.channel.send('hier is geen informatie voor')
            }
        break;
        case 'clear':
            if (member.roles.find(r => r.name == "moderator")) return message.channel.send('U HEEFT GEEN TOEGANG TOT DEZE COMMANDO')
            if (!args[1]) return message.reply('voer het nummer in van de aantal berichten dat u wilt verwijderen'), setTimeout(() => {
                message.channel.bulkDelete(1)
            }, 3000);
            message.channel.bulkDelete(args[1] + 1);

    }
})

bot.login(token);

anyone know how to fix this?

almostSouji commented 4 years ago

Regarding breaking changes in version 12 and updating:


If you still have questions about discord.js installation or usage please visit the Discord server at https://discord.gg/bRCvFy9. This issue tracker is just for bug reports and enhancement suggestions.