[英]How to change the status of discord bot node.js
我想将我的 discord 机器人的统计信息从 online 更改为idle
或dnd
。
这是我迄今为止尝试过的但没有奏效的方法:
client.on("ready", () => {
client.user.setStatus('dnd'),
client.user.setActivity('CrashGaming', { type: "WATCHING"}).catch(console.error)
});
您正在使用逗号,请删除逗号。 希望它会工作
client.on("ready", () => {
client.user.setStatus('dnd') // remove comma from here
client.user.setActivity('CrashGaming', { type: "WATCHING"}).catch(console.error)
});
让我知道它是否有效。
如果您使用的是 discord.js v14,则需要使用ActivityType
枚举或数字。
您可以从discord.js
导入它:
const {
ActivityType,
Client,
GatewayIntentBits,
} = require('discord.js');
并像这样使用它:
client.on('ready', () => {
client.user.setStatus('dnd');
client.user.setActivity('CrashGaming', { type: ActivityType.Watching });
});
您可以使用的ActivityType
列表:
v13 | v14 | v14 值 |
---|---|---|
"PLAYING" |
ActivityType.Playing |
0 |
"STREAMING" |
ActivityType.Streaming |
1 |
"LISTENING" |
ActivityType.Listening |
2 |
"WATCHING" |
ActivityType.Watching |
3 |
"COMPETING" |
ActivityType.Competing |
5 |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.