49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { DefaultExtractors } from "@discord-player/extractor"
|
|
import { Player } from "discord-player"
|
|
import { YoutubeiExtractor } from "discord-player-youtubei"
|
|
import { Redis } from "ioredis"
|
|
import { ExtendedClient as Client } from "~/utils/Client.js"
|
|
import env from "~/utils/Env.js"
|
|
import loadAllEvents from "./Events/loadevents.js"
|
|
import { log } from "./Logger.js"
|
|
|
|
const client = new Client()
|
|
const redis = new Redis(env.prod.redisURI)
|
|
const player = new Player(client)
|
|
|
|
let ft: "js" | "ts"
|
|
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
|
|
ft = "ts"
|
|
} else {
|
|
ft = "js"
|
|
}
|
|
|
|
class Illegitimate {
|
|
async start() {
|
|
await loadAllEvents(client, ft)
|
|
await player.extractors.loadMulti(DefaultExtractors)
|
|
await player.extractors.register(YoutubeiExtractor, {})
|
|
await client.start()
|
|
await this.databases()
|
|
this.loadMethods()
|
|
}
|
|
|
|
private async databases() {
|
|
redis.on("ready", () => {
|
|
log("Connected to Redis", "info", { type: "preset", color: "green" })
|
|
})
|
|
}
|
|
|
|
private loadMethods() {
|
|
String.prototype.removeIndents = function(this: string) {
|
|
return this.replace(/^ */gm, "")
|
|
}
|
|
|
|
String.prototype.capitalizeFirstLetter = function(this: string) {
|
|
return this[0].toUpperCase() + this.slice(1).toLowerCase()
|
|
}
|
|
}
|
|
}
|
|
|
|
export { client, Illegitimate, redis }
|