Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the status of a Discord.js bot?

I want to change the status of my Discord bot. I tried the one below, but it didn't work.

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',
 });
});
like image 383
BaconSam Avatar asked Oct 24 '25 11:10

BaconSam


1 Answers

You can use client.user.setActivity. The first parameter in this method is what you want the name of your activity to be.

In the second parameter, you can specify what activity type you want in your status (WATCHING, PLAYING, STREAMING, and LISTENING). For example:

client.on("ready", () => {
  // Playing in my support server
  client.user.setActivity("in my support server", { type: "PLAYING" });

  // Streaming <name of stream>
  client.user.setActivity({ type: "STREAMING", url: "<twich url>" });

  // Watching over xx servers
  client.user.setActivity(`over ${client.guilds.cache.size} servers`, {
    type: "WATCHING",
  });

  // Listening to xxx users
  client.user.setActivity(
    `to ${client.guilds.cache
      .map((guild) => guild.memberCount)
      .reduce((p, c) => p + c)} users`,
    { type: "LISTENING" }
  );
});
like image 50
Lioness100 Avatar answered Oct 26 '25 01:10

Lioness100



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!