✨ Add ping module to utility command #338
This commit is contained in:
parent
0847ae205d
commit
7d02cf9b8d
3 changed files with 57 additions and 1 deletions
|
@ -10,7 +10,8 @@ export const builder = new SlashCommandBuilder()
|
||||||
|
|
||||||
.addSubcommand(modules.about.builder)
|
.addSubcommand(modules.about.builder)
|
||||||
.addSubcommand(modules.stats.builder)
|
.addSubcommand(modules.stats.builder)
|
||||||
.addSubcommand(modules.avatar.builder);
|
.addSubcommand(modules.avatar.builder)
|
||||||
|
.addSubcommand(modules.ping.builder);
|
||||||
|
|
||||||
export const execute = async (interaction: CommandInteraction) => {
|
export const execute = async (interaction: CommandInteraction) => {
|
||||||
switch (interaction.options.getSubcommand()) {
|
switch (interaction.options.getSubcommand()) {
|
||||||
|
@ -20,6 +21,8 @@ export const execute = async (interaction: CommandInteraction) => {
|
||||||
return modules.stats.execute(interaction);
|
return modules.stats.execute(interaction);
|
||||||
case "avatar":
|
case "avatar":
|
||||||
return modules.avatar.execute(interaction);
|
return modules.avatar.execute(interaction);
|
||||||
|
case "ping":
|
||||||
|
return modules.ping.execute(interaction);
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unknown subcommand: ${interaction.options.getSubcommand()}`
|
`Unknown subcommand: ${interaction.options.getSubcommand()}`
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import avatar from "./avatar";
|
import avatar from "./avatar";
|
||||||
import about from "./about";
|
import about from "./about";
|
||||||
import stats from "./stats";
|
import stats from "./stats";
|
||||||
|
import ping from "./ping";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
avatar,
|
avatar,
|
||||||
about,
|
about,
|
||||||
stats,
|
stats,
|
||||||
|
ping,
|
||||||
};
|
};
|
||||||
|
|
51
src/plugins/commands/utility/modules/ping/index.ts
Normal file
51
src/plugins/commands/utility/modules/ping/index.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Dependencies
|
||||||
|
import {
|
||||||
|
CommandInteraction,
|
||||||
|
MessageActionRow,
|
||||||
|
MessageButton,
|
||||||
|
} from "discord.js";
|
||||||
|
|
||||||
|
// Configurations
|
||||||
|
import getEmbedConfig from "../../../../../helpers/getEmbedConfig";
|
||||||
|
|
||||||
|
import { hosterName, hosterUrl } from "../../../../../config/other";
|
||||||
|
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
|
|
||||||
|
// Function
|
||||||
|
export default {
|
||||||
|
metadata: { guildOnly: false, ephemeral: false },
|
||||||
|
|
||||||
|
builder: (command: SlashCommandSubcommandBuilder) => {
|
||||||
|
return command.setName("ping").setDescription("Ping this bot");
|
||||||
|
},
|
||||||
|
execute: async (interaction: CommandInteraction) => {
|
||||||
|
const { successColor, footerText, footerIcon } = await getEmbedConfig(
|
||||||
|
interaction.guild
|
||||||
|
);
|
||||||
|
|
||||||
|
const interactionEmbed = {
|
||||||
|
title: "[:tools:] Ping",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "📦 Deliver Latency",
|
||||||
|
value: `${Math.abs(Date.now() - interaction.createdTimestamp)} ms`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "🤖 API Latency",
|
||||||
|
value: `${Math.round(interaction.client.ws.ping)} ms`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
color: successColor,
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: {
|
||||||
|
iconURL: footerIcon,
|
||||||
|
text: footerText,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await interaction.editReply({
|
||||||
|
embeds: [interactionEmbed],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue