diff --git a/src/index.ts b/src/index.ts index 4f1efba..ec86855 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import "dotenv/config"; import { Client, Collection, GatewayIntentBits } from "discord.js"; // discord.js +import "dotenv/config"; import * as managers from "./managers"; diff --git a/src/plugins/commands/config/modules/audits/index.ts b/src/plugins/commands/config/modules/audits/index.ts index b7f14ad..b440562 100644 --- a/src/plugins/commands/config/modules/audits/index.ts +++ b/src/plugins/commands/config/modules/audits/index.ts @@ -8,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/cpgg/index.ts b/src/plugins/commands/config/modules/cpgg/index.ts index 3cc4731..80caa14 100644 --- a/src/plugins/commands/config/modules/cpgg/index.ts +++ b/src/plugins/commands/config/modules/cpgg/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import apiSchema from "../../../../../models/api"; -import encryption from "../../../../../handlers/encryption"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import encryption from "../../../../../handlers/encryption"; +import apiSchema from "../../../../../models/api"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/credits/index.ts b/src/plugins/commands/config/modules/credits/index.ts index 3d67301..4535d74 100644 --- a/src/plugins/commands/config/modules/credits/index.ts +++ b/src/plugins/commands/config/modules/credits/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts index f8decdd..bc49e1f 100644 --- a/src/plugins/commands/config/modules/embeds/components/getValues/index.ts +++ b/src/plugins/commands/config/modules/embeds/components/getValues/index.ts @@ -1,10 +1,6 @@ -import { - ChatInputCommandInteraction, - ColorResolvable, - CommandInteraction, -} from "discord.js"; -import guildSchema from "../../../../../../../models/guild"; +import { ChatInputCommandInteraction, ColorResolvable } from "discord.js"; import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; +import guildSchema from "../../../../../../../models/guild"; export default async (interaction: ChatInputCommandInteraction) => { const { options, guild } = interaction; diff --git a/src/plugins/commands/config/modules/embeds/index.ts b/src/plugins/commands/config/modules/embeds/index.ts index f868f49..3e667c6 100644 --- a/src/plugins/commands/config/modules/embeds/index.ts +++ b/src/plugins/commands/config/modules/embeds/index.ts @@ -1,16 +1,11 @@ import { - ColorResolvable, ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; -import logger from "../../../../../middlewares/logger"; - -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import guildSchema from "../../../../../models/guild"; import getValues from "./components/getValues"; export default { diff --git a/src/plugins/commands/config/modules/index.ts b/src/plugins/commands/config/modules/index.ts index 45d8a9f..7d8ba77 100644 --- a/src/plugins/commands/config/modules/index.ts +++ b/src/plugins/commands/config/modules/index.ts @@ -1,9 +1,9 @@ import audits from "./audits"; -import credits from "./credits"; -import points from "./points"; import cpgg from "./cpgg"; +import credits from "./credits"; +import embeds from "./embeds"; +import points from "./points"; import shop from "./shop"; import welcome from "./welcome"; -import embeds from "./embeds"; export default { audits, credits, points, cpgg, shop, welcome, embeds }; diff --git a/src/plugins/commands/config/modules/points/index.ts b/src/plugins/commands/config/modules/points/index.ts index e1a0704..9b73eb1 100644 --- a/src/plugins/commands/config/modules/points/index.ts +++ b/src/plugins/commands/config/modules/points/index.ts @@ -1,7 +1,6 @@ import { ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -9,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/shop/index.ts b/src/plugins/commands/config/modules/shop/index.ts index 8624b26..0e10d9f 100644 --- a/src/plugins/commands/config/modules/shop/index.ts +++ b/src/plugins/commands/config/modules/shop/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,8 +8,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/config/modules/welcome/index.ts b/src/plugins/commands/config/modules/welcome/index.ts index cd55b16..919711e 100644 --- a/src/plugins/commands/config/modules/welcome/index.ts +++ b/src/plugins/commands/config/modules/welcome/index.ts @@ -1,8 +1,6 @@ import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -10,9 +8,9 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import guildSchema from "../../../../../models/guild"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import guildSchema from "../../../../../models/guild"; export default { metadata: { diff --git a/src/plugins/commands/counters/index.ts b/src/plugins/commands/counters/index.ts index 9626b99..eb1e4f3 100644 --- a/src/plugins/commands/counters/index.ts +++ b/src/plugins/commands/counters/index.ts @@ -1,5 +1,5 @@ -import { CommandInteraction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "../../commands/counters/modules"; @@ -11,7 +11,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "view") { await modules.view.execute(interaction); } diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 695008d..81e1147 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -1,8 +1,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import counterSchema from "../../../../../models/counter"; diff --git a/src/plugins/commands/credits/index.ts b/src/plugins/commands/credits/index.ts index 6af41f7..4e30065 100644 --- a/src/plugins/commands/credits/index.ts +++ b/src/plugins/commands/credits/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../middlewares/logger"; import modules from "./modules"; @@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; switch (options.getSubcommand()) { diff --git a/src/plugins/commands/credits/modules/balance/index.ts b/src/plugins/commands/credits/modules/balance/index.ts index 0bef3a7..57afd75 100644 --- a/src/plugins/commands/credits/modules/balance/index.ts +++ b/src/plugins/commands/credits/modules/balance/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import logger from "../../../../../middlewares/logger"; import fetchUser from "../../../../../helpers/fetchUser"; diff --git a/src/plugins/commands/credits/modules/gift/index.ts b/src/plugins/commands/credits/modules/gift/index.ts index 7272ec2..fba20f1 100644 --- a/src/plugins/commands/credits/modules/gift/index.ts +++ b/src/plugins/commands/credits/modules/gift/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -10,8 +10,8 @@ import logger from "../../../../../middlewares/logger"; import mongoose from "mongoose"; // Models -import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../helpers/fetchUser"; // Function export default { @@ -37,7 +37,7 @@ export default { option.setName("reason").setDescription("Your reason.") ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, user, guild, client } = interaction; diff --git a/src/plugins/commands/credits/modules/top/index.ts b/src/plugins/commands/credits/modules/top/index.ts index 53b386e..6c3bec7 100644 --- a/src/plugins/commands/credits/modules/top/index.ts +++ b/src/plugins/commands/credits/modules/top/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; import logger from "../../../../../middlewares/logger"; import userSchema, { IUser } from "../../../../../models/user"; diff --git a/src/plugins/commands/credits/modules/work/index.ts b/src/plugins/commands/credits/modules/work/index.ts index 185a8d5..5354752 100644 --- a/src/plugins/commands/credits/modules/work/index.ts +++ b/src/plugins/commands/credits/modules/work/index.ts @@ -1,7 +1,7 @@ // Dependencies -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import Chance from "chance"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -13,8 +13,8 @@ import logger from "../../../../../middlewares/logger"; import * as cooldown from "../../../../../helpers/cooldown"; // Helpers -import fetchUser from "../../../../../helpers/fetchUser"; import fetchGuild from "../../../../../helpers/fetchGuild"; +import fetchUser from "../../../../../helpers/fetchUser"; export default { metadata: { guildOnly: true, ephemeral: true }, diff --git a/src/plugins/commands/dns/index.ts b/src/plugins/commands/dns/index.ts index ee623ec..abfb718 100644 --- a/src/plugins/commands/dns/index.ts +++ b/src/plugins/commands/dns/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.lookup.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "lookup": return modules.lookup.execute(interaction); diff --git a/src/plugins/commands/dns/modules/lookup/index.ts b/src/plugins/commands/dns/modules/lookup/index.ts index f3d443d..54635e1 100644 --- a/src/plugins/commands/dns/modules/lookup/index.ts +++ b/src/plugins/commands/dns/modules/lookup/index.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -21,7 +21,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const embedTitle = "[:hammer:] Utility (Lookup)"; diff --git a/src/plugins/commands/fun/index.ts b/src/plugins/commands/fun/index.ts index 3c546ed..7b0d4ba 100644 --- a/src/plugins/commands/fun/index.ts +++ b/src/plugins/commands/fun/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../middlewares/logger"; import modules from "../../commands/fun/modules"; @@ -12,7 +12,7 @@ export const builder = new SlashCommandBuilder() export const moduleData = modules; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options.getSubcommand() === "meme") { diff --git a/src/plugins/commands/fun/modules/meme/index.ts b/src/plugins/commands/fun/modules/meme/index.ts index a374ee9..9ad5a48 100644 --- a/src/plugins/commands/fun/modules/meme/index.ts +++ b/src/plugins/commands/fun/modules/meme/index.ts @@ -1,8 +1,7 @@ -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import axios from "axios"; import { CommandInteraction, EmbedBuilder } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; export default { metadata: { guildOnly: false, ephemeral: false, cooldown: 15 }, diff --git a/src/plugins/commands/manage/index.ts b/src/plugins/commands/manage/index.ts index 1b61f39..01b6508 100644 --- a/src/plugins/commands/manage/index.ts +++ b/src/plugins/commands/manage/index.ts @@ -1,6 +1,6 @@ //Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Groups import modules from "../../commands/manage/modules"; @@ -14,7 +14,7 @@ export const builder = new SlashCommandBuilder() .addSubcommandGroup(modules.counters.builder) .addSubcommandGroup(modules.credits.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { // Destructure const { options } = interaction; diff --git a/src/plugins/commands/manage/modules/counters/index.ts b/src/plugins/commands/manage/modules/counters/index.ts index a6f351d..04580e5 100644 --- a/src/plugins/commands/manage/modules/counters/index.ts +++ b/src/plugins/commands/manage/modules/counters/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { ChatInputCommandInteraction, CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import logger from "../../../../../middlewares/logger"; diff --git a/src/plugins/commands/manage/modules/counters/modules/add/index.ts b/src/plugins/commands/manage/modules/counters/modules/add/index.ts index c1b022f..2b95f9a 100644 --- a/src/plugins/commands/manage/modules/counters/modules/add/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/add/index.ts @@ -1,11 +1,11 @@ // Dependencies -import { - EmbedBuilder, - ChatInputCommandInteraction, - PermissionsBitField, -} from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + PermissionsBitField, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts index 018ae94..096fda7 100644 --- a/src/plugins/commands/manage/modules/counters/modules/remove/index.ts +++ b/src/plugins/commands/manage/modules/counters/modules/remove/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -14,9 +12,9 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; import logger from "../../../../../../../middlewares/logger"; // Models -import counterSchema from "../../../../../../../models/counter"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; +import counterSchema from "../../../../../../../models/counter"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/index.ts b/src/plugins/commands/manage/modules/credits/index.ts index 92efd12..0ed9837 100644 --- a/src/plugins/commands/manage/modules/credits/index.ts +++ b/src/plugins/commands/manage/modules/credits/index.ts @@ -1,5 +1,5 @@ -import { CommandInteraction } from "discord.js"; import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; @@ -16,7 +16,7 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.giveaway.builder); }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "give": return modules.give.execute(interaction); diff --git a/src/plugins/commands/manage/modules/credits/modules/give/index.ts b/src/plugins/commands/manage/modules/credits/modules/give/index.ts index 2eadb62..e797afd 100644 --- a/src/plugins/commands/manage/modules/credits/modules/give/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/give/index.ts @@ -1,12 +1,10 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts index 6d8decc..246b00a 100644 --- a/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/giveaway/index.ts @@ -1,18 +1,16 @@ // Dependencies +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import axios from "axios"; import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, - EmbedBuilder, - Permissions, - PermissionsBitField, ChatInputCommandInteraction, + EmbedBuilder, + PermissionsBitField, } from "discord.js"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { v4 as uuidv4 } from "uuid"; -import axios from "axios"; -import apiSchema from "../../../../../../../models/api"; import encryption from "../../../../../../../handlers/encryption"; +import apiSchema from "../../../../../../../models/api"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; diff --git a/src/plugins/commands/manage/modules/credits/modules/index.ts b/src/plugins/commands/manage/modules/credits/modules/index.ts index 96acc29..c82650d 100644 --- a/src/plugins/commands/manage/modules/credits/modules/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/index.ts @@ -1,7 +1,7 @@ import give from "./give"; +import giveaway from "./giveaway"; import set from "./set"; import take from "./take"; import transfer from "./transfer"; -import giveaway from "./giveaway"; export default { give, set, take, transfer, giveaway }; diff --git a/src/plugins/commands/manage/modules/credits/modules/set/index.ts b/src/plugins/commands/manage/modules/credits/modules/set/index.ts index 57de608..9e2a63c 100644 --- a/src/plugins/commands/manage/modules/credits/modules/set/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/set/index.ts @@ -1,8 +1,7 @@ // Dependencies import { - CommandInteraction, + ChatInputCommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -15,8 +14,8 @@ import logger from "../../../../../../../middlewares/logger"; // Helpers // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/take/index.ts b/src/plugins/commands/manage/modules/credits/modules/take/index.ts index b2dae44..707a149 100644 --- a/src/plugins/commands/manage/modules/credits/modules/take/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/take/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -17,8 +15,8 @@ import logger from "../../../../../../../middlewares/logger"; import pluralize from "../../../../../../../helpers/pluralize"; // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts index 0108f26..e8a1c00 100644 --- a/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts +++ b/src/plugins/commands/manage/modules/credits/modules/transfer/index.ts @@ -1,9 +1,7 @@ // Dependencies import { ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -16,8 +14,8 @@ import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; import logger from "../../../../../../../middlewares/logger"; // Models -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; // Function export default { diff --git a/src/plugins/commands/moderation/index.ts b/src/plugins/commands/moderation/index.ts index 73b4994..c9a2bec 100644 --- a/src/plugins/commands/moderation/index.ts +++ b/src/plugins/commands/moderation/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -10,7 +10,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.prune.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "prune": return modules.prune.execute(interaction); diff --git a/src/plugins/commands/moderation/modules/prune/index.ts b/src/plugins/commands/moderation/modules/prune/index.ts index 9745ca0..8abc31b 100644 --- a/src/plugins/commands/moderation/modules/prune/index.ts +++ b/src/plugins/commands/moderation/modules/prune/index.ts @@ -2,9 +2,7 @@ import { ChannelType, ChatInputCommandInteraction, - CommandInteraction, EmbedBuilder, - Permissions, PermissionsBitField, } from "discord.js"; @@ -36,8 +34,9 @@ export default { ); }, execute: async (interaction: ChatInputCommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + const { errorColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const count = interaction.options.getInteger("count"); if (count == null) return; diff --git a/src/plugins/commands/profile/index.ts b/src/plugins/commands/profile/index.ts index eeec469..3a9305e 100644 --- a/src/plugins/commands/profile/index.ts +++ b/src/plugins/commands/profile/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "../../commands/profile/modules"; @@ -16,7 +16,7 @@ export const builder = new SlashCommandBuilder() .setDescription("Check a profile.") .addSubcommand(modules.view.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "view") { diff --git a/src/plugins/commands/profile/modules/view/index.ts b/src/plugins/commands/profile/modules/view/index.ts index bee47bc..fe4474b 100644 --- a/src/plugins/commands/profile/modules/view/index.ts +++ b/src/plugins/commands/profile/modules/view/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -7,8 +7,8 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Models import fetchUser from "../../../../../helpers/fetchUser"; -import logger from "../../../../../middlewares/logger"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import logger from "../../../../../middlewares/logger"; // Function export default { @@ -24,7 +24,7 @@ export default { }, execute: async (interaction: CommandInteraction) => { - const { successColor, footerText, footerIcon } = await getEmbedConfig( + const { errorColor, footerText, footerIcon } = await getEmbedConfig( interaction.guild ); // Destructure const { client, options, user, guild } = interaction; @@ -44,14 +44,12 @@ export default { // User Information const userObj = await fetchUser(discordUser, guild); - // Embed object - const embed = { - author: { + const embed = new EmbedBuilder() + .setAuthor({ name: `${discordUser?.username}#${discordUser?.discriminator}`, - icon_url: discordUser?.displayAvatarURL(), - }, - color: successColor, - fields: [ + iconURL: discordUser?.displayAvatarURL(), + }) + .addFields( { name: `:dollar: Credits`, value: `${userObj?.credits || "Not found"}`, @@ -76,14 +74,11 @@ export default { name: `:rainbow_flag: Language`, value: `${userObj?.language || "Not found"}`, inline: true, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + } + ) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); // Return interaction reply return interaction?.editReply({ embeds: [embed] }); diff --git a/src/plugins/commands/reputation/index.ts b/src/plugins/commands/reputation/index.ts index d667343..3a4fd77 100644 --- a/src/plugins/commands/reputation/index.ts +++ b/src/plugins/commands/reputation/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "./modules"; @@ -15,7 +15,7 @@ export const builder = new SlashCommandBuilder() .setDescription("Manage reputation.") .addSubcommand(modules.give.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.options.getSubcommand() === "give") { await modules.give.execute(interaction); } diff --git a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts index f6a6778..dc0be04 100644 --- a/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts +++ b/src/plugins/commands/reputation/modules/give/components/noSelfReputation.ts @@ -1,4 +1,5 @@ import { User } from "discord.js"; + export default async (to: User | null, from: User | null) => { if (from?.id === to?.id) { throw new Error("You cannot give reputation to yourself."); diff --git a/src/plugins/commands/reputation/modules/give/index.ts b/src/plugins/commands/reputation/modules/give/index.ts index 1eb8c0b..7faa784 100644 --- a/src/plugins/commands/reputation/modules/give/index.ts +++ b/src/plugins/commands/reputation/modules/give/index.ts @@ -1,9 +1,9 @@ -import { CommandInteraction } from "discord.js"; +import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; +import * as cooldown from "../../../../../helpers/cooldown"; +import fetchUser from "../../../../../helpers/fetchUser"; import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; import logger from "../../../../../middlewares/logger"; -import fetchUser from "../../../../../helpers/fetchUser"; -import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -import * as cooldown from "../../../../../helpers/cooldown"; import noSelfReputation from "./components/noSelfReputation"; export default { @@ -33,7 +33,7 @@ export default { ) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { options, user, guild } = interaction; const { successColor, footerText, footerIcon } = await getEmbedConfig( @@ -68,19 +68,17 @@ export default { await userObj.save().then(async () => { logger.silly(`User reputation has been updated`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:loudspeaker:] Give") + .setDescription( + `You have given a ${optionType} repute to ${optionTarget}` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ - embeds: [ - { - title: "[:loudspeaker:] Give", - description: `You have given a ${optionType} repute to ${optionTarget}`, - timestamp: new Date(), - color: successColor, - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/shop/index.ts b/src/plugins/commands/shop/index.ts index 20fa7dd..5f6e0b6 100644 --- a/src/plugins/commands/shop/index.ts +++ b/src/plugins/commands/shop/index.ts @@ -1,6 +1,6 @@ // Dependencies import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Modules import modules from "./modules"; @@ -17,7 +17,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.cpgg.builder) .addSubcommandGroup(modules.roles.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { const { options } = interaction; if (options?.getSubcommand() === "cpgg") { diff --git a/src/plugins/commands/shop/modules/cpgg/index.ts b/src/plugins/commands/shop/modules/cpgg/index.ts index 5655d7a..c868e83 100644 --- a/src/plugins/commands/shop/modules/cpgg/index.ts +++ b/src/plugins/commands/shop/modules/cpgg/index.ts @@ -1,21 +1,22 @@ +import axios from "axios"; import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, + ButtonStyle, + ChatInputCommandInteraction, + EmbedBuilder, + Message, } from "discord.js"; import { v4 as uuidv4 } from "uuid"; -import axios from "axios"; -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; - -import logger from "../../../../../middlewares/logger"; import encryption from "../../../../../handlers/encryption"; +import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; +import logger from "../../../../../middlewares/logger"; -import pluralize from "../../../../../helpers/pluralize"; - -import apiSchema from "../../../../../models/api"; -import fetchUser from "../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../helpers/fetchUser"; +import pluralize from "../../../../../helpers/pluralize"; +import apiSchema from "../../../../../models/api"; export default { metadata: { guildOnly: true, ephemeral: true }, @@ -31,7 +32,7 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { + execute: async (interaction: ChatInputCommandInteraction) => { const { errorColor, successColor, footerText, footerIcon } = await getEmbedConfig(interaction.guild); const { options, guild, user, client } = interaction; @@ -41,19 +42,15 @@ export default { if (optionAmount === null) { logger?.silly(`Amount is null.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:dollar:] Gift") + .setDescription("We could not read your requested amount.") + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Credits [Gift]", - description: "We could not read your requested amount.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } @@ -72,76 +69,59 @@ export default { if ((optionAmount || userDB?.credits) < 100) { logger?.silly(`Amount or user credits is below 100.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription("You **can't** withdraw for __CPGG__ below **100**.") + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `You **can't** withdraw for __CPGG__ below **100**.`, - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } if ((optionAmount || userDB?.credits) > 1000000) { logger?.silly(`Amount or user credits is above 1.000.000.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + "You **can't** withdraw for __CPGG__ above **1.000.000**." + ) + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: - "You **can't** withdraw for __CPGG__ above **1.000.000**.", - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } if (userDB?.credits < optionAmount) { logger?.silly(`User credits is below amount.`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription("You have **insufficient** credits.") + .setTimestamp() + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `You have **insufficient** credits.`, - color: errorColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); } @@ -163,10 +143,10 @@ export default { const shopUrl = `${url}/store`; - const buttons = new ActionRowBuilder().addComponents( + const buttons = new ActionRowBuilder().addComponents( new ButtonBuilder() .setLabel("Redeem it here") - .setStyle("LINK") + .setStyle(ButtonStyle.Link) .setEmoji("🏦") .setURL(`${shopUrl}?voucher=${code}`) ); @@ -193,43 +173,37 @@ export default { if (!interaction.guild) throw new Error("Guild is undefined"); + const dmEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + `This voucher comes from **${interaction.guild.name}**.` + ) + .setTimestamp() + .addFields({ + name: "💶 Credits", + value: `${optionAmount || userDB?.credits}`, + inline: true, + }) + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await dmUser ?.send({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `This voucher comes from **${interaction.guild.name}**.`, - fields: [ - { - name: "💶 Credits", - value: `${optionAmount || userDB?.credits}`, - inline: true, - }, - ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [dmEmbed], components: [buttons], }) - .then(async (msg) => { + .then(async (msg: Message) => { + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription( + `I have sent you the code in [DM](${msg.url})!` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: `I have sent you the code in [DM](${msg.url})!`, - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }) @@ -237,19 +211,15 @@ export default { .catch(async (error) => { logger?.silly(`Error saving new credits. - ${error}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription(`Something went wrong.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: "Something went wrong.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }) @@ -257,19 +227,15 @@ export default { .catch(async (error) => { logger?.silly(`Error creating voucher. - ${error}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] CPGG") + .setDescription(`Something went wrong.`) + .setTimestamp() + .setColor(errorColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: "[:shopping_cart:] CPGG", - description: "Something went wrong.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }); }, diff --git a/src/plugins/commands/shop/modules/roles/index.ts b/src/plugins/commands/shop/modules/roles/index.ts index ed0c190..5f5d005 100644 --- a/src/plugins/commands/shop/modules/roles/index.ts +++ b/src/plugins/commands/shop/modules/roles/index.ts @@ -1,11 +1,8 @@ // Dependencies import { SlashCommandSubcommandGroupBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; // Handlers -import logger from "../../../../../middlewares/logger"; - -import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; // Modules import modules from "./modules"; @@ -23,11 +20,8 @@ export const builder = (group: SlashCommandSubcommandGroupBuilder) => { .addSubcommand(modules.cancel.builder); }; -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { if (interaction.guild == null) return; - const { errorColor, footerText, footerIcon } = await getEmbedConfig( - interaction.guild - ); const { options, guild } = interaction; const guildDB = await guildSchema?.findOne({ @@ -36,24 +30,8 @@ export const execute = async (interaction: CommandInteraction) => { if (guildDB === null) return; - if (!guildDB.shop.roles.status) { - logger.silly(`Shop roles disabled.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles", - description: "This server has disabled shop roles.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (!guildDB.shop.roles.status) + throw new Error("This server has disabled shop roles."); if (options?.getSubcommand() === "buy") { await modules.buy.execute(interaction); diff --git a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts index e9197f8..2ed7cdf 100644 --- a/src/plugins/commands/shop/modules/roles/modules/buy/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/buy/index.ts @@ -1,7 +1,8 @@ // Dependencies import { - CommandInteraction, + ChatInputCommandInteraction, ColorResolvable, + EmbedBuilder, GuildMemberRoleManager, } from "discord.js"; @@ -9,15 +10,15 @@ import { import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; // Models -import shopRolesSchema from "../../../../../../../models/shopRole"; import guildSchema from "../../../../../../../models/guild"; +import shopRolesSchema from "../../../../../../../models/shopRole"; import logger from "../../../../../../../middlewares/logger"; // Helpers -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; +import pluralize from "../../../../../../../helpers/pluralize"; // Function export default { @@ -40,33 +41,18 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + execute: async (interaction: ChatInputCommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild, user, member } = interaction; const optionName = options?.getString("name"); const optionColor = options?.getString("color"); // If amount is null - if (optionName === null) { - logger?.silly(`Name is null.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles [Buy]", - description: "We could not read your requested name.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (optionName === null) + throw new Error("We could not read your requested name"); await guild?.roles .create({ @@ -112,28 +98,20 @@ export default { logger?.silly(`Role ${role?.name} was bought by ${user?.tag}`); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Buy") + .setDescription( + `You bought **${optionName}** for **${pluralize( + pricePerHour, + "credit" + )}**.` + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":shopping_cart: Shop - Roles [Buy]", - description: `You bought **${optionName}** for **${pluralize( - pricePerHour, - "credit" - )}**.`, - color: successColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }) .catch(async (error) => { diff --git a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts index e983dd3..225b42a 100644 --- a/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts +++ b/src/plugins/commands/shop/modules/roles/modules/cancel/index.ts @@ -1,5 +1,9 @@ // Dependencies -import { CommandInteraction, GuildMemberRoleManager } from "discord.js"; +import { + ChatInputCommandInteraction, + EmbedBuilder, + GuildMemberRoleManager, +} from "discord.js"; // Configurations import getEmbedConfig from "../../../../../../../helpers/getEmbedConfig"; @@ -10,9 +14,9 @@ import shopRolesSchema from "../../../../../../../models/shopRole"; import logger from "../../../../../../../middlewares/logger"; // Helpers -import pluralize from "../../../../../../../helpers/pluralize"; -import fetchUser from "../../../../../../../helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import fetchUser from "../../../../../../../helpers/fetchUser"; +import pluralize from "../../../../../../../helpers/pluralize"; // Function export default { @@ -29,31 +33,16 @@ export default { .setRequired(true) ); }, - execute: async (interaction: CommandInteraction) => { - const { errorColor, successColor, footerText, footerIcon } = - await getEmbedConfig(interaction.guild); + execute: async (interaction: ChatInputCommandInteraction) => { + const { successColor, footerText, footerIcon } = await getEmbedConfig( + interaction.guild + ); const { options, guild, user, member } = interaction; const optionRole = options.getRole("role"); - if (optionRole === null) { - logger?.silly(`Role is null.`); - - return interaction?.editReply({ - embeds: [ - { - title: ":dollar: Shop - Roles [Cancel]", - description: "We could not read your requested role.", - color: errorColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], - }); - } + if (optionRole === null) + throw new Error("We could not read your requested role."); const roleExist = await shopRolesSchema?.findOne({ guildId: guild?.id, @@ -80,28 +69,22 @@ export default { guildId: guild?.id, }); + const interactionEmbed = new EmbedBuilder() + .setTitle("[:shopping_cart:] Cancel") + .setDescription(`You have canceled ${optionRole.name}.`) + .setTimestamp() + .setColor(successColor) + .addFields({ + name: "Your balance", + value: `${pluralize(userDB?.credits, "credit")}`, + }) + .setFooter({ text: footerText, iconURL: footerIcon }); + return interaction?.editReply({ - embeds: [ - { - title: ":shopping_cart: Shop - Roles [Cancel]", - description: `You have canceled ${optionRole.name}.`, - color: successColor, - fields: [ - { - name: "Your balance", - value: `${pluralize(userDB?.credits, "credit")}`, - }, - ], - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }, - ], + embeds: [interactionEmbed], }); }) - .catch(async (error) => { + .catch(async (error: Error) => { return logger?.silly(`Role could not be deleted. ${error}`); }); }, diff --git a/src/plugins/commands/utility/index.ts b/src/plugins/commands/utility/index.ts index 43da584..a10fde2 100644 --- a/src/plugins/commands/utility/index.ts +++ b/src/plugins/commands/utility/index.ts @@ -1,5 +1,5 @@ import { SlashCommandBuilder } from "@discordjs/builders"; -import { CommandInteraction } from "discord.js"; +import { ChatInputCommandInteraction } from "discord.js"; import modules from "./modules"; export const moduleData = modules; @@ -13,7 +13,7 @@ export const builder = new SlashCommandBuilder() .addSubcommand(modules.avatar.builder) .addSubcommand(modules.ping.builder); -export const execute = async (interaction: CommandInteraction) => { +export const execute = async (interaction: ChatInputCommandInteraction) => { switch (interaction.options.getSubcommand()) { case "about": return modules.about.execute(interaction); diff --git a/src/plugins/commands/utility/modules/about/index.ts b/src/plugins/commands/utility/modules/about/index.ts index 3dc1deb..6fee2f3 100644 --- a/src/plugins/commands/utility/modules/about/index.ts +++ b/src/plugins/commands/utility/modules/about/index.ts @@ -1,9 +1,9 @@ // Dependencies import { - CommandInteraction, ActionRowBuilder, ButtonBuilder, ButtonStyle, + CommandInteraction, EmbedBuilder, } from "discord.js"; diff --git a/src/plugins/commands/utility/modules/avatar/index.ts b/src/plugins/commands/utility/modules/avatar/index.ts index 3d69414..20f8edd 100644 --- a/src/plugins/commands/utility/modules/avatar/index.ts +++ b/src/plugins/commands/utility/modules/avatar/index.ts @@ -1,7 +1,7 @@ import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; -import { CommandInteraction, EmbedBuilder } from "discord.js"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; export default { metadata: { guildOnly: false, ephemeral: false }, diff --git a/src/plugins/commands/utility/modules/index.ts b/src/plugins/commands/utility/modules/index.ts index 33fa0f5..7383403 100644 --- a/src/plugins/commands/utility/modules/index.ts +++ b/src/plugins/commands/utility/modules/index.ts @@ -1,7 +1,7 @@ -import avatar from "./avatar"; import about from "./about"; -import stats from "./stats"; +import avatar from "./avatar"; import ping from "./ping"; +import stats from "./stats"; export default { avatar, diff --git a/src/plugins/commands/utility/modules/ping/index.ts b/src/plugins/commands/utility/modules/ping/index.ts index 420329e..96aee27 100644 --- a/src/plugins/commands/utility/modules/ping/index.ts +++ b/src/plugins/commands/utility/modules/ping/index.ts @@ -1,5 +1,5 @@ // Dependencies -import { CommandInteraction } from "discord.js"; +import { CommandInteraction, EmbedBuilder } from "discord.js"; // Configurations import getEmbedConfig from "../../../../../helpers/getEmbedConfig"; @@ -18,9 +18,9 @@ export default { interaction.guild ); - const interactionEmbed = { - title: "[:tools:] Ping", - fields: [ + const interactionEmbed = new EmbedBuilder() + .setTitle("[:tools:] Ping") + .addFields( { name: "📦 Deliver Latency", value: `${Math.abs(Date.now() - interaction.createdTimestamp)} ms`, @@ -30,15 +30,12 @@ export default { name: "🤖 API Latency", value: `${Math.round(interaction.client.ws.ping)} ms`, inline: true, - }, - ], - color: successColor, - timestamp: new Date(), - footer: { - iconURL: footerIcon, - text: footerText, - }, - }; + } + ) + .setTimestamp() + .setColor(successColor) + .setFooter({ text: footerText, iconURL: footerIcon }); + await interaction.editReply({ embeds: [interactionEmbed], }); diff --git a/src/types/common/environment.d.ts b/src/types/common/environment.d.ts index 4c1ee6c..bc18671 100644 --- a/src/types/common/environment.d.ts +++ b/src/types/common/environment.d.ts @@ -1,4 +1,4 @@ -import { Snowflake, ColorResolvable } from "discord.js"; +import { ColorResolvable, Snowflake } from "discord.js"; declare global { namespace NodeJS {