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

182
Views
TypeError no capturado: no se pueden leer las propiedades de undefined (leyendo 'roles')

Quiero hacer un rol en la lista blanca para hacer un comando y puse esta línea

 if (!message.guild.cache.roles.find(role => role.id === '873595824469344256')) return;

Aparece el error: Uncaught TypeError: Cannot read properties of undefined (reading 'roles')

 const Discord = require("discord.js"); const { Client, Intents } = require('discord.js'); const bot = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGE_TYPING", "GUILD_MEMBERS", "GUILD_PRESENCES"] }); const config = require('./config.json'); const prefix = "g!" bot.on("ready", () => { console.log(`${bot.user.tag} bot is online`); }); bot.on("messageCreate", message => { if(message.content === prefix + "help") { if (!message.guild.cache.roles.find(role => role.id === '873595824469344256')) return; let helpembed = new Discord.MessageEmbed() .setColor('#0099ff') .setTitle('Help Guide') .setAuthor('Request : ' + `${message.author.username}`) .addFields( { name: 'Ban Usage', value: `${prefix}ban **id** | **reason** | **time** \n**__Exemple__** : ${prefix}ban id ALT-F4+Troll (without espace) 32H`}, { name: 'Warn Usage', value: `${prefix}warn **id** | **reason** | **time** \n**__Exemple__** : ${prefix}warn id Bunny-Hope (without espace) warn-1/2/3`}, ) .setFooter('© ©'); message.reply({ embeds: [helpembed] }); }; });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cambia tu

 if (!message.guild.cache.roles.find(role => role.id === '873595824469344256')) return;

a:

 if (!message.member.roles.cache.has("873595824469344256")) return`
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!