RasmonT
RasmonT

Reputation: 403

How to change Discord bot Nickname?

I need my bot to be changing name depending on the price and movement of the price. I can't use username because bot will stop working because limit of changing usernames. I found out that Nicknames should be fine, however i can't make it work.

client.once('ready', () => {
  rp(requestOptions).then(response => {
    const answer = JSON.parse(response)
    console.log('API Call response:', answer["data"]["3501"]["quote"]);
    const percent_change_24h = answer["data"]["3501"]["quote"]["USD"]["percent_change_24h"];
    const price = answer["data"]["3501"]["quote"]["USD"]["price"]; 
  client.user.setNickname("Coin Price" + price.toFixed(5) + "$");
  client.user.setActivity(percent_change_24h + "%", { type: "PLAYING" });
  console.log('Ready!');
  }).catch((err) => {
  console.log('API Call error:', err.message);
  });
});

// Login to Discord with your client's token
client.login(config.token);

Error: API Call error: client.user.setNickname is not a function

What is the correct keyword to change bot nickname? (NOT USERNAME)

Upvotes: 1

Views: 339

Answers (1)

node_modules
node_modules

Reputation: 4925

To change the bot's nickname in every server it's in, you could loop through all guilds in the onReady event. For example:

client.once("ready", () => {

    client.guilds.cache.forEach(guild => {
        guild.me.setNickname("New Nickname");
    });
});

I'd be careful changing the nickname rapidly as it may result in temporary rate limits.

Upvotes: 2

Related Questions