【问题标题】:How to change Discord bot Nickname?如何更改 Discord 机器人昵称?
【发布时间】:2021-11-01 08:52:19
【问题描述】:

我需要我的机器人根据价格和价格变动来更改名称。我不能使用用户名,因为机器人会因为更改用户名的限制而停止工作。我发现昵称应该没问题,但是我不能让它工作。

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);

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

更改机器人昵称的正确关键字是什么? (不是用户名

【问题讨论】:

    标签: node.js api discord discord.js


    【解决方案1】:

    要在它所在的每个服务器中更改机器人的昵称,您可以在 onReady 事件中遍历所有公会。例如:

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

    我会小心快速更改昵称,因为它可能会导致临时速率限制。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-31
      • 2021-03-10
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 2021-05-14
      • 2017-08-04
      相关资源
      最近更新 更多