• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

126
Views
Set a discord bot's presence with json config variables

I'm trying to create a typescript discord bot that can set its presence appearance based on the bot's config variables from the config.json file.

index.ts:


client.on('ready', async () => {
   client.user?.setPresence({
      activities: [{ 
         name: `${config.activity}`,
         type: `${config.type}`
      }],
   status: `${config.status}`
   });
});

config.json:

{
    "status": "online",
    "type": "LISTENING",
    "activity": "for !help",

    "prefix": "!",
    "version": "1.0",
}

I get an error saying "Type 'string' is not assignable to type 'PresenceStatusData | undefined'.ts(2322) in the type and status part. The name part doesn't seem to be affected by this error. Before anybody asks, I have checked if the json configurations works properly. It parses the data as it should (not sure if parse is the correct word here, please correct me if this is a mistake).

I'm also using Discord.js version 13 if that helps.

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error