From 9050eff5a55b1dfca3e9e61c376387c475851666 Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 26 Aug 2024 22:29:37 +0200 Subject: [PATCH] Updated types --- scripts/delete-commands.ts | 6 +++--- scripts/deploy-commands.ts | 6 +++--- scripts/dev-deploy.ts | 6 +++--- src/interfaces/IEnv.ts | 20 ++++++++++---------- src/utils/Autodeploy.ts | 2 +- src/utils/Client.ts | 6 +++--- src/utils/Env.ts | 20 ++++++++++---------- src/utils/Illegitimate.ts | 6 +++--- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/scripts/delete-commands.ts b/scripts/delete-commands.ts index d6851c7..c3b00e9 100644 --- a/scripts/delete-commands.ts +++ b/scripts/delete-commands.ts @@ -1,13 +1,13 @@ import { REST, Routes } from "discord.js" import env from "../src/utils/Env" -const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!) +const rest = new REST({ version: "10" }).setToken(env.dev.devtoken) async function deleteCommands() { try { console.log("Started deleting application (/) commands.") await rest.put( - Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!), + Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid), { body: [] }, ) console.log("Successfully deleted application (/) commands.") @@ -15,4 +15,4 @@ async function deleteCommands() { console.error(error) } } -deleteCommands() \ No newline at end of file +deleteCommands() diff --git a/scripts/deploy-commands.ts b/scripts/deploy-commands.ts index 9aea2f3..9294dea 100644 --- a/scripts/deploy-commands.ts +++ b/scripts/deploy-commands.ts @@ -3,7 +3,7 @@ import fs from "node:fs" import { ICommand } from "../src/interfaces" import env from "../src/utils/Env" import color from "../src/utils/functions/colors" -const rest = new REST({ version: "10" }).setToken(env.prod.token!) +const rest = new REST({ version: "10" }).setToken(env.prod.token) const commands: RESTPutAPIApplicationCommandsJSONBody = [] const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWith(".ts")) @@ -26,7 +26,7 @@ for (const file of contentMenuCommands) { console.log(color(commandsString.join("\n"), "lavender")) await rest.put( - Routes.applicationCommands(env.dev.clientid!), + Routes.applicationCommands(env.dev.clientid), { body: commands }, ).then(() => { console.log(color(`Successfully reloaded ${commands.length} application (/) commands.`, "green")) @@ -36,4 +36,4 @@ for (const file of contentMenuCommands) { } catch (error) { console.error(error) } -})() \ No newline at end of file +})() diff --git a/scripts/dev-deploy.ts b/scripts/dev-deploy.ts index 703d9cf..506e813 100644 --- a/scripts/dev-deploy.ts +++ b/scripts/dev-deploy.ts @@ -2,7 +2,7 @@ import { REST, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js" import fs from "fs" import env from "../src/utils/Env" import { ICommand } from "../src/interfaces" -const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!) +const rest = new REST({ version: "10" }).setToken(env.dev.devtoken) const commands: RESTPutAPIApplicationCommandsJSONBody = [] const commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(".ts")) @@ -26,7 +26,7 @@ for (const file of contentMenuCommands) { console.log(`Started refreshing ${commands.length} application (/) commands.`) await rest.put( - Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!), + Routes.applicationGuildCommands(env.dev.devid, env.dev.guildid), { body: commands }, ).then(() => { console.log(`Successfully reloaded ${commands.length} application (/) commands.`) @@ -35,4 +35,4 @@ for (const file of contentMenuCommands) { } catch (error) { console.error(error) } -})() \ No newline at end of file +})() diff --git a/src/interfaces/IEnv.ts b/src/interfaces/IEnv.ts index 11e9dea..5851d13 100644 --- a/src/interfaces/IEnv.ts +++ b/src/interfaces/IEnv.ts @@ -1,17 +1,17 @@ interface ProdEnv { - token: string | undefined - mongoURI: string | undefined - dev: string | undefined - hypixelapikey: string | undefined - redisURI: string | undefined - postgresURI: string | undefined + token: string + mongoURI: string + dev: string + hypixelapikey: string + redisURI: string + postgresURI: string } interface DevEnv { - devtoken: string | undefined - clientid: string | undefined - devid: string | undefined - guildid: string | undefined + devtoken: string + clientid: string + devid: string + guildid: string } export default interface IEnv { diff --git a/src/utils/Autodeploy.ts b/src/utils/Autodeploy.ts index e27f20c..ef96f1b 100644 --- a/src/utils/Autodeploy.ts +++ b/src/utils/Autodeploy.ts @@ -44,7 +44,7 @@ export default async function autoDeployCommands(fileType: FileType, client: Ext }).sort((a, b) => a.name > b.name ? 1 : -1) client.on("ready", async (c) => { - const guildclient = c.guilds.cache.get(env.dev.guildid!)! + const guildclient = c.guilds.cache.get(env.dev.guildid)! const currentCommands = await guildclient.commands.fetch() if (!currentCommands) return diff --git a/src/utils/Client.ts b/src/utils/Client.ts index 047eb7c..466440b 100644 --- a/src/utils/Client.ts +++ b/src/utils/Client.ts @@ -34,15 +34,15 @@ export class ExtendedClient extends Client { let token: string if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") { console.log(color("Running in development mode. [ts-node]", "lavender")) - token = env.dev.devtoken! + token = env.dev.devtoken autoDeployCommands("ts", this) } else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) { console.log(color("Running in development mode.", "lavender")) - token = env.dev.devtoken! + token = env.dev.devtoken autoDeployCommands("js", this) } else { console.log(color("Running in production mode.", "green")) - token = env.prod.token! + token = env.prod.token } this.login(token) diff --git a/src/utils/Env.ts b/src/utils/Env.ts index f166f06..226a5f6 100644 --- a/src/utils/Env.ts +++ b/src/utils/Env.ts @@ -3,18 +3,18 @@ import "dotenv/config" const env: IEnv = { prod: { - token: process.env.TOKEN, - mongoURI: process.env.MONGOURI, - dev: process.env.DEV, - hypixelapikey: process.env.HYPIXELAPIKEY, - redisURI: process.env.REDISURI, - postgresURI: process.env.POSTGRESURI + token: process.env.TOKEN!, + mongoURI: process.env.MONGOURI!, + dev: process.env.DEV!, + hypixelapikey: process.env.HYPIXELAPIKEY!, + redisURI: process.env.REDISURI!, + postgresURI: process.env.POSTGRESURI! }, dev: { - devtoken: process.env.DEVTOKEN, - clientid: process.env.CLIENTID, - devid: process.env.DEVID, - guildid: process.env.GUILDID, + devtoken: process.env.DEVTOKEN!, + clientid: process.env.CLIENTID!, + devid: process.env.DEVID!, + guildid: process.env.GUILDID! } } diff --git a/src/utils/Illegitimate.ts b/src/utils/Illegitimate.ts index 8c1a6fc..830cdcc 100644 --- a/src/utils/Illegitimate.ts +++ b/src/utils/Illegitimate.ts @@ -9,7 +9,7 @@ import { Sequelize } from "sequelize" import { YoutubeiExtractor } from "discord-player-youtubei" const client = new Client() -const redis = new Redis(env.prod.redisURI!) +const redis = new Redis(env.prod.redisURI) const player = new Player(client) let sequelize: Sequelize @@ -19,7 +19,7 @@ if (process.env.NODE_ENV === "dev") { storage: "data/db.sqlite" }) } else { - sequelize = new Sequelize(env.prod.postgresURI!, { dialect: "postgres" }) + sequelize = new Sequelize(env.prod.postgresURI, { dialect: "postgres" }) } let ft: "js" | "ts" @@ -49,7 +49,7 @@ class Illegitimate { console.log(color("Synced the db [dev]", "green")) }) } - // connect(env.prod.mongoURI!, {}).then(() => { + // connect(env.prod.mongoURI, {}).then(() => { // console.log(color("Connected to MongoDB", "green")) // }) }