Updated subcommand types
This commit is contained in:
@@ -24,17 +24,17 @@ export default {
|
|||||||
const subcommand = interaction.options.getSubcommand()
|
const subcommand = interaction.options.getSubcommand()
|
||||||
|
|
||||||
if (subcommand === "member") {
|
if (subcommand === "member") {
|
||||||
await guildMember(interaction)
|
await guildMember({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "info") {
|
if (subcommand === "info") {
|
||||||
await guildInfo(interaction)
|
await guildInfo({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "top") {
|
if (subcommand === "top") {
|
||||||
await guildTop(interaction)
|
await guildTop({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const infoSub = new SlashCommandSubcommandBuilder()
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const query = interaction.options.getString("query")!
|
const query = interaction.options.getString("query")!
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const memberSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const ign = interaction.options.getString("ign")!
|
const ign = interaction.options.getString("ign")!
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const topSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setDescription("The amount of guild members to show. [Default: 10]")
|
.setDescription("The amount of guild members to show. [Default: 10]")
|
||||||
)
|
)
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const query = interaction.options.getString("query")!
|
const query = interaction.options.getString("query")!
|
||||||
|
|||||||
@@ -29,27 +29,27 @@ export default {
|
|||||||
const subcommand = interaction.options.getSubcommand()
|
const subcommand = interaction.options.getSubcommand()
|
||||||
|
|
||||||
if (subcommand === "help") {
|
if (subcommand === "help") {
|
||||||
help(interaction, client)
|
help({ interaction, client })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "beast") {
|
if (subcommand === "beast") {
|
||||||
beast(interaction)
|
beast({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "prune") {
|
if (subcommand === "prune") {
|
||||||
prune(interaction)
|
prune({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "removeguildroles") {
|
if (subcommand === "removeguildroles") {
|
||||||
removeGuildRoles(interaction)
|
removeGuildRoles({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subcommand === "updateall") {
|
if (subcommand === "updateall") {
|
||||||
updateAll(interaction)
|
updateAll({ interaction })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const beastSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
)
|
)
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const ign = interaction.options.getString("ign")!
|
const ign = interaction.options.getString("ign")!
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, MessageFlags, SlashCommandSubcommandBuilder } from "discord.js"
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ComponentType, MessageFlags, SlashCommandSubcommandBuilder } from "discord.js"
|
||||||
import { devMessage, embedColor } from "~/config/options"
|
import { devMessage, embedColor } from "~/config/options"
|
||||||
import { SubCommmndClient } from "~/typings"
|
import { SubCommand } from "~/typings"
|
||||||
|
|
||||||
export const helpSub = new SlashCommandSubcommandBuilder()
|
export const helpSub = new SlashCommandSubcommandBuilder()
|
||||||
.setName("help")
|
.setName("help")
|
||||||
.setDescription("Get help with staff commands")
|
.setDescription("Get help with staff commands")
|
||||||
|
|
||||||
const cmd: SubCommmndClient = async (interaction, client) => {
|
const cmd: SubCommand<true> = async ({ interaction, client }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
type CommandList = {
|
type CommandList = {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const pruneSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setName("prune")
|
.setName("prune")
|
||||||
.setDescription("Update the discord roles of all guild members")
|
.setDescription("Update the discord roles of all guild members")
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
if (interaction.user.id !== env.prod.DEV) {
|
if (interaction.user.id !== env.prod.DEV) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const removeGuildRolesSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setName("removeguildroles")
|
.setName("removeguildroles")
|
||||||
.setDescription("Remove guild roles from non members")
|
.setDescription("Remove guild roles from non members")
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const discordMember = interaction.member as GuildMember
|
const discordMember = interaction.member as GuildMember
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const updateAllSub = new SlashCommandSubcommandBuilder()
|
|||||||
.setName("updateall")
|
.setName("updateall")
|
||||||
.setDescription("Update the discord roles of all guild members")
|
.setDescription("Update the discord roles of all guild members")
|
||||||
|
|
||||||
const cmd: SubCommand = async (interaction) => {
|
const cmd: SubCommand = async ({ interaction }) => {
|
||||||
await interaction.deferReply()
|
await interaction.deferReply()
|
||||||
|
|
||||||
const discordMember = interaction.member as GuildMember
|
const discordMember = interaction.member as GuildMember
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
import { ChatInputCommandInteraction } from "discord.js"
|
import { ChatInputCommandInteraction } from "discord.js"
|
||||||
import { ExtendedClient } from "~/utils/Client"
|
import { ExtendedClient } from "~/utils/Client"
|
||||||
|
|
||||||
export type SubCommand = (interaction: ChatInputCommandInteraction) => Promise<void>
|
type InteractionObject = {
|
||||||
export type SubCommmndClient = (interaction: ChatInputCommandInteraction, client: ExtendedClient) => Promise<void>
|
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>
|
||||||
|
|||||||
Reference in New Issue
Block a user