最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord JS (Bot Presence) - Stack Overflow

programmeradmin7浏览0评论

So, in Discord, users can have a custom status, however, when I try to set my bot up with one nothing happens...Even though CUSTOM_STATUS is available

I have bot.user.setPresence({ activity: { name: "Testing", type: "CUSTOM_STATUS" }, status: "online" }); inside of the ready event. I was just wondering why this doesn't work and if there is a work around

So, in Discord, users can have a custom status, however, when I try to set my bot up with one nothing happens...Even though CUSTOM_STATUS is available

I have bot.user.setPresence({ activity: { name: "Testing", type: "CUSTOM_STATUS" }, status: "online" }); inside of the ready event. I was just wondering why this doesn't work and if there is a work around

Share Improve this question edited May 12, 2020 at 18:08 Syntle 5,1743 gold badges15 silver badges34 bronze badges asked May 12, 2020 at 17:59 AppleMan101AppleMan101 311 gold badge1 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

According to the docs.

Bots cannot set a CUSTOM_STATUS, it is only for custom statuses received from users

The valid types you could choose from are:

  • PLAYING
  • STREAMING
  • LISTENING
  • WATCHING

Try client.user.setActivity(Your Status) I am using this and its working fine If you are using v12 then i cant help you

You should make sure that your setPresence mand is in your ready event. For example, this is my ready mand:

const {PREFIX} = require('../config.json');
const { Message } = require('discord.js');
const message = require('./message.js');

//must update when new module.exports event happens
const leaveEvent = require('../util/guildMemberRemove');
const invitecounterEvent = require('../util/guildMemberAddinvitecounter');
const modmailEvent = require('../util/modmail');

module.exports = (client, message) => {

    //must update when new module.exports event happens
    leaveEvent(client);
    invitecounterEvent(client);
    modmailEvent(client);

    console.log(' ');
    console.log(`Hi, ${client.user.username} is now online! My Prefix is ${PREFIX}`);
    console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`); 
    //client.user.setActivity(`Serving ${client.guilds.size} servers`); (big servers only)
    client.user.setActivity('U', { type: 'WATCHING' }) //PLAYING, STREAMING, LISTENING, WATCHING, CUSTOM_STATUS
        .then(presence => console.log(`Activity set to: WATCHING ${presence.activities[0].name}`))
        .catch(console.error);


    console.log(`Ready as ${client.user.tag} to serve in ${client.channels.cache.size} channels on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users.`);

    client.generateInvite(['SEND_MESSAGES', 'MANAGE_GUILD', 'MENTION_EVERYONE', 'ADMINISTRATOR',])
    .then(link => {
        console.log(`Generated bot invite link: ${link}`);
        // eslint-disable-next-line no-undef
        inviteLink = link;
    });

};

The part that should help you is client.user.setActivity('U', { type: 'WATCHING' }) The different types you can do are PLAYING, STREAMING, LISTENING, and WATCHING.

发布评论

评论列表(0)

  1. 暂无评论