Skip to content

Commit

Permalink
Merge pull request #13 from Bikoil/Magicord-RollRelease
Browse files Browse the repository at this point in the history
New command, fixed ralsay command
  • Loading branch information
Bikoil authored Aug 26, 2024
2 parents 8c7367c + 1c65343 commit 8be5c1a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions commands/fetch/serverstats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { CommandInteraction, Guild, PermissionsBitField } from "discord.js";
import { Discord, Slash } from "discordx";

@Discord()
export class ServerStats {
@Slash({
name: "serverstats",
description: "Gathers and displays server statistics.",
})
async serverStats(interaction: CommandInteraction): Promise<void> {
const guild = interaction.guild as Guild;

if (!guild) {
await interaction.reply("This command can only be used in a server.");
return;
}

// Fetch server members and channels
const members = await guild.members.fetch();
const channels = await guild.channels.fetch();
const roles = await guild.roles.fetch();

// Calculate the statistics
const totalMembers = members.size;
const totalBots = members.filter((member) => member.user.bot).size;
const totalAdminPerms = members.filter((member) =>
member.permissions.has(PermissionsBitField.Flags.Administrator)
).size;
const totalMods = members.filter((member) =>
member.permissions.has(PermissionsBitField.Flags.ModerateMembers)
).size;
const totalBoosts = guild.premiumSubscriptionCount ?? 0;
const totalChannels = channels.size;


// Respond with the collected stats
await interaction.deferReply();
await interaction.editReply(
`**Server Statistics:**\n` +
`> Total Members: ${totalMembers}\n` +
`> Total Bots: ${totalBots}\n` +
`> Total Admins: ${totalAdminPerms}\n` +
`> Total Mods: ${totalMods}\n` +
`> Total Boosts: ${totalBoosts}\n` +
`> Total Channels: ${totalChannels}`
);
}
}

4 changes: 3 additions & 1 deletion commands/fun/ralsay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export class RalsayCommand {
interaction: CommandInteraction
): Promise<void> {
const asciiArt = generateRalsay(text);
await interaction.reply("```" + asciiArt + "```");

await interaction.deferReply();
await interaction.editReply("```" + asciiArt + "```");
}
}

0 comments on commit 8be5c1a

Please sign in to comment.