Dough Git

clove/inviteTracker

src/commands/info.ts

back to src/commands

/* src/commands/info.ts */

import {
  type ChatInputCommandInteraction,
  MessageFlags,
  SlashCommandBuilder,
} from "discord.js";

const sourceUrl = "https://git.doughmination.gay/clove/inviteTracker";

export const infoCommand = new SlashCommandBuilder()
  .setName("info")
  .setDescription("Show the source, Discord latency, and tracked invite count");

export async function replyWithInfo(
  interaction: ChatInputCommandInteraction,
  trackedInvites: number,
) {
  const ping = interaction.client.ws.ping;
  const latency = Number.isFinite(ping) && ping >= 0
    ? `${Math.round(ping)} ms`
    : "Unavailable";

  await interaction.reply({
    content: [
      `**Source** · <${sourceUrl}>`,
      `**Discord gateway latency** · ${latency}`,
      `**Tracked invites (including used)** · ${trackedInvites}`,
    ].join("\n"),
    flags: MessageFlags.Ephemeral,
  });
}