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

87
Views
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 answers
Answer question

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 Report

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 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!