2

I have exhausted a lot of options and attempts at this for the last week or two. I have everything setup right but I am struggling to target the bot's Nickname.

Desired Outcome: I want to update the Discord Bot Nickname (not the username) ever X seconds (in this case 10) to sync with the Binance ticker price.

Issue: targeting the Nickname of the bot properly without issuing a command. I am getting an error that 'me' is undefined

Code:

client.on('ready', () => {
 setInterval(() => {
   client.guilds.cache.find(guild => guild.id === 'GUILD_ID').me.setNickname("$" + '${ticker.DOGEUSDT}');
 }, 10000);
})
4

1 回答 1

1
client.on('ready', () => {
 setInterval(() => {
   client.guilds.cache.get("652865271089856525").members.cache.find(member => member.id === client.user.id).setNickname("$" + `${value}`);
 }, 10000);
})

对我来说,这绝对有效。npm i discord.js@latest通过在终端中输入,确保您使用的是 discord.js v12 。

但我给你一点提示:如果你想将变量放在字符串中,你必须使用 ` 而不是 ' 或 "。

于 2021-01-10T23:27:38.333 回答