node.js 如何设置机器人的状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49286640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set bot's status
提问by Modular
So I'm trying to make my bot's streaming to be with depression but I've tried multiple things and they don't work.
I've tried these methods:
所以我试图让我的机器人流变得抑郁,但我尝试了多种方法,但它们不起作用。
我试过这些方法:
client.user.setPresence({ game: { name: 'with depression' }, status: 'online' });
bot.user.setGame('with depression', 'https://www.twitch.tv/monstercat');
None of these seem to be working the way they should. Any help is appreciated.
这些似乎都没有按应有的方式工作。任何帮助表示赞赏。
回答by koubi
Simple way to initiate the message on startup:
在启动时启动消息的简单方法:
bot.on('ready', () => {
bot.user.setStatus('available')
bot.user.setPresence({
game: {
name: 'with depression',
type: "STREAMING",
url: "https://www.twitch.tv/monstercat"
}
});
});
You can also just declare it elsewhere after startup, to change the message as needed:
您也可以在启动后在其他地方声明它,根据需要更改消息:
bot.user.setPresence({ game: { name: 'with depression', type: "streaming", url: "https://www.twitch.tv/monstercat"}});
回答by Monacraft
.setGameis discontinued. Use:
.setGame已停产。用:
client.user.setActivity("Game");
To set a playing game status.
设置玩游戏状态。
As an addition, if you were using an earlier version of discord.js, try this:
另外,如果您使用的是早期版本的 discord.js,请尝试以下操作:
client.user.setGame("Game");
In newer versions of discord.js, this is deprecated.
在较新版本的 discord.js 中,这已被弃用。
回答by Federico Grandi
Use this:
用这个:
client.user.setActivity("with depression", {
type: "STREAMING",
url: "https://www.twitch.tv/monstercat"
});
回答by Federico Grandi
client.user.setStatus('dnd', 'Made by KwinkyWolf')
And change 'dnd' to whatever status you want it to have. And then the next field 'Made by KwinkyWolf' is where you change the game. Hope this helped :)
并将“dnd”更改为您希望它具有的任何状态。然后下一个字段“由 KwinkyWolf 制造”是您改变游戏规则的地方。希望这有帮助:)
List of status':
状态列表':
- online
- idle
- dnd
- invisible
- 在线的
- 闲置的
- 天地
- 无形的
Not sure if they're still the same, or if there's more but hope that helped too :)
不确定它们是否仍然相同,或者是否还有更多,但希望也有帮助:)
回答by Will
setGamehas been discontinued. You must use client.user.setActivity.
setGame已停产。您必须使用client.user.setActivity.
Don't forget, if you are setting a streaming status, you MUSTspecify a Twitch URL
不要忘记,如果您要设置流媒体状态,则必须指定 Twitch URL
An example is here:
一个例子在这里:
client.user.setActivity("with depression", {
type: "STREAMING",
url: "https://www.twitch.tv/example-url"
});

