Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Discord.js v13 Why is my member moving command not working?

I've made this command to "wake up" members by moving them 10 times between 2 voice channels. It's supposed to work if you have the administrator permissions (will propably change that in the future tho) and if used incorrectly return the correct usage in an embed. Everything works EXCEPT for the actual moving of users and I can't for the life of me figure out how to move members. Any help? My code:

const { Permissions,MessageEmbed } = require('discord.js')

module.exports = {
    name: 'pobudka',
    description: "Budzi gracza.",
    execute(message, args)
    {
        const target = message.mentions.members.first()
        const usageEmbed = new MessageEmbed() //the embed sent if the usage is incorrect
            .setColor('ff0004')
            .setTitle('Poprawne użycie')
            .addField('rp pobudka @user', 'zamienić @user na wzmiankę użytkownika')

        if(message.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) //checking if the invoking member has the administrator perms to use the command
        {
            if(target)
            {
                for(let i = 10; i > 0; i--) //loop for changing the voice channels 10 times 
                { 
                    message.guild.member(target.id).voice.setChannel("940573437561303080") //moving the member to a different voice channel
                    message.guild.member(target.id).voice.setChannel("946790140003631165") //moving the member to a different voice channel
                }
            }
            else
            {
                message.reply({ embeds: [usageEmbed]}) //sending the usage embed
            }
        }
        else
        {
            message.reply("Nie możesz tego użyć.") //replying if the invoking member doesnt have administrator perms
        }
    }
}

The error I'm getting:

C:\Users\Miki\Desktop\dc bots\jajco bot smol\commands\pobudka.js:22
                    message.guild.member(target.id).voice.setChannel("940573437561303080")
                                  ^

TypeError: message.guild.member is not a function
    at Object.execute (C:\Users\Miki\Desktop\dc bots\jajco bot smol\commands\pobudka.js:22:35)
    at Client.<anonymous> (C:\Users\Miki\Desktop\dc bots\jajco bot smol\main.js:134:44)
    at Client.emit (node:events:520:28)
    at MessageCreateAction.handle (C:\Users\Miki\Desktop\dc bots\jajco bot smol\node_modules\discord.js\src\client\actions\MessageCreate.js:26:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Miki\Desktop\dc bots\jajco bot smol\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)

(and yes the response messages are in polish because this isn't just for me but for a small server which is, you guessed it - polish)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The reason it is erroring is because you need to look for the members from cache but as mentioned above, target is already a member object.

To find members you need to code it like this

message.guild.members.cache.get(target.id)

or like this

message.guild.members.cache.find(member => member.id === target.id)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!