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

94
Views
¿Hay alguna forma de acceder a message.guild.name en un evento listo?

Estoy codificando un bot de utilidades y quiero que cambie su apodo en cada servidor a <server_name> Utilities automáticamente cuando ejecute mi bot.

Aquí está mi evento listo:

 bot.on('ready',async () => { console.log('|| MaRa Utilities, Console') console.log(` Logged in as "#${bot.user.discriminator}"`) console.log(`\nBot "#${bot.user.discriminator}" has been loaded successfully...\n`) console.log(`The Prefix Is: ${PREFIX}`) console.log(`Bot "#${bot.user.discriminator}" Is in ${bot.guilds.cache.size} guild/s\n`) console.log(`|| Logs/Errors:`) db.get("Prefix").then(value => {if(value != PREFIX){ console.log('A Dev has changed the "PREFIX" on startup.') db.set("Prefix", PREFIX); }}) db.get("BotAuthorID").then(value => {if(value != BotAuthorID){ console.log('A Dev has changed the "BotAuthorID" on startup.') db.set("BotAuthorID", BotAuthorID); }}) db.get("TOKEN").then(value => {if(value != TOKEN){ console.log('A Dev has changed the "TOKEN" on startup.') db.set("TOKEN", TOKEN); }}) bot.user.setActivity(`DM For Help!`) bot.user.setUsername(bot.Message.guild.name + ' Utilities') })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

¡Sí, solo tienes que usar bot.guilds.cache.get("GUILD_ID").name en lugar de message.guild.name ! Documentación

Para cambiar el apodo de su bot en el uso del servidor:

 bot.guilds.cache.get("GUILD_ID").me.setNickname(`${bot.guilds.cache.get("GUILD_ID").name} Utilities`)

Así que el código completo será:

 bot.guilds.cache.forEach(guild => { bot.guilds.cache.get(guild.id).me.setNickname(`${guild.name} Utilities`) })
about 4 years ago · Juan Pablo Isaza Report

0

Iterar a través de GuildManager#cache . Verifique si el cliente tiene permiso para cambiar su propio apodo (constante de cadena "CHANGE_NICKNAME") si tiene permiso, luego use Member#setNickname()

 bot.on('ready', async() => { bot.guilds.cache.forEach(guild => { const botMember = guild.me; if (botMember.permissions.has('CHANGE_NICKNAME')) { botMember .setNickname(`${guild.name} Utilities`) .catch(err => /* Handle Error */); } }); });
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!