From 5e6e8b3823f045f662aa109f3379534457cdf1f3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Sat, 30 Apr 2022 16:59:58 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20remove=20all=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/shop/modules/pterodactyl.ts | 26 +------------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/plugins/shop/modules/pterodactyl.ts b/src/plugins/shop/modules/pterodactyl.ts index 9ada9fb..6aeed22 100644 --- a/src/plugins/shop/modules/pterodactyl.ts +++ b/src/plugins/shop/modules/pterodactyl.ts @@ -1,9 +1,7 @@ -// Dependencies import { CommandInteraction } from "discord.js"; import { v4 as uuidv4 } from "uuid"; import axios from "axios"; -// Configurations import { successColor, errorColor, @@ -11,19 +9,15 @@ import { footerIcon, } from "@config/embed"; -// Handlers import logger from "@logger"; import encryption from "@handlers/encryption"; -// Helpers import pluralize from "@helpers/pluralize"; -// Models import apiSchema from "@schemas/api"; import fetchUser from "@helpers/fetchUser"; import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; -// Function export default { meta: { guildOnly: true, ephemeral: true }, @@ -40,10 +34,8 @@ export default { execute: async (interaction: CommandInteraction) => { const { options, guild, user, client } = interaction; - // Get options const optionAmount = options?.getInteger("amount"); - // If amount is null if (optionAmount === null) { logger?.verbose(`Amount is null.`); @@ -67,17 +59,14 @@ export default { return logger?.verbose(`Guild is null`); } - // Get user object const userDB = await fetchUser(user, guild); if (userDB === null) { return logger?.verbose(`User is null`); } - // Get DM user object const dmUser = client?.users?.cache?.get(user?.id); - // Stop if amount or user credits is below 100 if ((optionAmount || userDB?.credits) < 100) { logger?.verbose(`Amount or user credits is below 100.`); @@ -103,7 +92,6 @@ export default { }); } - // Stop if amount or user credits is above 1.000.000 if ((optionAmount || userDB?.credits) > 1000000) { logger?.verbose(`Amount or user credits is above 1.000.000.`); @@ -130,7 +118,6 @@ export default { }); } - // Stop if user credits is below amount if (userDB?.credits < optionAmount) { logger?.verbose(`User credits is below amount.`); @@ -156,15 +143,12 @@ export default { }); } - // Generate a unique voucher for the user const code = uuidv4(); - // Get api object const apiCredentials = await apiSchema?.findOne({ guildId: guild?.id, }); - // Create a api instance const api = axios?.create({ baseURL: apiCredentials?.url, headers: { @@ -172,13 +156,10 @@ export default { }, }); - // Get shop URL const shopUrl = apiCredentials?.url?.replace("/api", "/store"); - // Make API request await api - // Make a post request to the API ?.post("vouchers", { uses: 1, code, @@ -186,17 +167,14 @@ export default { memo: `${interaction?.createdTimestamp} - ${interaction?.user?.id}`, }) - // If successful ?.then(async () => { logger?.verbose(`Successfully created voucher.`); - // Withdraw amount from user credits userDB.credits -= optionAmount || userDB?.credits; - // Save new credits await userDB ?.save() - // If successful + ?.then(async () => { logger?.verbose(`Successfully saved new credits.`); @@ -239,7 +217,6 @@ export default { }); }) - // If error occurs .catch(async (error) => { logger?.verbose(`Error saving new credits. - ${error}`); @@ -260,7 +237,6 @@ export default { }); }) - // If error occurs .catch(async (error: any) => { logger?.verbose(`Error creating voucher. - ${error}`);