I want to know how to set my activity status for my bot.
Like "Watching youtube.com"
Or "playing a game."
I've tried following the discord api document but it does not tell me how.
CodePudding user response:
May I ask what version of Discord.JS you are using?
v12:
client.user.setActivity("you", {type: "WATCHING"});
v14:
In v14, you will need to use ActivityType, make sure to add "ActivityType" before require("discord.js"); like this
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
then this is the code:
client.user.setPresence({ activities: [{ name: `discord.js v14`, type: ActivityType.Watching }], status: 'dnd', });
heres a list of the activity types:
ActivityType.Competing
ActivityType.Listening
ActivityType.Playing
ActivityType.Streaming
ActivityType.Watching
CodePudding user response:
To specify your activity type or set an activity type in discordjs version 14 you can do it by simply writing.
First you need to add const
{ Client, GatewayIntentBits, ActivityType, Guild } = require('discord.js');
And then you can set your activity type as the following:
client.user.setActivity('Message goes here', { type: ActivityType.Streaming});
There are 6 different types.
Playing | 0
Streaming | 1
Listening | 2
Watching | 3
Custom | 4
Competing | 5
For example if you would like to set your bots status to playing a game you would do it as following:
client.user.setActivity('game', { type: ActivityType.Playing});
https://discord-api-types.dev/api/discord-api-types-v10/enum/ActivityType