📈 add total users to default status

This commit is contained in:
Axel Olausson Holtenäs 2022-05-29 21:48:12 +02:00
parent 825ff53878
commit 5bcfafd0ed
No known key found for this signature in database
GPG key ID: 7BF6826B76382CBA
3 changed files with 15 additions and 12 deletions

View file

@ -13,15 +13,9 @@ export const options: IEventOptions = {
}; };
export const execute = async (client: Client) => { export const execute = async (client: Client) => {
logger.info("Ready!"); logger.info("Discord's API client is ready!");
await updatePresence(client); await updatePresence(client);
await devMode(client); await devMode(client);
await deployCommands(client); await deployCommands(client);
client.guilds?.cache.forEach((guild) => {
logger.silly(
`${client.user?.tag} (${client.user?.id}) is in guild: ${guild.name} (${guild.id}) with member count of ${guild.memberCount}`
);
});
}; };

View file

@ -2,7 +2,7 @@ import { token, clientId } from "../config/discord";
import { devMode, guildId } from "../config/other"; import { devMode, guildId } from "../config/other";
import logger from "../logger"; import logger from "../logger";
import { ApplicationCommandDataResolvable, Client } from "discord.js"; import { Client } from "discord.js";
import { REST } from "@discordjs/rest"; import { REST } from "@discordjs/rest";
import { Routes } from "discord-api-types/v9"; import { Routes } from "discord-api-types/v9";
import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10";

View file

@ -4,11 +4,20 @@ import logger from "../../logger";
// Function // Function
export default async (client: Client) => { export default async (client: Client) => {
const status = `${client?.guilds?.cache?.size} guilds.`; if (!client?.user) throw new Error("Client's user is undefined.");
client?.user?.setPresence({ const { guilds } = client;
activities: [{ type: "WATCHING", name: status }],
const memberCount = guilds.cache.reduce((a, g) => a + g.memberCount, 0);
const guildCount = guilds.cache.size;
const status = `${memberCount} users in ${guildCount} guilds.`;
client.user.setPresence({
activities: [{ type: "LISTENING", name: status }],
status: "online", status: "online",
}); });
logger?.debug(`Updated client presence to: ${status}`);
logger.info(`Client's presence is set to "${status}"`);
}; };