From 560ad899f8be73a59bfc0d1523a783a1084c5d04 Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 12 Jan 2025 19:40:20 +0100 Subject: [PATCH] Added types for subcommands --- src/commands/counting/ban.ts | 7 +++++-- src/commands/counting/unban.ts | 7 +++++-- src/commands/guild/info.ts | 7 ++++--- src/commands/guild/member.ts | 6 ++++-- src/commands/guild/top.ts | 7 ++++--- src/commands/music/leave.ts | 6 ++++-- src/commands/music/nowplaying.ts | 6 ++++-- src/commands/music/pause.ts | 6 ++++-- src/commands/music/play.ts | 7 +++++-- src/commands/music/queue.ts | 6 ++++-- src/commands/music/skip.ts | 6 ++++-- src/commands/music/unpause.ts | 6 ++++-- src/commands/music/volume.ts | 6 ++++-- src/commands/staff/beast.ts | 6 ++++-- src/commands/staff/help.ts | 8 +++++--- src/commands/staff/prune.ts | 7 +++++-- src/commands/staff/removeguildroles.ts | 8 +++++--- src/commands/staff/updateall.ts | 8 +++++--- src/typings/SubCommand.ts | 3 ++- 19 files changed, 81 insertions(+), 42 deletions(-) diff --git a/src/commands/counting/ban.ts b/src/commands/counting/ban.ts index 5b77695..081cf63 100644 --- a/src/commands/counting/ban.ts +++ b/src/commands/counting/ban.ts @@ -1,8 +1,9 @@ -import { ChatInputCommandInteraction, GuildMember, userMention } from "discord.js" +import { GuildMember, userMention } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" import { countingBanned } from "~/config/roles.js" +import { SubCommand } from "~/typings" -export default async function ban(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { const member = interaction.options.getMember("user")! as GuildMember if (member.roles.cache.has(countingBanned)) { @@ -31,3 +32,5 @@ export default async function ban(interaction: ChatInputCommandInteraction): Pro }) } } + +export default cmd diff --git a/src/commands/counting/unban.ts b/src/commands/counting/unban.ts index 0bdd667..4fed630 100644 --- a/src/commands/counting/unban.ts +++ b/src/commands/counting/unban.ts @@ -1,8 +1,9 @@ -import { ChatInputCommandInteraction, GuildMember, userMention } from "discord.js" +import { GuildMember, userMention } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" import { countingBanned } from "~/config/roles.js" +import { SubCommand } from "~/typings" -export default async function ban(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { const member = interaction.options.getMember("user")! as GuildMember if (!member.roles.cache.has(countingBanned)) { @@ -31,3 +32,5 @@ export default async function ban(interaction: ChatInputCommandInteraction): Pro }) } } + +export default cmd diff --git a/src/commands/guild/info.ts b/src/commands/guild/info.ts index 2e949f9..4308c48 100644 --- a/src/commands/guild/info.ts +++ b/src/commands/guild/info.ts @@ -1,10 +1,9 @@ -import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" -import { IGuildData } from "~/typings" +import { IGuildData, SubCommand } from "~/typings" import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js" import { getGuild, getIGN, getPlayer, getUUID, guildLevel } from "~/utils/Hypixel.js" -export default async function guildInfo(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const query = interaction.options.getString("query")! @@ -160,3 +159,5 @@ export default async function guildInfo(interaction: ChatInputCommandInteraction }] }) } + +export default cmd diff --git a/src/commands/guild/member.ts b/src/commands/guild/member.ts index 01c8ce5..1c382ef 100644 --- a/src/commands/guild/member.ts +++ b/src/commands/guild/member.ts @@ -1,9 +1,9 @@ -import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js" import { getGuild, getHeadURL, getPlayer, getUUID } from "~/utils/Hypixel.js" -export default async function guildMember(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const ign = interaction.options.getString("ign")! @@ -145,3 +145,5 @@ export default async function guildMember(interaction: ChatInputCommandInteracti }] }) } + +export default cmd diff --git a/src/commands/guild/top.ts b/src/commands/guild/top.ts index c35e62f..29c1c70 100644 --- a/src/commands/guild/top.ts +++ b/src/commands/guild/top.ts @@ -1,11 +1,10 @@ -import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" -import { IGuildData } from "~/typings" +import { IGuildData, SubCommand } from "~/typings" import { numberFormatter } from "~/utils/Functions/intlFormaters.js" import { getGuild, getIGN, getPlayer, getUUID } from "~/utils/Hypixel.js" import { redis } from "~/utils/Illegitimate.js" -export default async function guildTop(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const query = interaction.options.getString("query")! @@ -215,3 +214,5 @@ export default async function guildTop(interaction: ChatInputCommandInteraction) }] }) } + +export default cmd diff --git a/src/commands/music/leave.ts b/src/commands/music/leave.ts index 5b71043..b67dde6 100644 --- a/src/commands/music/leave.ts +++ b/src/commands/music/leave.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function leave(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { const player = useMainPlayer() const queue = player.queues.get(interaction.guildId!) if (!queue) { @@ -23,3 +23,5 @@ export default async function leave(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/nowplaying.ts b/src/commands/music/nowplaying.ts index 640d89b..5803a92 100644 --- a/src/commands/music/nowplaying.ts +++ b/src/commands/music/nowplaying.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function nowplaying(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const player = useMainPlayer() @@ -56,3 +56,5 @@ export default async function nowplaying(interaction: ChatInputCommandInteractio }] }) } + +export default cmd diff --git a/src/commands/music/pause.ts b/src/commands/music/pause.ts index 7ab88c4..cdcef02 100644 --- a/src/commands/music/pause.ts +++ b/src/commands/music/pause.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function pause(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const player = useMainPlayer() @@ -36,3 +36,5 @@ export default async function pause(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index 1394ea1..7245467 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -1,8 +1,9 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction, GuildMember } from "discord.js" +import { GuildMember } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function play(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const query = interaction.options.getString("query")! const channel = (interaction.member as GuildMember).voice.channel @@ -41,3 +42,5 @@ export default async function play(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/queue.ts b/src/commands/music/queue.ts index 53ebdff..3d44705 100644 --- a/src/commands/music/queue.ts +++ b/src/commands/music/queue.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function queue(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const player = useMainPlayer() const queue = player.queues.get(interaction.guildId!) @@ -37,3 +37,5 @@ export default async function queue(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/skip.ts b/src/commands/music/skip.ts index 1cec46f..f28785d 100644 --- a/src/commands/music/skip.ts +++ b/src/commands/music/skip.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function skip(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const amount = interaction.options.getNumber("amount") ?? 1 @@ -42,3 +42,5 @@ export default async function skip(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/unpause.ts b/src/commands/music/unpause.ts index 1fc34b1..9f64271 100644 --- a/src/commands/music/unpause.ts +++ b/src/commands/music/unpause.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function pause(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const player = useMainPlayer() @@ -36,3 +36,5 @@ export default async function pause(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/music/volume.ts b/src/commands/music/volume.ts index ca0e66e..b3bde44 100644 --- a/src/commands/music/volume.ts +++ b/src/commands/music/volume.ts @@ -1,8 +1,8 @@ import { useMainPlayer } from "discord-player" -import { ChatInputCommandInteraction } from "discord.js" import { embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" -export default async function volume(interaction: ChatInputCommandInteraction) { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const volume = interaction.options.getNumber("volume")! @@ -27,3 +27,5 @@ export default async function volume(interaction: ChatInputCommandInteraction) { }] }) } + +export default cmd diff --git a/src/commands/staff/beast.ts b/src/commands/staff/beast.ts index 4b83355..c435605 100644 --- a/src/commands/staff/beast.ts +++ b/src/commands/staff/beast.ts @@ -1,9 +1,9 @@ -import { ChatInputCommandInteraction } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" import { beastbwfkdr, beastbwstars, beastduelswins, beastswkdr, beastswstars, bwwins, duelswlr } from "~/config/reqs.js" +import { SubCommand } from "~/typings" import { bedwarsLevel, getGuild, getHeadURL, getPlayer, getUUID, hypixelLevel, skywarsLevel } from "~/utils/Hypixel.js" -export default async function beast(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const ign = interaction.options.getString("ign")! @@ -206,3 +206,5 @@ export default async function beast(interaction: ChatInputCommandInteraction): P }] }) } + +export default cmd diff --git a/src/commands/staff/help.ts b/src/commands/staff/help.ts index 51f8fae..139afa9 100644 --- a/src/commands/staff/help.ts +++ b/src/commands/staff/help.ts @@ -1,8 +1,8 @@ -import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChatInputCommandInteraction, ComponentType } from "discord.js" +import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" -import { ExtendedClient as Client } from "~/utils/Client.js" +import { SubCommmndClient } from "~/typings" -export default async function help(interaction: ChatInputCommandInteraction, client: Client): Promise { +const cmd: SubCommmndClient = async (interaction, client) => { await interaction.deferReply() type CommandList = { @@ -183,3 +183,5 @@ export default async function help(interaction: ChatInputCommandInteraction, cli }) }) } + +export default cmd diff --git a/src/commands/staff/prune.ts b/src/commands/staff/prune.ts index 2a5af2f..7d3e54f 100644 --- a/src/commands/staff/prune.ts +++ b/src/commands/staff/prune.ts @@ -1,8 +1,9 @@ -import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChatInputCommandInteraction, ComponentType } from "discord.js" +import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ComponentType } from "discord.js" import { devMessage, embedColor } from "~/config/options.js" +import { SubCommand } from "~/typings" import env from "~/utils/Env.js" -export default async function prune(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() if (interaction.user.id !== env.prod.dev) { @@ -118,3 +119,5 @@ export default async function prune(interaction: ChatInputCommandInteraction): P }) }) } + +export default cmd diff --git a/src/commands/staff/removeguildroles.ts b/src/commands/staff/removeguildroles.ts index df9f63c..58fab8a 100644 --- a/src/commands/staff/removeguildroles.ts +++ b/src/commands/staff/removeguildroles.ts @@ -1,12 +1,12 @@ -import { ChatInputCommandInteraction, GuildMember } from "discord.js" +import { GuildMember } from "discord.js" import { getVerifies } from "src/drizzle/functions.js" import { embedColor, hypixelGuildID } from "~/config/options.js" -import { IGuildData } from "~/typings" +import { IGuildData, SubCommand } from "~/typings" import env from "~/utils/Env.js" import roleManage from "~/utils/Functions/rolesmanage.js" import { getGuild } from "~/utils/Hypixel.js" -export default async function removeGuildRoles(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const discordMember = interaction.member as GuildMember @@ -52,3 +52,5 @@ export default async function removeGuildRoles(interaction: ChatInputCommandInte } } } + +export default cmd diff --git a/src/commands/staff/updateall.ts b/src/commands/staff/updateall.ts index 9ba9a0a..df42da4 100644 --- a/src/commands/staff/updateall.ts +++ b/src/commands/staff/updateall.ts @@ -1,14 +1,14 @@ -import { ChannelType, ChatInputCommandInteraction, GuildMember } from "discord.js" +import { ChannelType, GuildMember } from "discord.js" import { getVerifies } from "src/drizzle/functions.js" import { embedColor, hypixelGuildID } from "~/config/options.js" -import { IGuildData } from "~/typings" +import { IGuildData, SubCommand } from "~/typings" import env from "~/utils/Env.js" import getGuildRank from "~/utils/Functions/guildrank.js" import roleManage from "~/utils/Functions/rolesmanage.js" import { getGuild, getIGN } from "~/utils/Hypixel.js" import { log } from "~/utils/Logger.js" -export default async function updateAll(interaction: ChatInputCommandInteraction): Promise { +const cmd: SubCommand = async (interaction) => { await interaction.deferReply() const discordMember = interaction.member as GuildMember @@ -116,3 +116,5 @@ export default async function updateAll(interaction: ChatInputCommandInteraction }] }) } + +export default cmd diff --git a/src/typings/SubCommand.ts b/src/typings/SubCommand.ts index 52ecc4d..a23e167 100644 --- a/src/typings/SubCommand.ts +++ b/src/typings/SubCommand.ts @@ -1,4 +1,5 @@ import { ChatInputCommandInteraction } from "discord.js" +import { ExtendedClient } from "~/utils/Client" export type SubCommand = (interaction: ChatInputCommandInteraction) => Promise - +export type SubCommmndClient = (interaction: ChatInputCommandInteraction, client: ExtendedClient) => Promise