Skip to content

Commit ba4c01c

Browse files
committed
Remove statistics command, remove command usage data
1 parent 15647f3 commit ba4c01c

File tree

6 files changed

+21
-95
lines changed

6 files changed

+21
-95
lines changed

src/actions/loadCommands.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ function isValidCommand(obj: unknown) {
99
&& "run" in obj
1010
&& typeof obj.run === "function"
1111
&& "data" in obj
12-
&& typeof obj.data === "object"
13-
&& "uses" in obj
14-
&& typeof obj.uses === "number";
12+
&& typeof obj.data === "object";
1513
}
1614

1715
export async function loadCommands(client: Client) {

src/commands/chatInput/ping.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1+
import { memoryUsage } from "node:process";
12
import { Command } from "#structures";
3+
import { formatTime } from "#util";
4+
5+
function formatBytes(bytes: number) {
6+
if (!bytes) return "0 Bytes";
7+
8+
const sizes = ["Bytes", "KB", "MB", "GB"];
9+
const i = Math.floor(Math.log(bytes) / Math.log(1_000));
10+
11+
return (bytes / Math.pow(1_000, i)).toFixed(1) + " " + sizes[i];
12+
}
213

314
export default new Command<"chatInput">({
415
async run(interaction) {
5-
const msg = await interaction.reply({ content: "Pinging...", fetchReply: true });
16+
const msg = await interaction.deferReply({ fetchReply: true });
17+
const { heapUsed, heapTotal, rss } = memoryUsage();
618

7-
await interaction.editReply([
8-
`Websocket: \`${interaction.client.ws.ping}\`ms`,
9-
`Round-trip: \`${msg.createdTimestamp - interaction.createdTimestamp}\`ms`
10-
].join("\n"));
19+
await interaction.editReply(
20+
`Websocket: \`${interaction.client.ws.ping}\`ms\n` +
21+
`Round-trip: \`${msg.createdTimestamp - interaction.createdTimestamp}\`ms\n` +
22+
`-# Memory: ${formatBytes(heapUsed)} **|** ${formatBytes(heapTotal)} **|** ${formatBytes(rss)}\n` +
23+
`-# Uptime: ${formatTime(interaction.client.uptime, 2, { longNames: true })}`
24+
);
1125
},
1226
data: {
1327
name: "ping",

src/commands/chatInput/statistics.ts

-82
This file was deleted.

src/interactions/chatInputCommand.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export async function handleChatInputCommand(interaction: ChatInputCommandIntera
1919

2020
try {
2121
await command.run(interaction);
22-
command.uses++;
2322
} catch (err: any) {
2423
await interaction.client.errorLog(err);
2524

src/interactions/contextMenuCommand.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export async function handleContextMenuCommand(interaction: CombinedContextMenuC
1818

1919
try {
2020
await command.run(interaction);
21-
command.uses++;
2221
} catch (err: any) {
2322
await interaction.client.errorLog(err);
2423

src/structures/command.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ export class Command<
3333
public run: (interaction: TInteraction) => Promise<any>;
3434
/** The data for this command */
3535
public readonly data: TData;
36-
/** The amount of times this command has been used */
37-
public uses = 0;
3836

39-
public constructor(commandData: Omit<Command<TCommand, TData, TInteraction, TAutocomplete>, "uses">) {
37+
public constructor(commandData: Command<TCommand, TData, TInteraction, TAutocomplete>) {
4038
this.autocomplete = commandData.autocomplete;
4139
this.run = commandData.run;
4240
this.data = commandData.data;

0 commit comments

Comments
 (0)