我想更改Discord机器人的状态。我尝试了以下方法,但是没有用。
const { Client, MessageAttachment } = require('discord.js');
const client = new Client();
client.once('ready', () => {
console.log('Status:Ready');
client.user.setPresence({
game: {
name: 'to radio',
type: 'LISTENING',
},
status: 'online',
});
});
答案 0 :(得分:2)
您可以使用此行
client.user.setActivity('your status', {
type: 'a type like STREAMING',
url: 'url of streaming',
});
答案 1 :(得分:1)
您可以使用client.user.setActivity
。此方法的第一个参数是您想要的活动名称。
在第二个参数中,您可以指定状态下想要的活动类型(WATCHING
,PLAYING
,STREAMING
和{{1} })。例如:
LISTENING
答案 2 :(得分:1)
´´´
client.once('ready', () => {
client.user.setActivity('something',{type: 'PLAYING'});
});
´´´
这可能是最简单的方法了,存在的类型可以是播放、观看和流媒体,但您可以在最后两个添加一个网址。
答案 3 :(得分:0)
const things = [{
"created": "2020-08-21T09:17:42.009Z",
"modified": "2020-08-21T09:17:42.009Z"
},
{
"created": "2020-08-05T21:06:50.643Z",
"modified": "2020-08-11T16:05:29.416Z"
},
{
"created": "2020-07-21T12:06:14.052Z",
"modified": "2020-07-22T13:27:45.336Z"
}, {
"created": "2020-04-17T13:07:48.751Z",
"modified": "2020-07-22T13:28:10.370Z"
},
{
"created": "2020-08-21T09:58:08.385Z",
"modified": "2020-08-21T09:58:08.386Z"
}, {
"created": "2020-08-21T09:31:29.988Z",
"modified": "2020-08-21T09:31:29.988Z"
}, {
"created": "2020-08-21T08:42:01.524Z",
"modified": "2020-08-21T08:42:01.524Z"
}, {
"created": "2020-08-20T09:30:23.717Z",
"modified": "2020-08-20T09:30:23.718Z"
}, {
"created": "2020-08-20T09:28:59.100Z",
"modified": "2020-08-20T09:28:59.101Z"
}, {
"created": "2020-08-20T09:28:19.055Z",
"modified": "2020-08-20T09:28:19.056Z"
}, {
"created": "2020-08-19T14:39:46.071Z",
"modified": "2020-08-19T14:39:46.072Z"
}, {
"created": "2020-08-06T14:16:38.611Z",
"modified": "2020-08-07T08:11:46.439Z"
}
]
const convertArr = things.map(function(item){
return {
"created": convertDate(item.created),
}
})
function convertDate(val){
var dateObj = new Date(val);
var month = dateObj.getUTCMonth() + 1; //months from 1-12
var day = dateObj.getUTCDate();
var year = dateObj.getUTCFullYear();
return year + "-" + month + "-" + day;
}
var result = convertArr.reduce((unique, o) => {
if(!unique.some(obj => obj.created === o.created && obj.modified === o.modified)) {
unique.push(o);
}
return unique;
},[]);
console.log(result)
可以进行流式观看