我需要设置bot自定义状态。我试过这个代码:
client.on("ready", () =>{
console.log(`Logged in as ${client.user.tag}!`);
client.user.setPresence({
status: "online", //You can show online, idle....
game: {
name: "Using !help", //The message shown
type: "STREAMING" //PLAYING: WATCHING: LISTENING: STREAMING:
}
});
});
这个:
client.user.setActivity('discord.js', { type: 'WATCHING' });
这个:
client.user.setStatus('available');
client.user.setActivity(`Using !help`, { //msg shown
type: "STREAMING",
url: "" //optional
});
此错误显示在控制台中:
错误
现在我用了这个代码:
client.on("ready", () => {
client.user.setPresence({ activity: { name: "Using .help" }, status: "idle" })})
但这只会让人无所适从。我需要查看文本
但什么都不管用。有人能帮我吗?
尝试使用.setActivity
而不是.setPresence
,并使用以下格式:
client.once('ready', () => {
client.user.setStatus('available');
client.user.setActivity(`Using !help`, { //msg shown
type: "STREAMING",
url: "" //optional
});
});
这是我的状态代码(discord.js的v13.6(:
client.user.setActivity('+help', {type: "PLAYING"});
client.on代码如下:
client.on("ready", () => {
...
client.on('ready', (client) => {
client.user.setPresence({
status: "streaming"
});
});
.setPresence
设置您的微小存在,如dnd
、idle
、online
、offline
client.user.setActivity({
type: "STREAMING",
name: `over ${client.guilds.cache.size} servers.`,
url: "https://www.twitch.tv/your_twitch_streaming" //optional
});
.setActivity
设置您的活动,如playing
、watching
、etc
我认为,因为它不适用于您的代码文件,所以您没有在ready
之后添加client
您可以将它们同时放在ready event
中
client.on('ready', (client) => {
client.user.setPresence({
status: "streaming"
});
client.user.setActivity({
type: "STREAMING",
name: `over ${client.guilds.cache.size} servers.`,
url: "https://www.twitch.tv/your_twitch_streaming" //optional
});
});