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

180
Views
handlePromiseRejectionWarning: TypeError: No se puede leer la propiedad 'agregar' de indefinido (Discord Bot)

He estado lidiando con un problema con mi captcha de Discord bot. El captcha funciona muy bien pero a la hora de agregar un rol si verificaron me da una bofetada con

handlePromiseRejectionWarning: TypeError: no se puede leer la propiedad 'agregar' de indefinido

Este es mi código:

 const Discord = require('discord.js-12'); const client = new Discord.Client(); const prefix = 'ri-'; const Captcha = require("@haileybot/captcha-generator"); client.once('ready', () => { console.log('Ready!'); }); let captcha = new Captcha(); console.log(captcha.value); const path = require("path"), fs = require("fs") client.on('message', async message => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (command === 'verification') { let captcha = new Captcha(); message.channel.send( "**Enter the text shown in the image below:**", new Discord.MessageAttachment(captcha.JPEGStream, "captcha.jpeg") ); let collector = message.channel.createMessageCollector(m => m.author.id === message.author.id); collector.on("collect", m => { if (m.content.toUpperCase() === captcha.value){ message.channel.send("Verified Successfully!"); let role = message.guild.roles.cache.find(r => r.id === "Verified"); message.author.roles.add(role); }else{ message.channel.send("Failed Verification!");} collector.stop(); }); } }); client.login('you don't need this.');

¡Cualquier ayuda es apreciada! ^^

Error:

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

0

Veo dos problemas en tu código.

  1. message.author se refiere a un usuario, que no tiene roles. Usa mensaje.miembro en su lugar

  2. Reemplace r.id con r.name, id no es una cadena.

Qué tengas un lindo día :)

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!