Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
how to code a custom rich presence i tried doing one but gives error

const client = require("../index");

client.on("ready", () =>
    console.log(`${client.user.tag} is up and ready to go!`)
);
client.user.setPresence({
    status: "online",  // You can show online, idle... Do not disturb is dnd
    game: {
        name: "p!help • poketwo.net",  // The message shown
        type: "PLAYING" // PLAYING, WATCHING, LISTENING, STREAMING,
    }
});

that is the code for my rich presence but but i get a error as below

F:\akash\code\p22222\events\ready.js:6
client.user.setPresence({
            ^

TypeError: Cannot read properties of null (reading 'setPresence')
    at Object.<anonymous> (F:\akash\code\p22222\events\ready.js:6:13)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at F:\akash\code\p22222\handler\index.js:27:31
    at Array.map (<anonymous>)
    at module.exports (F:\akash\code\p22222\handler\index.js:27:16)

i dont know how to fix pls let me know what to do

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since I do not know where does the client come from, I can't give you a proper solution. I'll show you how I made mine work, though.

Client code:

const client = new Discord.Client({
  intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_WEBHOOKS", "DIRECT_MESSAGES", "GUILD_BANS", "GUILD_MEMBERS", "GUILD_VOICE_STATES"], //must use intents
  allowedMentions: ["users"] //stops people from using +say @everyone
});

On code:

//state: on
client.on("ready", () => {
  console.log(`Logged in as ${client.user.tag}!`);
  console.log("Connected to server(s):");
  client.guilds.cache.forEach((guild) => {
    console.log(" - " + guild.name + "\n    ID: " + guild.id +"\n");
    guild_number += 1;
  });
      console.log(`The number of guilds connected: ${guild_number}`);
      client.user.setActivity('World of Tanks', {type: "PLAYING"});
      client.user.setStatus('dnd');
    });

You should put all the client initalizers (defining, on, etc.) in your index.js.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!