Merge branch 'dev' into 'main'
Added new init function See merge request illegitimate/illegitimate-bot!140
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
interface ProdConfig {
|
interface ProdConfig {
|
||||||
token: string
|
token: string | undefined
|
||||||
mongoURI: string
|
mongoURI: string | undefined
|
||||||
dev: string
|
dev: string | undefined
|
||||||
hypixelapikey: string
|
hypixelapikey: string | undefined
|
||||||
redisURI: string
|
redisURI: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DevConfig {
|
interface DevConfig {
|
||||||
devtoken: string
|
devtoken: string | undefined
|
||||||
clientid: string
|
clientid: string | undefined
|
||||||
devid: string
|
devid: string | undefined
|
||||||
guildid: string
|
guildid: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export default interface Config {
|
export default interface Config {
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ async function autoDeployCommands() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken)
|
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken!)
|
||||||
|
|
||||||
const currentCommands = (await rest.get(
|
const currentCommands = (await rest.get(
|
||||||
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid),
|
Routes.applicationGuildCommands(config.dev.devid!, config.dev.guildid!),
|
||||||
)) as RESTGetAPIApplicationGuildCommandResult[]
|
)) as RESTGetAPIApplicationGuildCommandResult[]
|
||||||
|
|
||||||
const currentCommandsInfo = currentCommands.map(command => {
|
const currentCommandsInfo = currentCommands.map(command => {
|
||||||
@@ -94,8 +94,8 @@ async function autoDeployCommands() {
|
|||||||
|
|
||||||
const data = (await rest.put(
|
const data = (await rest.put(
|
||||||
Routes.applicationGuildCommands(
|
Routes.applicationGuildCommands(
|
||||||
config.dev.devid,
|
config.dev.devid!,
|
||||||
config.dev.guildid,
|
config.dev.guildid!,
|
||||||
),
|
),
|
||||||
{ body: commands },
|
{ body: commands },
|
||||||
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
|
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ export class ExtendedClient extends Client {
|
|||||||
let token: string
|
let token: string
|
||||||
if (process.env.NODE_ENV === "dev") {
|
if (process.env.NODE_ENV === "dev") {
|
||||||
console.log("Running in development mode.")
|
console.log("Running in development mode.")
|
||||||
token = config.dev.devtoken
|
token = config.dev.devtoken!
|
||||||
autoDeployCommands()
|
autoDeployCommands()
|
||||||
} else {
|
} else {
|
||||||
console.log("Running in production mode.")
|
console.log("Running in production mode.")
|
||||||
token = config.prod.token
|
token = config.prod.token!
|
||||||
}
|
}
|
||||||
|
|
||||||
this.login(token)
|
this.login(token)
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import "dotenv/config"
|
|||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
prod: {
|
prod: {
|
||||||
token: process.env.TOKEN!,
|
token: process.env.TOKEN,
|
||||||
mongoURI: process.env.MONGOURI!,
|
mongoURI: process.env.MONGOURI,
|
||||||
dev: process.env.DEV!,
|
dev: process.env.DEV,
|
||||||
hypixelapikey: process.env.HYPIXELAPIKEY!,
|
hypixelapikey: process.env.HYPIXELAPIKEY,
|
||||||
redisURI: process.env.REDISURI!,
|
redisURI: process.env.REDISURI,
|
||||||
},
|
},
|
||||||
dev: {
|
dev: {
|
||||||
devtoken: process.env.DEVTOKEN!,
|
devtoken: process.env.DEVTOKEN,
|
||||||
clientid: process.env.CLIENTID!,
|
clientid: process.env.CLIENTID,
|
||||||
devid: process.env.DEVID!,
|
devid: process.env.DEVID,
|
||||||
guildid: process.env.GUILDID!,
|
guildid: process.env.GUILDID,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { ExtendedClient as Client } from "./Client"
|
|||||||
import config from "./Config"
|
import config from "./Config"
|
||||||
import { redis } from "./Redis"
|
import { redis } from "./Redis"
|
||||||
import { connect } from "mongoose"
|
import { connect } from "mongoose"
|
||||||
// import init from "./Init"
|
import init from "./Init"
|
||||||
const client = new Client()
|
const client = new Client()
|
||||||
|
|
||||||
export default class Illegitimate {
|
export default class Illegitimate {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
// init()
|
init()
|
||||||
|
|
||||||
client.start()
|
client.start()
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ export default class Illegitimate {
|
|||||||
console.log("Connected to Redis")
|
console.log("Connected to Redis")
|
||||||
})
|
})
|
||||||
|
|
||||||
connect(config.prod.mongoURI, {}).then(() => {
|
connect(config.prod.mongoURI!, {}).then(() => {
|
||||||
console.log("Connected to MongoDB")
|
console.log("Connected to MongoDB")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,22 +5,17 @@ const devValues = config.dev
|
|||||||
|
|
||||||
export default function init() {
|
export default function init() {
|
||||||
if (process.env.NODE_ENV === "dev") {
|
if (process.env.NODE_ENV === "dev") {
|
||||||
Object.keys(devValues).forEach(key => {
|
for (const [key, value] of Object.entries(devValues)) {
|
||||||
if (!process.env[key.toUpperCase()]) {
|
if (!value) throw new Error(`No ${key} specified`)
|
||||||
throw new Error(`[DEV] Missing environment variable: ${key}`)
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Object.keys(prodValues).forEach(key => {
|
for (const [key, value] of Object.entries(prodValues)) {
|
||||||
if (!process.env[key.toUpperCase()]) {
|
if (!value) throw new Error(`No ${key} specified`)
|
||||||
throw new Error(`[PROD] Missing environment variable: ${key}`)
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Object.keys(prodValues).forEach(key => {
|
for (const [key, value] of Object.entries(prodValues)) {
|
||||||
if (!process.env[key]) {
|
if (!value) throw new Error(`No ${key} specified`)
|
||||||
throw new Error(`[PROD] Missing environment variable: ${key}`)
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Redis } from "ioredis"
|
import { Redis } from "ioredis"
|
||||||
import config from "./Config"
|
import config from "./Config"
|
||||||
|
|
||||||
const redis = new Redis(config.prod.redisURI)
|
const redis = new Redis(config.prod.redisURI!)
|
||||||
|
|
||||||
export { redis }
|
export { redis }
|
||||||
|
|||||||
Reference in New Issue
Block a user