Skip to content

Commit

Permalink
Support for multiple presence messages #363
Browse files Browse the repository at this point in the history
  • Loading branch information
saiteja-madha committed Nov 5, 2024
1 parent 4ef5fd2 commit 26bd3f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ module.exports = {
ENABLED: false, // Whether or not the bot should update its status
STATUS: "online", // The bot's status [online, idle, dnd, invisible]
TYPE: "WATCHING", // Status type for the bot [ CUSTOM | PLAYING | LISTENING | WATCHING | COMPETING ]
MESSAGE: "{members} members in {servers} servers", // Your bot status message (note: in custom status type you won't have "Playing", "Listening", "Competing" prefix)
// Your bot status message (note: in custom status type you won't have "Playing", "Listening", "Competing" prefix)
MESSAGE: ["{members} members in {servers} servers"],
},

STATS: {
Expand Down
9 changes: 8 additions & 1 deletion src/handlers/presence.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const { ActivityType } = require("discord.js");

let messageIndex = 0;

/**
* @param {import('@src/structures').BotClient} client
*/
function updatePresence(client) {
let message = client.config.PRESENCE.MESSAGE;
let messages = client.config.PRESENCE.MESSAGE;
let message = Array.isArray(messages) ? messages[messageIndex] : messages;

if (message.includes("{servers}")) {
message = message.replaceAll("{servers}", client.guilds.cache.size);
Expand Down Expand Up @@ -56,6 +59,10 @@ function updatePresence(client) {
],
});
}

if (Array.isArray(messages)) {
messageIndex = (messageIndex + 1) % messages.length;
}
}

module.exports = function handlePresence(client) {
Expand Down

0 comments on commit 26bd3f8

Please sign in to comment.