简体   繁体   English

discord.js v14 中的 setPresence 活动类型只能设置为“正在播放”

[英]setPresence activity type in discord.js v14 can only be set to "PLAYING"

When I try to set the status of the bot, I do not know the type, basically, there are 4 ways: PLAYING , WATCHING , LISTENING , and STREAMING .当我尝试设置机器人的状态时,我不知道类型,基本上有 4 种方式: PLAYINGWATCHINGLISTENINGSTREAMING But I can't set anything else, I can only use the default PLAYING .但是我不能设置其他任何东西,我只能使用默认的PLAYING

Am I inattentive or can't really be like that in the newer update?在较新的更新中,我是不专心还是真的不能那样?

client.user.setPresence({ activities: [{ name: `discord.js v14`, type: `WATCHING` }], status: 'dnd' })

In v14, you will need to use the ActivityType enums or numbers.在 v14 中,您将需要使用ActivityType枚举或数字。

You can import it from discord.js :您可以从discord.js导入它:

const { Client, GatewayIntentBits, ActivityType } = require('discord.js');

And use it like this:并像这样使用它:

client.user.setPresence({
  activities: [{ name: `discord.js v14`, type: ActivityType.Watching }],
  status: 'dnd',
});

List of ActivityType s: ActivityType列表:

v13 v13 v14 v14 v14 value v14 值
"COMPETING" ActivityType.Competing 5
"LISTENING" ActivityType.Listening 2
"PLAYING" ActivityType.Playing 0
"STREAMING" ActivityType.Streaming 1
"WATCHING" ActivityType.Watching 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM