Updated subcommand types

This commit is contained in:
2025-03-23 16:44:42 +01:00
parent e67307a6bd
commit d8ebeff481
11 changed files with 28 additions and 19 deletions

View File

@@ -24,17 +24,17 @@ export default {
const subcommand = interaction.options.getSubcommand()
if (subcommand === "member") {
await guildMember(interaction)
await guildMember({ interaction })
return
}
if (subcommand === "info") {
await guildInfo(interaction)
await guildInfo({ interaction })
return
}
if (subcommand === "top") {
await guildTop(interaction)
await guildTop({ interaction })
return
}

View File

@@ -24,7 +24,7 @@ export const infoSub = new SlashCommandSubcommandBuilder()
)
)
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const query = interaction.options.getString("query")!

View File

@@ -16,7 +16,7 @@ export const memberSub = new SlashCommandSubcommandBuilder()
.setRequired(true)
)
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!

View File

@@ -30,7 +30,7 @@ export const topSub = new SlashCommandSubcommandBuilder()
.setDescription("The amount of guild members to show. [Default: 10]")
)
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const query = interaction.options.getString("query")!

View File

@@ -29,27 +29,27 @@ export default {
const subcommand = interaction.options.getSubcommand()
if (subcommand === "help") {
help(interaction, client)
help({ interaction, client })
return
}
if (subcommand === "beast") {
beast(interaction)
beast({ interaction })
return
}
if (subcommand === "prune") {
prune(interaction)
prune({ interaction })
return
}
if (subcommand === "removeguildroles") {
removeGuildRoles(interaction)
removeGuildRoles({ interaction })
return
}
if (subcommand === "updateall") {
updateAll(interaction)
updateAll({ interaction })
return
}

View File

@@ -14,7 +14,7 @@ export const beastSub = new SlashCommandSubcommandBuilder()
.setRequired(true)
)
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const ign = interaction.options.getString("ign")!

View File

@@ -1,12 +1,12 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, MessageFlags, SlashCommandSubcommandBuilder } from "discord.js"
import { devMessage, embedColor } from "~/config/options"
import { SubCommmndClient } from "~/typings"
import { SubCommand } from "~/typings"
export const helpSub = new SlashCommandSubcommandBuilder()
.setName("help")
.setDescription("Get help with staff commands")
const cmd: SubCommmndClient = async (interaction, client) => {
const cmd: SubCommand<true> = async ({ interaction, client }) => {
await interaction.deferReply()
type CommandList = {

View File

@@ -7,7 +7,7 @@ export const pruneSub = new SlashCommandSubcommandBuilder()
.setName("prune")
.setDescription("Update the discord roles of all guild members")
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
if (interaction.user.id !== env.prod.DEV) {

View File

@@ -10,7 +10,7 @@ export const removeGuildRolesSub = new SlashCommandSubcommandBuilder()
.setName("removeguildroles")
.setDescription("Remove guild roles from non members")
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const discordMember = interaction.member as GuildMember

View File

@@ -12,7 +12,7 @@ export const updateAllSub = new SlashCommandSubcommandBuilder()
.setName("updateall")
.setDescription("Update the discord roles of all guild members")
const cmd: SubCommand = async (interaction) => {
const cmd: SubCommand = async ({ interaction }) => {
await interaction.deferReply()
const discordMember = interaction.member as GuildMember

View File

@@ -1,5 +1,14 @@
import { ChatInputCommandInteraction } from "discord.js"
import { ExtendedClient } from "~/utils/Client"
export type SubCommand = (interaction: ChatInputCommandInteraction) => Promise<void>
export type SubCommmndClient = (interaction: ChatInputCommandInteraction, client: ExtendedClient) => Promise<void>
type InteractionObject = {
interaction: ChatInputCommandInteraction
}
type ClientObject = {
client: ExtendedClient
}
type SubCommandObject<T extends boolean> = T extends true ? InteractionObject & ClientObject : InteractionObject
export type SubCommand<T extends boolean = false> = (arg: SubCommandObject<T>) => Promise<void>