discord.js activity code example

Example 1: discord.js bot activity

bot.user.setActivity('some activity', { type: 'WATCHING' }) // STREAMING, WATCHING, CUSTOM_STATUS, PLAYING, COMPETING
.then(presence => console.log(`Activity set to ${presence.activities[0].name}`))
  .catch(console.error);

Example 2: discord bot playing game

client.user.setActivity("what the bot is playing");

Example 3: discord js channel send

const user = <client>.users.cache.get('<id>');
user.send('<content>');

Example 4: discord js channel send

const channel = <client>.channels.cache.get('<id>');
channel.send('<content>');

Tags:

Misc Example