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

213
Views
Discord.js assigning role to all users, works in test server but not on live server(command)

I have slight issue I have discord bot in discord.js, we recently added 3 roles that are defaulted on each new member. But ofc this not apply to all the old ones and I dont really fancy assigning it to each individual user. So I made this following script below, This script works fully on my test discord server but throws errors on the live server. The error is"Cannot read property 'roles' of undefined". Anyone knows why that is the case?

module.exports = {
    commands: ['updatetags', 'utall'],
    minArgs: 0,
    expectedArgs: "Incorrect Syntax",
    callback: (message) => {

        let cosmeticTag = message.guild.roles.cache.find(role => role.name === "━━━━━{Cosmetics}━━━━━");
        let otherTag = message.guild.roles.cache.find(role => role.name === "╶━━━━━{Other}━━━━━╴");
        let gamesTag = message.guild.roles.cache.find(role => role.name === "╶━━━━━{Games}━━━━━╴");
        const members = message.guild.members.cache.map((member) => member);
        for (let index = 0; index < message.guild.memberCount; index++) {

            members[index].roles.add(cosmeticTag)
            members[index].roles.add(otherTag)
            members[index].roles.add(gamesTag)
        }
        message.reply('Updated Role Dividers For All Members').then(message => {
            message.delete({
                timeout: 10000
            });
        }).catch();
    },
}
about 4 years ago · Juan Pablo Isaza
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!