diff --git a/src/commands/autokick.ts b/src/commands/autokick.ts index 760441e..09318b3 100644 --- a/src/commands/autokick.ts +++ b/src/commands/autokick.ts @@ -1,7 +1,5 @@ -import {ChatInputCommandInteraction, CommandInteraction, EmbedBuilder, PermissionFlagsBits, SlashCommandBuilder} from "discord.js"; +import {CommandInteraction, PermissionFlagsBits, SlashCommandBuilder} from "discord.js"; import {Command} from "../type/command"; -import TimeLengthInput from "../helpers/TimeLengthInput"; -import AutoKickHelper from "../helpers/AutoKickHelper"; export default class Autokick extends Command { constructor() { @@ -48,66 +46,9 @@ export default class Autokick extends Command { } } - private async set(interaction: ChatInputCommandInteraction) { - if (!interaction.guildId) return; - - const roleOption = interaction.options.getRole("role", true); - const kickTimeOption = interaction.options.getString("kicktime", true); - const noticeTimeOption = interaction.options.getString("noticetime"); - const noticeChannelOption = interaction.options.getChannel("noticechannel"); - - const roleId = roleOption.id; - const kickTimeInput = new TimeLengthInput(kickTimeOption); - const noticeTimeInput = noticeTimeOption ? new TimeLengthInput(noticeTimeOption) : undefined; - const noticeChannelId = noticeChannelOption?.id; - - if ((noticeTimeInput && !noticeTimeOption) || (!noticeTimeInput && noticeChannelOption)) { - await interaction.reply("Both `noticetime` and `noticechannel` must be set if you want a notification embed"); - return; - } - - await AutoKickHelper.SetSetting(interaction.guildId, roleId, kickTimeInput.GetMilliseconds(), noticeTimeInput?.GetMilliseconds(), noticeChannelId); - - const embed = new EmbedBuilder() - .setTitle("Auto Kick") - .setDescription("Configured auto kick for this server") - .addFields([ - { - name: "Role", - value: roleOption.name, - inline: true, - }, - { - name: "Kick Time", - value: kickTimeInput.GetLengthShort(), - inline: true, - }, - ]); - - if (noticeTimeInput) { - embed.addFields([ - { - name: "Notice Time", - value: noticeTimeInput.GetLengthShort(), - }, - { - name: "Notice Channel", - value: noticeChannelOption!.name!, - inline: true, - }, - ]); - } - - await interaction.reply({ - embeds: [ embed ], - }); + private async set(interaction: CommandInteraction) { } - private async unset(interaction: ChatInputCommandInteraction) { - if (!interaction.guildId) return; - - await AutoKickHelper.UnsetSetting(interaction.guildId); - - await interaction.reply("Unset the auto kick configuration for this server"); + private async unset(interaction: CommandInteraction) { } } diff --git a/src/database/entities/AutoKickConfig.ts b/src/database/entities/AutoKickConfig.ts index 6a82ba5..1ee3625 100644 --- a/src/database/entities/AutoKickConfig.ts +++ b/src/database/entities/AutoKickConfig.ts @@ -47,15 +47,4 @@ export default class AutoKickConfig extends BaseEntity { return query; } - - public static async FetchAllByServerId(serverId: string): Promise { - const repository = AppDataSource.getRepository(AutoKickConfig); - - const query = repository - .createQueryBuilder("config") - .where("config.serverId = :serverId", { serverId }) - .getMany(); - - return query; - } } diff --git a/src/helpers/AutoKickHelper.ts b/src/helpers/AutoKickHelper.ts deleted file mode 100644 index a02a934..0000000 --- a/src/helpers/AutoKickHelper.ts +++ /dev/null @@ -1,37 +0,0 @@ -import AutoKickConfig from "../database/entities/AutoKickConfig"; - -export default class AutoKickHelper { - public static async GetSetting(serverId: string): Promise { - const configs = await AutoKickConfig.FetchAllByServerId(serverId); - - if (configs.length != 1) { - return null; - } - - return configs[0]; - } - - public static async SetSetting(serverId: string, roleId: string, kickTime: number, noticeTime?: number, noticeChannelId?: string) { - const configs = await AutoKickConfig.FetchAllByServerId(serverId); - - if (configs.length == 0) { - const config = new AutoKickConfig(serverId, roleId, kickTime, noticeTime, noticeChannelId); - await config.Save(AutoKickConfig, config); - - return; - } - - const config = configs[0]; - - config.UpdateBasicDetails(roleId, kickTime, noticeTime, noticeChannelId); - await config.Save(AutoKickConfig, config); - } - - public static async UnsetSetting(serverId: string) { - const configs = await AutoKickConfig.FetchAllByServerId(serverId); - - for (let config of configs) { - await AutoKickConfig.Remove(AutoKickConfig, config); - } - } -} diff --git a/src/registry.ts b/src/registry.ts index 36dd021..a2d7391 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -4,7 +4,6 @@ import { EventType } from "./constants/EventType"; // Command Imports import About from "./commands/about"; import Audits from "./commands/audits"; -import Autokick from "./commands/autokick"; import Ban from "./commands/ban"; import Bunny from "./commands/bunny"; import Clear from "./commands/clear"; @@ -46,7 +45,6 @@ export default class Registry { public static RegisterCommands() { CoreClient.RegisterCommand("about", new About()); CoreClient.RegisterCommand("audits", new Audits()); - CoreClient.RegisterCommand("autokick", new Autokick()); CoreClient.RegisterCommand("ban", new Ban()); CoreClient.RegisterCommand("bunny", new Bunny()); CoreClient.RegisterCommand("clear", new Clear());