Updated types
This commit is contained in:
@@ -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()
|
||||
deleteCommands()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})()
|
||||
})()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})()
|
||||
})()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"))
|
||||
// })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user