From 66709c43e2a5f12318fbdc856b0da5a8bdf64fe2 Mon Sep 17 00:00:00 2001 From: hirzidevs Date: Sun, 25 Aug 2024 21:34:33 +0700 Subject: [PATCH] Better Presence Settings --- config.yml | 1 + index.js | 50 ++++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/config.yml b/config.yml index b3e07dd..49ad34d 100644 --- a/config.yml +++ b/config.yml @@ -4,6 +4,7 @@ # Bot Configuration token: "Put Bot Token Here" presence: + enable: true text: "Hosting Panel" type: "watching" # can be 'watching', 'playing', 'listening', or 'competing'. 'streaming' is not working for now status: "online" # can be 'online', 'idle', 'dnd', or 'invisible' diff --git a/index.js b/index.js index dc3b354..830fb30 100644 --- a/index.js +++ b/index.js @@ -51,33 +51,35 @@ async function startGetStatus() { client.once("ready", () => { console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.greenBright(`${client.user.tag} is online!`)); - if (config.presence.text && config.presence.type) { - switch (config.presence.type.toLowerCase()) { - case "playing": - config.presence.type = ActivityType.Playing; - break; - case "listening": - config.presence.type = ActivityType.Listening; - break; - case "competing": - config.presence.type = ActivityType.Competing; - break; - default: - config.presence.type = ActivityType.Watching; + if (config.presence.enable) { + if (config.presence.text && config.presence.type) { + switch (config.presence.type.toLowerCase()) { + case "playing": + config.presence.type = ActivityType.Playing; + break; + case "listening": + config.presence.type = ActivityType.Listening; + break; + case "competing": + config.presence.type = ActivityType.Competing; + break; + default: + config.presence.type = ActivityType.Watching; + } + + client.user.setActivity(config.presence.text, { + type: config.presence.type, + }); } - client.user.setActivity(config.presence.text, { - type: config.presence.type, - }); - } + if (config.presence.status) { + if (!["idle", "online", "dnd", "invisible"].includes( + config.presence.status.toLowerCase() + )) + config.presence.status = "online"; - if (config.presence.status) { - if (!["idle", "online", "dnd", "invisible"].includes( - config.presence.status.toLowerCase() - )) - config.presence.status = "online"; - - client.user.setStatus(config.presence.status); + client.user.setStatus(config.presence.status); + } } startGetStatus();