From 6c523bbebac3a9fbba8494019d1a91374517b40a Mon Sep 17 00:00:00 2001 From: Ahmad <103906421+ahmadk953@users.noreply.github.com> Date: Fri, 28 Feb 2025 23:23:39 -0500 Subject: [PATCH] Updated Command Types --- src/commands/moderation/ban.ts | 11 +++-------- src/commands/moderation/unban.ts | 16 ++++------------ src/commands/moderation/warn.ts | 16 ++++------------ src/commands/testing/testJoin.ts | 12 ++---------- src/commands/testing/testLeave.ts | 14 +++----------- src/commands/util/members.ts | 8 ++------ src/commands/util/ping.ts | 7 ++----- src/commands/util/rules.ts | 11 ++--------- src/commands/util/server.ts | 7 ++----- src/commands/util/user-info.ts | 11 +++-------- src/types/CommandTypes.ts | 11 ++++++++++- 11 files changed, 37 insertions(+), 87 deletions(-) diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts index 9b40b0d..d834567 100644 --- a/src/commands/moderation/ban.ts +++ b/src/commands/moderation/ban.ts @@ -1,19 +1,14 @@ import { - CommandInteraction, PermissionsBitField, SlashCommandBuilder, - SlashCommandOptionsOnlyBuilder, } from 'discord.js'; + import { updateMember, updateMemberModerationHistory } from '../../db/db.js'; import { parseDuration, scheduleUnban } from '../../util/helpers.js'; +import { OptionsCommand } from '../../types/CommandTypes.js'; import logAction from '../../util/logging/logAction.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} - -const command: Command = { +const command: OptionsCommand = { data: new SlashCommandBuilder() .setName('ban') .setDescription('Ban a member from the server') diff --git a/src/commands/moderation/unban.ts b/src/commands/moderation/unban.ts index 70efff7..8a458f2 100644 --- a/src/commands/moderation/unban.ts +++ b/src/commands/moderation/unban.ts @@ -1,17 +1,9 @@ -import { - CommandInteraction, - PermissionsBitField, - SlashCommandBuilder, - SlashCommandOptionsOnlyBuilder, -} from 'discord.js'; +import { PermissionsBitField, SlashCommandBuilder } from 'discord.js'; + import { executeUnban } from '../../util/helpers.js'; +import { OptionsCommand } from '../../types/CommandTypes.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} - -const command: Command = { +const command: OptionsCommand = { data: new SlashCommandBuilder() .setName('unban') .setDescription('Unban a user from the server') diff --git a/src/commands/moderation/warn.ts b/src/commands/moderation/warn.ts index f368aa2..c92c7ae 100644 --- a/src/commands/moderation/warn.ts +++ b/src/commands/moderation/warn.ts @@ -1,18 +1,10 @@ -import { - CommandInteraction, - PermissionsBitField, - SlashCommandBuilder, - SlashCommandOptionsOnlyBuilder, -} from 'discord.js'; +import { PermissionsBitField, SlashCommandBuilder } from 'discord.js'; + import { updateMemberModerationHistory } from '../../db/db.js'; +import { OptionsCommand } from '../../types/CommandTypes.js'; import logAction from '../../util/logging/logAction.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} - -const command: Command = { +const command: OptionsCommand = { data: new SlashCommandBuilder() .setName('warn') .setDescription('Warn a member') diff --git a/src/commands/testing/testJoin.ts b/src/commands/testing/testJoin.ts index 5a0eb28..b1998e0 100644 --- a/src/commands/testing/testJoin.ts +++ b/src/commands/testing/testJoin.ts @@ -1,14 +1,6 @@ -import { - CommandInteraction, - PermissionsBitField, - SlashCommandBuilder, - SlashCommandOptionsOnlyBuilder, -} from 'discord.js'; +import { PermissionsBitField, SlashCommandBuilder } from 'discord.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} +import { Command } from '../../types/CommandTypes.js'; const command: Command = { data: new SlashCommandBuilder() diff --git a/src/commands/testing/testLeave.ts b/src/commands/testing/testLeave.ts index 3f13f5c..b643b0e 100644 --- a/src/commands/testing/testLeave.ts +++ b/src/commands/testing/testLeave.ts @@ -1,15 +1,7 @@ -import { - CommandInteraction, - PermissionsBitField, - SlashCommandBuilder, - SlashCommandOptionsOnlyBuilder, -} from 'discord.js'; -import { updateMember } from '../../db/db.js'; +import { PermissionsBitField, SlashCommandBuilder } from 'discord.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} +import { updateMember } from '../../db/db.js'; +import { Command } from '../../types/CommandTypes.js'; const command: Command = { data: new SlashCommandBuilder() diff --git a/src/commands/util/members.ts b/src/commands/util/members.ts index bd088f2..083ee64 100644 --- a/src/commands/util/members.ts +++ b/src/commands/util/members.ts @@ -1,6 +1,5 @@ import { SlashCommandBuilder, - CommandInteraction, EmbedBuilder, ButtonBuilder, ActionRowBuilder, @@ -9,12 +8,9 @@ import { APIEmbed, JSONEncodable, } from 'discord.js'; -import { getAllMembers } from '../../db/db.js'; -interface Command { - data: Omit; - execute: (interaction: CommandInteraction) => Promise; -} +import { getAllMembers } from '../../db/db.js'; +import { Command } from '../../types/CommandTypes.js'; const command: Command = { data: new SlashCommandBuilder() diff --git a/src/commands/util/ping.ts b/src/commands/util/ping.ts index c67554e..ed64529 100644 --- a/src/commands/util/ping.ts +++ b/src/commands/util/ping.ts @@ -1,9 +1,6 @@ -import { SlashCommandBuilder, CommandInteraction } from 'discord.js'; +import { SlashCommandBuilder } from 'discord.js'; -interface Command { - data: Omit; - execute: (interaction: CommandInteraction) => Promise; -} +import { Command } from '../../types/CommandTypes.js'; const command: Command = { data: new SlashCommandBuilder() diff --git a/src/commands/util/rules.ts b/src/commands/util/rules.ts index eb7d5f7..c8ff029 100644 --- a/src/commands/util/rules.ts +++ b/src/commands/util/rules.ts @@ -1,13 +1,6 @@ -import { - SlashCommandBuilder, - CommandInteraction, - EmbedBuilder, -} from 'discord.js'; +import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; -interface Command { - data: Omit; - execute: (interaction: CommandInteraction) => Promise; -} +import { Command } from '../../types/CommandTypes.js'; const rulesEmbed = new EmbedBuilder() .setColor(0x0099ff) diff --git a/src/commands/util/server.ts b/src/commands/util/server.ts index 565770d..a391e03 100644 --- a/src/commands/util/server.ts +++ b/src/commands/util/server.ts @@ -1,9 +1,6 @@ -import { SlashCommandBuilder, CommandInteraction } from 'discord.js'; +import { SlashCommandBuilder } from 'discord.js'; -interface Command { - data: Omit; - execute: (interaction: CommandInteraction) => Promise; -} +import { Command } from '../../types/CommandTypes.js'; const command: Command = { data: new SlashCommandBuilder() diff --git a/src/commands/util/user-info.ts b/src/commands/util/user-info.ts index 42218ab..7f1ac68 100644 --- a/src/commands/util/user-info.ts +++ b/src/commands/util/user-info.ts @@ -1,19 +1,14 @@ import { SlashCommandBuilder, - CommandInteraction, EmbedBuilder, - SlashCommandOptionsOnlyBuilder, GuildMember, PermissionsBitField, } from 'discord.js'; + import { getMember } from '../../db/db.js'; +import { OptionsCommand } from '../../types/CommandTypes.js'; -interface Command { - data: SlashCommandOptionsOnlyBuilder; - execute: (interaction: CommandInteraction) => Promise; -} - -const command: Command = { +const command: OptionsCommand = { data: new SlashCommandBuilder() .setName('userinfo') .setDescription('Provides information about the specified user.') diff --git a/src/types/CommandTypes.ts b/src/types/CommandTypes.ts index 5c8b644..30d175c 100644 --- a/src/types/CommandTypes.ts +++ b/src/types/CommandTypes.ts @@ -1,6 +1,15 @@ -import { CommandInteraction, SlashCommandBuilder } from 'discord.js'; +import { + CommandInteraction, + SlashCommandBuilder, + SlashCommandOptionsOnlyBuilder, +} from 'discord.js'; export interface Command { data: Omit; execute: (interaction: CommandInteraction) => Promise; } + +export interface OptionsCommand { + data: SlashCommandOptionsOnlyBuilder; + execute: (interaction: CommandInteraction) => Promise; +}