Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

92
Vistas
Is there a way to access message.guild.name in a ready event?

I'm coding a utilities bot and I want it to change its nickname on every server to <server_name> Utilities automatically when I run my bot.

Heres my ready event:

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 Respuestas
Responde la pregunta

0

Yes, you just have to use bot.guilds.cache.get("GUILD_ID").name instead of message.guild.name! Documentation

To change your bot nickname on server use:

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

So full code will be:

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

0

Iterate through GuildManager#cache. Check if the client has permission to change it's own nickname (string constant "CHANGE_NICKNAME") if it does have the permission then 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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda