From 020ef73775b1eaec988173dff892b107f5c99835 Mon Sep 17 00:00:00 2001 From: Sebola3461 Date: Sat, 15 Jun 2024 22:15:02 -0300 Subject: [PATCH] Fix typing errors --- commands/management/quotes.ts | 63 ----------- .../subcommands/quotes/quotesAddWord.ts | 48 -------- .../subcommands/quotes/quotesAllowChannels.ts | 73 ------------ .../subcommands/quotes/quotesBlockChannels.ts | 73 ------------ .../subcommands/quotes/quotesGetList.ts | 41 ------- .../subcommands/quotes/quotesSetChance.ts | 48 -------- .../subcommands/quotes/quotesSetList.ts | 67 ----------- .../subcommands/quotes/quotesSetType.ts | 53 --------- .../subcommands/quotes/quotesSetWord.ts | 48 -------- .../subcommands/quotes/quotesStatus.ts | 62 ---------- .../subcommands/quotes/quotesToggle.ts | 53 --------- helpers/core/slashCommandHandler.ts | 106 ------------------ helpers/interactions/registerCommands.ts | 84 -------------- modules/mappertracker/mapperTrackerManager.ts | 2 +- modules/osu/fetcher/beatmap.ts | 6 +- .../client/runVerificationChecks.ts | 7 +- responses/osu/PlayerEmbed.ts | 7 +- responses/qat/BNEmbed.ts | 2 - 18 files changed, 5 insertions(+), 838 deletions(-) delete mode 100644 commands/management/quotes.ts delete mode 100644 commands/management/subcommands/quotes/quotesAddWord.ts delete mode 100644 commands/management/subcommands/quotes/quotesAllowChannels.ts delete mode 100644 commands/management/subcommands/quotes/quotesBlockChannels.ts delete mode 100644 commands/management/subcommands/quotes/quotesGetList.ts delete mode 100644 commands/management/subcommands/quotes/quotesSetChance.ts delete mode 100644 commands/management/subcommands/quotes/quotesSetList.ts delete mode 100644 commands/management/subcommands/quotes/quotesSetType.ts delete mode 100644 commands/management/subcommands/quotes/quotesSetWord.ts delete mode 100644 commands/management/subcommands/quotes/quotesStatus.ts delete mode 100644 commands/management/subcommands/quotes/quotesToggle.ts delete mode 100644 helpers/core/slashCommandHandler.ts delete mode 100644 helpers/interactions/registerCommands.ts diff --git a/commands/management/quotes.ts b/commands/management/quotes.ts deleted file mode 100644 index ce501f7a..00000000 --- a/commands/management/quotes.ts +++ /dev/null @@ -1,63 +0,0 @@ -// import { PermissionFlagsBits } from "discord.js"; -// import { SlashCommand } from "../../models/commands/SlashCommand"; -// import quotesToggle from "./subcommands/quotes/quotesToggle"; -// import quotesStatus from "./subcommands/quotes/quotesStatus"; -// import { SlashCommandSubcommandGroup } from "../../models/commands/SlashCommandSubcommandGroup"; -// import quotestSetType from "./subcommands/quotes/quotesSetType"; -// import quotesSetList from "./subcommands/quotes/quotesSetList"; -// import quotesSetChance from "./subcommands/quotes/quotesSetChance"; -// import quotesSetWord from "./subcommands/quotes/quotesSetWord"; -// import quotesBlockChannels from "./subcommands/quotes/quotesBlockChannels"; -// import quotesAllowChannels from "./subcommands/quotes/quotesAllowChannels"; -// import quotesAddWord from "./subcommands/quotes/quotesAddWord"; - -// const quotes = new SlashCommand( -// "quotes", -// "Configure random quotes system", -// "Management", -// false, -// undefined, -// [PermissionFlagsBits.ManageChannels] -// ); - -// quotes.addSubcommand(quotesToggle).addSubcommand(quotesStatus); - -// const commandGroupSET = new SlashCommandSubcommandGroup( -// "set", -// "Set some value to the system" -// ); - -// commandGroupSET -// .addCommand(quotestSetType) -// .addCommand(quotesSetList) -// .addCommand(quotesSetChance) -// .addCommand(quotesSetWord); - -// const commandGroupBLOCK = new SlashCommandSubcommandGroup( -// "block", -// "Block some value to the system" -// ); - -// commandGroupBLOCK.addCommand(quotesBlockChannels); - -// const commandGroupALLOW = new SlashCommandSubcommandGroup( -// "allow", -// "Allow some value to the system" -// ); - -// commandGroupALLOW.addCommand(quotesAllowChannels); - -// const commandGroupADD = new SlashCommandSubcommandGroup( -// "add", -// "Add some value to the system" -// ); - -// commandGroupADD.addCommand(quotesAddWord); - -// quotes -// .addSubcommandGroup(commandGroupSET) -// .addSubcommandGroup(commandGroupBLOCK) -// .addSubcommandGroup(commandGroupADD) -// .addSubcommandGroup(commandGroupALLOW); - -// export default quotes; diff --git a/commands/management/subcommands/quotes/quotesAddWord.ts b/commands/management/subcommands/quotes/quotesAddWord.ts deleted file mode 100644 index 91781172..00000000 --- a/commands/management/subcommands/quotes/quotesAddWord.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { Message, PermissionFlagsBits } from "discord.js"; -import * as database from "../../../../database"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesAddWord = new SlashCommandSubcommand( - "word", - "Adds a new phrase to the server custom quotes list", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesAddWord.builder.addStringOption((o) => - o.setName("phrase").setDescription("Phrase that you want to add").setRequired(true) -); - -quotesAddWord.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - - if (!guild) return; - - if (guild.fun.mode != "custom") - return command.editReply({ - embeds: [generateErrorEmbed("This server is not in custom quotes mode.")], - }); - - if (!command.guild) return; - - const phrase = command.options.getString("phrase", true); - - if (!guild.fun.phrases) guild.fun.phrases = [] as string[]; - - guild.fun.phrases.push(phrase); - - await database.guilds.updateOne( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [generateSuccessEmbed(`Phrase added!`)], - }); -}); - -export default quotesAddWord; diff --git a/commands/management/subcommands/quotes/quotesAllowChannels.ts b/commands/management/subcommands/quotes/quotesAllowChannels.ts deleted file mode 100644 index 0c6b6ece..00000000 --- a/commands/management/subcommands/quotes/quotesAllowChannels.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ChannelType, PermissionFlagsBits } from "discord.js"; - -import * as database from "../../../../database"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesAllowChannels = new SlashCommandSubcommand( - "channel", - "Set channels that quotes can run. ", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesAllowChannels.builder.addStringOption((o) => - o - .setName("channels") - .setDescription( - 'Channel names without # and split by comma. Use "all" to allow all channels' - ) - .setRequired(true) -); - -quotesAllowChannels.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - - if (!command.guild) return; - if (!guild) return; - - const channel = command.options.getString("channels", true); - - let channels: string[] = []; - - channel.split(",").forEach((channelName) => { - channelName = channelName.trim(); - - const requested = command.guild?.channels.cache.find( - (c) => c.name == channelName - ); - - if (requested && requested.type == ChannelType.GuildText) { - channels.push(requested.id); - } - }); - - if (channels[0] == "all") channels = ["all"]; - - let blacklist = guild.fun.blacklist.channels; - - if (channels.length) - return generateErrorEmbed("Provide valid text channels!"); - - channels.forEach((channel) => { - if ( - !blacklist.includes(channel) && - !["all", "none"].includes(channel) - ) { - blacklist = blacklist.filter((l: string) => l != channel); - } - }); - - guild.fun.blacklist.channels = blacklist; - - await database.guilds.findOneAndUpdate({ _id: command.guildId }, guild); - - command.editReply({ - embeds: [ - generateSuccessEmbed(`✅ Done! Use \`/quotes status\` to check`), - ], - }); -}); - -export default quotesAllowChannels; diff --git a/commands/management/subcommands/quotes/quotesBlockChannels.ts b/commands/management/subcommands/quotes/quotesBlockChannels.ts deleted file mode 100644 index baed60a3..00000000 --- a/commands/management/subcommands/quotes/quotesBlockChannels.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { ChannelType, PermissionFlagsBits } from "discord.js"; - -import * as database from "../../../../database"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesBlockChannels = new SlashCommandSubcommand( - "channel", - "Set channels that quotes can't run. ", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesBlockChannels.builder.addStringOption((o) => - o - .setName("channels") - .setDescription( - 'Channel names without # and split by comma. Use "all" to block all channels' - ) - .setRequired(true) -); - -quotesBlockChannels.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - - if (!command.guild) return; - if (!guild) return; - - const channel = command.options.getString("channels", true); - - let channels: string[] = []; - - channel.split(",").forEach((channelName) => { - channelName = channelName.trim(); - - const requested = command.guild?.channels.cache.find( - (c) => c.name == channelName - ); - - if (requested && requested.type == ChannelType.GuildText) { - channels.push(requested.id); - } - }); - - if (channels[0] == "all") channels = ["none"]; - - const blacklist = guild.fun.blacklist.channels; - - if (channels.length) - return generateErrorEmbed("Provide valid text channels!"); - - channels.forEach((channel) => { - if ( - !blacklist.includes(channel) && - !["all", "none"].includes(channel) - ) { - blacklist.push(channel); - } - }); - - guild.fun.blacklist.channels = blacklist; - - await database.guilds.findOneAndUpdate({ _id: command.guildId }, guild); - - command.editReply({ - embeds: [ - generateSuccessEmbed(`✅ Done! Use \`/quotes status\` to check`), - ], - }); -}); - -export default quotesBlockChannels; diff --git a/commands/management/subcommands/quotes/quotesGetList.ts b/commands/management/subcommands/quotes/quotesGetList.ts deleted file mode 100644 index 4fa8816c..00000000 --- a/commands/management/subcommands/quotes/quotesGetList.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { AttachmentBuilder, PermissionFlagsBits } from "discord.js"; - -import * as database from "../../../../database"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesCustomFile = new SlashCommandSubcommand( - "customfile", - "Send custom list file for download", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesCustomFile.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - if (guild.fun.mode != "custom") - return command.editReply({ - embeds: [ - generateErrorEmbed( - "❗ This server is not using a custom quote list." - ), - ], - }); - - const text = guild.fun.phrases.join("\n"); - const buffer = Buffer.from(text, "utf-8"); - const attachment = new AttachmentBuilder(buffer, { - name: "List.txt", - }); - - command.editReply({ - content: "Current list:", - files: [attachment], - }); -}); - -export default quotesCustomFile; diff --git a/commands/management/subcommands/quotes/quotesSetChance.ts b/commands/management/subcommands/quotes/quotesSetChance.ts deleted file mode 100644 index b67c1442..00000000 --- a/commands/management/subcommands/quotes/quotesSetChance.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { PermissionFlagsBits } from "discord.js"; -import * as database from "../../../../database"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesSetChance = new SlashCommandSubcommand( - "chance", - "Set a chance between 1->100 to reply with a quote after the trigger word is detected", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesSetChance.builder.addIntegerOption((o) => - o - .setName("chance") - .setDescription("Chance number (percentage)") - .setRequired(true) - .setMinValue(1) - .setMaxValue(100) -); - -quotesSetChance.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - const chance = command.options.getInteger("chance", true); - - guild.fun.chance = chance; - - await database.guilds.updateOne( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [ - generateSuccessEmbed( - `✅ Successfully set the chance to ${chance}%` - ), - ], - }); -}); - -export default quotesSetChance; diff --git a/commands/management/subcommands/quotes/quotesSetList.ts b/commands/management/subcommands/quotes/quotesSetList.ts deleted file mode 100644 index be3864d6..00000000 --- a/commands/management/subcommands/quotes/quotesSetList.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { PermissionFlagsBits } from "discord.js"; -import * as database from "../../../../database"; -import { parseTextFileAttachment } from "../../../../helpers/text/processText"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesSetList = new SlashCommandSubcommand( - "list", - "Sets a custom list for the server quotes", - { - syntax: "/quotes `set` `list` `[Text File Attachment]`", - note: "Quotes are split by line break.", - }, - [PermissionFlagsBits.ManageChannels] -); - -quotesSetList.builder.addAttachmentOption((o) => - o - .setName("text_file") - .setDescription("Text file with quotes") - .setRequired(true) -); - -quotesSetList.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - const file = command.options.getAttachment("text_file", true); - - if (!command.guild) return; - - if (!file || file.contentType != "text/plain; charset=utf-8") - return command.editReply({ - embeds: [generateErrorEmbed("❗ Please attach a text file.")], - }); - - // ? Prevent big files (It uses bytes) - if (file.size > 200000) - return command.editReply({ - embeds: [ - generateErrorEmbed("❌ File is too big. Max size is 200KB."), - ], - }); - - const list = await parseTextFileAttachment(file.url); - - if (list.length < 1) - return command.editReply({ - embeds: [generateErrorEmbed("❌ File is empty.")], - }); - - guild.fun.enable = true; - guild.fun.phrases = list; - - await database.guilds.findOneAndUpdate( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [generateSuccessEmbed("✅ Loaded the list!")], - }); -}); - -export default quotesSetList; diff --git a/commands/management/subcommands/quotes/quotesSetType.ts b/commands/management/subcommands/quotes/quotesSetType.ts deleted file mode 100644 index f3f9d33c..00000000 --- a/commands/management/subcommands/quotes/quotesSetType.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { PermissionFlagsBits } from "discord.js"; -import * as database from "../../../../database"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotestSetType = new SlashCommandSubcommand( - "type", - "Change quotes system list to default list or custom list", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotestSetType.builder.addStringOption((o) => - o - .setName("type") - .setDescription("Select list type") - .addChoices( - { - name: "default", - value: "default", - }, - { - name: "custom", - value: "custom", - } - ) - .setRequired(true) -); - -quotestSetType.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - const type = command.options.getString("type", true); - - guild.fun.enable = true; - guild.fun.mode = type; - - await database.guilds.updateOne( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [generateSuccessEmbed(`✅ Switched mode to ${type}.`)], - }); -}); - -export default quotestSetType; diff --git a/commands/management/subcommands/quotes/quotesSetWord.ts b/commands/management/subcommands/quotes/quotesSetWord.ts deleted file mode 100644 index df23bfbb..00000000 --- a/commands/management/subcommands/quotes/quotesSetWord.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { PermissionFlagsBits } from "discord.js"; -import * as database from "../../../../database"; -import generateErrorEmbed from "../../../../helpers/text/embeds/generateErrorEmbed"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesSetWord = new SlashCommandSubcommand( - "word", - "Sets a trigger word for the quotes system", - { - syntax: "/quotes `set` `word` ``", - }, - [PermissionFlagsBits.ManageChannels] -); - -quotesSetWord.builder.addStringOption((o) => - o.setName("word").setDescription("New word").setRequired(true) -); - -quotesSetWord.setExecuteFunction(async (command) => { - const word = command.options.getString("word", true); - - if (word == "") - return command.editReply({ - embeds: [generateErrorEmbed("❗ Please specify a word.")], - }); - - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - guild.fun.enable = true; - guild.fun.word = word.toUpperCase(); - - await database.guilds.updateOne( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [generateSuccessEmbed(`✅ Trigger word set to \`${word}\`!`)], - }); -}); - -export default quotesSetWord; diff --git a/commands/management/subcommands/quotes/quotesStatus.ts b/commands/management/subcommands/quotes/quotesStatus.ts deleted file mode 100644 index d3f0be18..00000000 --- a/commands/management/subcommands/quotes/quotesStatus.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { EmbedBuilder, PermissionFlagsBits } from "discord.js"; -import colors from "../../../../constants/colors"; -import * as database from "../../../../database"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesStatus = new SlashCommandSubcommand( - "status", - "Display info about system configuration", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesStatus.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - if (!guild.fun.word) guild.fun.word = "axer"; - - const embed = new EmbedBuilder() - .setTitle("⚙️ Current quotes system configuration") - .setFields( - { - name: "Status", - value: guild.fun.enable ? "`Enabled`" : "`Disabled`", - }, - { - name: "List mode", - value: `\`${guild.fun.mode - .charAt(0) - .toUpperCase() - .concat(guild.fun.mode.slice(1))}\``, // Captalize the first character - }, - { - name: "Trigger word", - value: `\`${guild.fun.word.toLowerCase()}\``, - }, - { - name: "Reply chance", - value: `\`${ - guild.fun.chance ? `${guild.fun.chance}%` : "100%" - }\``, - }, - { - name: "Blocked channels", - value: - guild.fun.blacklist.channels.length > 0 - ? `${guild.fun.blacklist.channels.map((c: any) => { - return `<#${c}>`; - })}` - : "None.", - } - ) - .setColor(guild.fun.enable ? colors.green : colors.red); - - command.editReply({ - embeds: [embed], - }); -}); - -export default quotesStatus; diff --git a/commands/management/subcommands/quotes/quotesToggle.ts b/commands/management/subcommands/quotes/quotesToggle.ts deleted file mode 100644 index fe85d498..00000000 --- a/commands/management/subcommands/quotes/quotesToggle.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { PermissionFlagsBits } from "discord.js"; - -import * as database from "../../../../database"; -import generateSuccessEmbed from "../../../../helpers/text/embeds/generateSuccessEmbed"; -import { SlashCommandSubcommand } from "../../../../models/commands/SlashCommandSubcommand"; - -const quotesToggle = new SlashCommandSubcommand( - "toggle", - "Disable or enable quotes system", - undefined, - [PermissionFlagsBits.ManageChannels] -); - -quotesToggle.builder.addStringOption((o) => - o - .setName("status") - .setDescription("Enable or disable?") - .setRequired(true) - .addChoices( - { - name: "Enable", - value: "enabled", - }, - { - name: "Disable", - value: "disabled", - } - ) -); - -quotesToggle.setExecuteFunction(async (command) => { - let guild = await database.guilds.findById(command.guildId); - if (!guild) return; - - if (!command.guild) return; - - const status = command.options.getString("status", true); - - guild.fun.enable = status == "enabled"; - - await database.guilds.updateOne( - { _id: command.guildId }, - { - fun: guild.fun, - } - ); - - command.editReply({ - embeds: [generateSuccessEmbed(`✅ quotes system is ${status}.`)], - }); -}); - -export default quotesToggle; diff --git a/helpers/core/slashCommandHandler.ts b/helpers/core/slashCommandHandler.ts deleted file mode 100644 index fc2e060e..00000000 --- a/helpers/core/slashCommandHandler.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { - ApplicationCommandOptionType, - ChannelType, - ChatInputCommandInteraction, - Client, - ContextMenuCommandInteraction, - GuildMember, - Interaction, - MessageContextMenuCommandInteraction, - PermissionResolvable, - UserContextMenuCommandInteraction, -} from "discord.js"; -import config from "../../config.json"; -import { AxerCommands } from "../../commands"; -import { ContextMenuCommand } from "../../models/commands/ContextMenuCommand"; -import MissingPermissions from "../../responses/embeds/MissingPermissions"; -import generateErrorEmbed from "../text/embeds/generateErrorEmbed"; -import createNewUser from "../../database/utils/createNewUser"; - -export function checkMemberPermissions(member: GuildMember, permissions: PermissionResolvable[]) { - let pass = false; - - if (!member) return false; - - if (config.owners.includes(member.user.id)) return true; - - if (permissions.length == 0) return true; - - permissions.forEach((permission) => { - if (member.permissions.has(permission)) pass = true; - }); - - return pass; -} - -export default async function commandHandler( - bot: Client, - event: - | ChatInputCommandInteraction - | MessageContextMenuCommandInteraction - | UserContextMenuCommandInteraction -) { - if (event.user.bot) return; - - const targetCommand = AxerCommands.find( - (c) => - c.names.includes(event.commandName) || - ( - c as ContextMenuCommand< - UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction - > - ).name == event.commandName - ); - - if (!targetCommand) return console.log("0"); // Command not found error embed - - if (!targetCommand.allowDM && !event.channel) - return event.reply({ - embeds: [generateErrorEmbed("You need to run this command in a guild!")], - }); // Command error message - - if (!targetCommand.allowDM && event.channel?.type == ChannelType.DM) - return event.reply({ - embeds: [generateErrorEmbed("You need to run this command in a guild!")], - }); // Command error message - - if (targetCommand.permissions.length != 0 && !event.member) - return event.reply({ - embeds: [generateErrorEmbed("You need to run this command in a guild!")], - }); - - if ( - targetCommand.permissions.length != 0 && - !checkMemberPermissions(event.member as GuildMember, targetCommand.permissions) - ) { - return event.reply({ - embeds: [MissingPermissions], - }); - } - - await createNewUser(event.user); - - if (targetCommand.isSlashCommand() && event.isChatInputCommand()) { - try { - if (event.options.getSubcommand() || event.options.getSubcommandGroup()) - return targetCommand.runSubcommand(event, { - name: event.options.getSubcommand(), - group: event.options.getSubcommandGroup(), - }); - } catch (e) { - if (!String(e).includes("CommandInteractionOptionNoSubcommand")) console.error(e); - } - - try { - targetCommand.run(event); - } catch (e) { - console.error(e); - } - } - - if (targetCommand.isContextMenu() && event.isContextMenuCommand()) { - if (event.isContextMenuCommand()) { - (targetCommand as ContextMenuCommand).run(event); - } - } -} diff --git a/helpers/interactions/registerCommands.ts b/helpers/interactions/registerCommands.ts deleted file mode 100644 index ecd03283..00000000 --- a/helpers/interactions/registerCommands.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { - Client, - MessageContextMenuCommandInteraction, - UserContextMenuCommandInteraction, -} from "discord.js"; -import { REST } from "@discordjs/rest"; -import { Routes } from "discord-api-types/v9"; -import { consoleLog, consoleCheck } from "../core/logger"; -import { AxerCommands } from "../../commands"; -import { SlashCommand } from "models/commands/SlashCommand"; -import { ContextMenuCommand } from "../../models/commands/ContextMenuCommand"; - -export default (bot: Client) => { - const _commands: { [key: string]: any } = []; - - for (const command of AxerCommands) { - post(command); - } - - function post( - command: - | SlashCommand - | ContextMenuCommand< - | UserContextMenuCommandInteraction - | MessageContextMenuCommandInteraction - > - ) { - consoleCheck( - "registerCommands", - `Command ${command.names.join("/")} queued!` - ); - - if ((command as SlashCommand).builder) { - command.names.forEach((name) => { - if ((command as SlashCommand).builder) { - (command as SlashCommand).builder.setName(name); - _commands.push((command as SlashCommand).builder.toJSON()); - } - }); - } else { - _commands.push( - ( - command as ContextMenuCommand< - | UserContextMenuCommandInteraction - | MessageContextMenuCommandInteraction - > - ).toJSON() - ); - } - } - - const rest = new REST({ version: "10" }).setToken(process.env.TOKEN || ""); - - (async () => { - try { - consoleLog( - "registerCommands", - "Started refreshing application (/) commands." - ); - - const commandsResponse: any = await rest.put( - Routes.applicationCommands(process.env.CLIENT_ID || ""), - { - body: _commands, - } - ); - - commandsResponse.forEach((command: any) => { - consoleCheck( - "registerCommands", - `Command ${command.name} registered!` - ); - }); - - consoleCheck( - "registerCommands", - "Successfully reloaded application (/) commands." - ); - } catch (error) { - console.error(error); - console.error(JSON.stringify(error)); - } - })(); -}; diff --git a/modules/mappertracker/mapperTrackerManager.ts b/modules/mappertracker/mapperTrackerManager.ts index 2fdac6da..a94ae7ca 100644 --- a/modules/mappertracker/mapperTrackerManager.ts +++ b/modules/mappertracker/mapperTrackerManager.ts @@ -16,7 +16,7 @@ // import { sendBeatmapHypeEmbed } from "../../responses/IMapperTracker/SendBeatmapHypeEmbed"; // import { sendBeatmapFavoriteEmbed } from "../../responses/IMapperTracker/SendBeatmapFavoriteEmbed"; -import { MapperTrackerType } from "../../commands/osu/mappertracker"; +import { MapperTrackerType } from "../../struct/mapperTracker/TrackerTypes"; // export interface MapperTracker { // _id: string; diff --git a/modules/osu/fetcher/beatmap.ts b/modules/osu/fetcher/beatmap.ts index cac0eb94..d4dabf73 100644 --- a/modules/osu/fetcher/beatmap.ts +++ b/modules/osu/fetcher/beatmap.ts @@ -1,9 +1,4 @@ import axios from "axios"; - -import { - BeatmapGenre, - BeatmapLanguage, -} from "../../../commands/osu/subcommands/beatmap/searchBeatmap"; import { consoleCheck, consoleError, consoleLog } from "../../../helpers/core/logger"; import { BeatmapResponse, @@ -21,6 +16,7 @@ import { IHTTPResponse } from "../../../types/http"; import { HTTPResponse } from "../../../types/qat"; import { FetchDownloadClient, OsuAuthenticator, OsuOfficialDownloader } from "./downloader/beatmap"; import { UserCompact } from "../../../types/user"; +import { BeatmapGenre, BeatmapLanguage } from "../../../struct/beatmaps/SearchTypes"; export async function beatmap(beatmap_id: string): Promise { try { diff --git a/modules/verification/client/runVerificationChecks.ts b/modules/verification/client/runVerificationChecks.ts index 3434a94b..a0d2d3fe 100644 --- a/modules/verification/client/runVerificationChecks.ts +++ b/modules/verification/client/runVerificationChecks.ts @@ -1,17 +1,14 @@ import { Guild, GuildMember } from "discord.js"; -import { guilds, users, verifications } from "../../../database"; +import { guilds, users } from "../../../database"; import { User, UserGroup } from "../../../types/user"; import osuApi from "../../../modules/osu/fetcher/osuApi"; import { IMapperRole, MapperRoleType, } from "../../../commands/management/subcommands/verification/addMapperRole"; -import { HTTPResponse } from "../../../types/qat"; import { Beatmapset } from "../../../types/beatmap"; -import { IHTTPResponse } from "../../../types/http"; -import { bot } from "../../.."; -import { BeatmapStatus } from "../../../commands/osu/subcommands/beatmap/searchBeatmap"; import { countryFlags } from "../../../constants/countryflags"; +import { BeatmapStatus } from "../../../struct/beatmaps/SearchTypes"; export async function runVerificationChecks(guild: Guild, user: User, member: GuildMember) { const guild_db = await guilds.findById(guild.id); diff --git a/responses/osu/PlayerEmbed.ts b/responses/osu/PlayerEmbed.ts index 5f2aafad..2f12aadc 100644 --- a/responses/osu/PlayerEmbed.ts +++ b/responses/osu/PlayerEmbed.ts @@ -5,7 +5,6 @@ import generatePlayerRankChart from "../../modules/osu/player/generatePlayerRank import parseUsergroup from "../../modules/osu/player/getHighestUsergroup"; import parsePlayTime from "../../modules/osu/player/parsePlayTime"; import { UserResponse } from "../../types/user"; -import { ContextMenuType } from "../../models/commands/ContextMenuCommand"; export default { send: async (user: UserResponse, message: Message, mode?: string) => { @@ -114,11 +113,7 @@ export default { void {}; }); }, - reply: async ( - user: UserResponse, - interaction: ChatInputCommandInteraction | ContextMenuType.Message | ContextMenuType.User, - mode?: string - ) => { + reply: async (user: UserResponse, interaction: ChatInputCommandInteraction, mode?: string) => { const usergroup = parseUsergroup(user.data); const attachment = user.data.statistics?.global_rank diff --git a/responses/qat/BNEmbed.ts b/responses/qat/BNEmbed.ts index 37e8e655..4b53ac84 100644 --- a/responses/qat/BNEmbed.ts +++ b/responses/qat/BNEmbed.ts @@ -17,8 +17,6 @@ import getEmoji from "../../helpers/text/getEmoji"; import parseUsergroup from "../../modules/osu/player/getHighestUsergroup"; import { QatUserResponse, UserActivityResponse } from "../../types/qat"; import { UserResponse } from "../../types/user"; -import { bnRules } from "../../database"; -import bn from "../../commands/BNsite/bn"; //! if you're re-adding QA info, check other warning comments and remove the regular /* */ comments // TODO: add BN finder count IF you're re-adding QA info