handle custom presence status

still not tested yet
This commit is contained in:
Amane Serenetia 2024-07-01 09:41:25 +07:00
parent 520395167f
commit 0590081849
2 changed files with 30 additions and 12 deletions

View File

@ -128,8 +128,8 @@ module.exports = {
PRESENCE: {
ENABLED: true, // Whether or not the bot should update its status
STATUS: "online", // The bot's status [online, idle, dnd, invisible]
TYPE: "LISTENING", // Status type for the bot [PLAYING | LISTENING | WATCHING | COMPETING]
MESSAGE: "/play with {members} members in {servers} servers", // Your bot status message
TYPE: "LISTENING", // Status type for the bot [ CUSTOM | PLAYING | LISTENING | WATCHING | COMPETING ]
MESSAGE: "/play with {members} members in {servers} servers", // Your bot status message (note: in custom status type you won't have "Playing", "Listening", "Competing" prefix)
},
STATS: {

View File

@ -11,7 +11,9 @@ function updatePresence(client) {
}
if (message.includes("{members}")) {
const members = client.guilds.cache.map((g) => g.memberCount).reduce((partial_sum, a) => partial_sum + a, 0);
const members = client.guilds.cache
.map((g) => g.memberCount)
.reduce((partial_sum, a) => partial_sum + a, 0);
message = message.replaceAll("{members}", members);
}
@ -28,18 +30,34 @@ function updatePresence(client) {
case "WATCHING":
return ActivityType.Watching;
case "CUSTOM":
return ActivityType.Custom;
}
};
client.user.setPresence({
status: client.config.PRESENCE.STATUS,
activities: [
{
name: message,
type: getType(client.config.PRESENCE.TYPE),
},
],
});
if(client.config.PRESENCE.TYPE === "CUSTOM") {
client.user.setPresence({
status: client.config.PRESENCE.STATUS,
activities: [
{
name: message,
state: message,
type: getType(client.config.PRESENCE.TYPE),
},
],
});
} else {
client.user.setPresence({
status: client.config.PRESENCE.STATUS,
activities: [
{
name: message,
type: getType(client.config.PRESENCE.TYPE),
},
],
});
}
}
module.exports = function handlePresence(client) {