Home > Net >  setActivity will only set the activity type to "Playing". Discord.js v14
setActivity will only set the activity type to "Playing". Discord.js v14

Time:12-01

When trying to set the activity status of the bot I only manage to set have it say "Playing x".

Looking at the documentation of discord.js the correct usage should be:

client.user.setActivity('discord.js', { type: ActivityType.Watching });

But even when trying this usage I get the same result of it displaying "Playing discord.js".

This is my code currently:

const ActivityType = require('discord.js');

client.user.setActivity('/play', { type: ActivityType.Listening });

But I have also tried

client.user.setActivity({ name: '/play', type: ActivityType.Listening });

The client is being passed from my index file, I get no errors. Also tried the example from the answer here, also giving me the same result.

What am I missing here?

Edit. Full code is:

ready.js

const ActivityType = require('discord.js');

module.exports = {
  name: 'ready',
  once: true,
  execute(client) {
    client.user.setActivity({ name: '/play', type: ActivityType.Listening });
  },
};

index.js

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildVoiceStates,
  ],
});

CodePudding user response:

Try this. Discord.js: Cannot read property 'setActivity' of undefined

  • Related