Added types for subcommands

This commit is contained in:
2025-01-12 19:40:20 +01:00
parent 53914fa9dd
commit 560ad899f8
19 changed files with 81 additions and 42 deletions

View File

@@ -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 { devMessage, embedColor } from "~/config/options.js"
import { countingBanned } from "~/config/roles.js" import { countingBanned } from "~/config/roles.js"
import { SubCommand } from "~/typings"
export default async function ban(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
const member = interaction.options.getMember("user")! as GuildMember const member = interaction.options.getMember("user")! as GuildMember
if (member.roles.cache.has(countingBanned)) { if (member.roles.cache.has(countingBanned)) {
@@ -31,3 +32,5 @@ export default async function ban(interaction: ChatInputCommandInteraction): Pro
}) })
} }
} }
export default cmd

View File

@@ -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 { devMessage, embedColor } from "~/config/options.js"
import { countingBanned } from "~/config/roles.js" import { countingBanned } from "~/config/roles.js"
import { SubCommand } from "~/typings"
export default async function ban(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
const member = interaction.options.getMember("user")! as GuildMember const member = interaction.options.getMember("user")! as GuildMember
if (!member.roles.cache.has(countingBanned)) { if (!member.roles.cache.has(countingBanned)) {
@@ -31,3 +32,5 @@ export default async function ban(interaction: ChatInputCommandInteraction): Pro
}) })
} }
} }
export default cmd

View File

@@ -1,10 +1,9 @@
import { ChatInputCommandInteraction } from "discord.js"
import { devMessage, embedColor } from "~/config/options.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 { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js"
import { getGuild, getIGN, getPlayer, getUUID, guildLevel } from "~/utils/Hypixel.js" import { getGuild, getIGN, getPlayer, getUUID, guildLevel } from "~/utils/Hypixel.js"
export default async function guildInfo(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
@@ -160,3 +159,5 @@ export default async function guildInfo(interaction: ChatInputCommandInteraction
}] }]
}) })
} }
export default cmd

View File

@@ -1,9 +1,9 @@
import { ChatInputCommandInteraction } from "discord.js"
import { devMessage, embedColor } from "~/config/options.js" import { devMessage, embedColor } from "~/config/options.js"
import { SubCommand } from "~/typings"
import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js" import { dateTimeFormatter, numberFormatter } from "~/utils/Functions/intlFormaters.js"
import { getGuild, getHeadURL, getPlayer, getUUID } from "~/utils/Hypixel.js" import { getGuild, getHeadURL, getPlayer, getUUID } from "~/utils/Hypixel.js"
export default async function guildMember(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const ign = interaction.options.getString("ign")! const ign = interaction.options.getString("ign")!
@@ -145,3 +145,5 @@ export default async function guildMember(interaction: ChatInputCommandInteracti
}] }]
}) })
} }
export default cmd

View File

@@ -1,11 +1,10 @@
import { ChatInputCommandInteraction } from "discord.js"
import { devMessage, embedColor } from "~/config/options.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 { numberFormatter } from "~/utils/Functions/intlFormaters.js"
import { getGuild, getIGN, getPlayer, getUUID } from "~/utils/Hypixel.js" import { getGuild, getIGN, getPlayer, getUUID } from "~/utils/Hypixel.js"
import { redis } from "~/utils/Illegitimate.js" import { redis } from "~/utils/Illegitimate.js"
export default async function guildTop(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
@@ -215,3 +214,5 @@ export default async function guildTop(interaction: ChatInputCommandInteraction)
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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 player = useMainPlayer()
const queue = player.queues.get(interaction.guildId!) const queue = player.queues.get(interaction.guildId!)
if (!queue) { if (!queue) {
@@ -23,3 +23,5 @@ export default async function leave(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const player = useMainPlayer() const player = useMainPlayer()
@@ -56,3 +56,5 @@ export default async function nowplaying(interaction: ChatInputCommandInteractio
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const player = useMainPlayer() const player = useMainPlayer()
@@ -36,3 +36,5 @@ export default async function pause(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,9 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction, GuildMember } from "discord.js" import { GuildMember } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const query = interaction.options.getString("query")! const query = interaction.options.getString("query")!
const channel = (interaction.member as GuildMember).voice.channel const channel = (interaction.member as GuildMember).voice.channel
@@ -41,3 +42,5 @@ export default async function play(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const player = useMainPlayer() const player = useMainPlayer()
const queue = player.queues.get(interaction.guildId!) const queue = player.queues.get(interaction.guildId!)
@@ -37,3 +37,5 @@ export default async function queue(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const amount = interaction.options.getNumber("amount") ?? 1 const amount = interaction.options.getNumber("amount") ?? 1
@@ -42,3 +42,5 @@ export default async function skip(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const player = useMainPlayer() const player = useMainPlayer()
@@ -36,3 +36,5 @@ export default async function pause(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,8 +1,8 @@
import { useMainPlayer } from "discord-player" import { useMainPlayer } from "discord-player"
import { ChatInputCommandInteraction } from "discord.js"
import { embedColor } from "~/config/options.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() await interaction.deferReply()
const volume = interaction.options.getNumber("volume")! const volume = interaction.options.getNumber("volume")!
@@ -27,3 +27,5 @@ export default async function volume(interaction: ChatInputCommandInteraction) {
}] }]
}) })
} }
export default cmd

View File

@@ -1,9 +1,9 @@
import { ChatInputCommandInteraction } from "discord.js"
import { devMessage, embedColor } from "~/config/options.js" import { devMessage, embedColor } from "~/config/options.js"
import { beastbwfkdr, beastbwstars, beastduelswins, beastswkdr, beastswstars, bwwins, duelswlr } from "~/config/reqs.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" import { bedwarsLevel, getGuild, getHeadURL, getPlayer, getUUID, hypixelLevel, skywarsLevel } from "~/utils/Hypixel.js"
export default async function beast(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const ign = interaction.options.getString("ign")! const ign = interaction.options.getString("ign")!
@@ -206,3 +206,5 @@ export default async function beast(interaction: ChatInputCommandInteraction): P
}] }]
}) })
} }
export default cmd

View File

@@ -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 { 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<void> { const cmd: SubCommmndClient = async (interaction, client) => {
await interaction.deferReply() await interaction.deferReply()
type CommandList = { type CommandList = {
@@ -183,3 +183,5 @@ export default async function help(interaction: ChatInputCommandInteraction, cli
}) })
}) })
} }
export default cmd

View File

@@ -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 { devMessage, embedColor } from "~/config/options.js"
import { SubCommand } from "~/typings"
import env from "~/utils/Env.js" import env from "~/utils/Env.js"
export default async function prune(interaction: ChatInputCommandInteraction): Promise<void> { 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) {
@@ -118,3 +119,5 @@ export default async function prune(interaction: ChatInputCommandInteraction): P
}) })
}) })
} }
export default cmd

View File

@@ -1,12 +1,12 @@
import { ChatInputCommandInteraction, GuildMember } from "discord.js" import { GuildMember } from "discord.js"
import { getVerifies } from "src/drizzle/functions.js" import { getVerifies } from "src/drizzle/functions.js"
import { embedColor, hypixelGuildID } from "~/config/options.js" import { embedColor, hypixelGuildID } from "~/config/options.js"
import { IGuildData } from "~/typings" import { IGuildData, SubCommand } from "~/typings"
import env from "~/utils/Env.js" import env from "~/utils/Env.js"
import roleManage from "~/utils/Functions/rolesmanage.js" import roleManage from "~/utils/Functions/rolesmanage.js"
import { getGuild } from "~/utils/Hypixel.js" import { getGuild } from "~/utils/Hypixel.js"
export default async function removeGuildRoles(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const discordMember = interaction.member as GuildMember const discordMember = interaction.member as GuildMember
@@ -52,3 +52,5 @@ export default async function removeGuildRoles(interaction: ChatInputCommandInte
} }
} }
} }
export default cmd

View File

@@ -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 { getVerifies } from "src/drizzle/functions.js"
import { embedColor, hypixelGuildID } from "~/config/options.js" import { embedColor, hypixelGuildID } from "~/config/options.js"
import { IGuildData } from "~/typings" import { IGuildData, SubCommand } from "~/typings"
import env from "~/utils/Env.js" import env from "~/utils/Env.js"
import getGuildRank from "~/utils/Functions/guildrank.js" import getGuildRank from "~/utils/Functions/guildrank.js"
import roleManage from "~/utils/Functions/rolesmanage.js" import roleManage from "~/utils/Functions/rolesmanage.js"
import { getGuild, getIGN } from "~/utils/Hypixel.js" import { getGuild, getIGN } from "~/utils/Hypixel.js"
import { log } from "~/utils/Logger.js" import { log } from "~/utils/Logger.js"
export default async function updateAll(interaction: ChatInputCommandInteraction): Promise<void> { const cmd: SubCommand = async (interaction) => {
await interaction.deferReply() await interaction.deferReply()
const discordMember = interaction.member as GuildMember const discordMember = interaction.member as GuildMember
@@ -116,3 +116,5 @@ export default async function updateAll(interaction: ChatInputCommandInteraction
}] }]
}) })
} }
export default cmd

View File

@@ -1,4 +1,5 @@
import { ChatInputCommandInteraction } from "discord.js" import { ChatInputCommandInteraction } from "discord.js"
import { ExtendedClient } from "~/utils/Client"
export type SubCommand = (interaction: ChatInputCommandInteraction) => Promise<void> export type SubCommand = (interaction: ChatInputCommandInteraction) => Promise<void>
export type SubCommmndClient = (interaction: ChatInputCommandInteraction, client: ExtendedClient) => Promise<void>