samedi 22 août 2020

Im wondering how I would be able to get a discord bot to randomly ping someone from the guild its in with discord.js

I have this

    }else if (message.content.toLowerCase() === `${prefix}command`) {
    message.delete()
    const randomuser = Array.from(message.member.guild.members)
    randomperson = (math.random() *0 + guild.membercount)
    message.channel.send([randomuser])
  .then(msg => {
    msg.delete({ timeout: 100 })
  })

but using it results with this

    message.channel.send([Array.from(message.member.guild.members())])
    TypeError: message.member.guild.members is not a function
    at Client.<anonymous> (C:\Users\mrcoo\Desktop\Discord Bots\WeeWeeBot\WeeWeeBot\index.js:59:59)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\mrcoo\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\mrcoo\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\mrcoo\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\mrcoo\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\mrcoo\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\mrcoo\node_modules\ws\lib\event-target.js:125:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\mrcoo\node_modules\ws\lib\websocket.js:797:20)

I want to make it get an array of users from the guild that the message was sent in and then randomly choose one using the amount of users in the guild and all the tutorials I've found are for v11.5.1




Aucun commentaire:

Enregistrer un commentaire