Merge branch 'dev' into 'main'
Docker workaround See merge request illegitimate/illegitimate-bot!350
This commit is contained in:
4
src/typings/General.ts
Normal file
4
src/typings/General.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export type LoadEventsOptions = {
|
||||||
|
ft: "ts" | "js"
|
||||||
|
dir: "src" | "dist" | ""
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ export * from "./Command"
|
|||||||
export * from "./ContextMenu"
|
export * from "./ContextMenu"
|
||||||
export * from "./Cron"
|
export * from "./Cron"
|
||||||
export * from "./Event"
|
export * from "./Event"
|
||||||
|
export * from "./General"
|
||||||
export * from "./Guild"
|
export * from "./Guild"
|
||||||
export * from "./Modal"
|
export * from "./Modal"
|
||||||
export * from "./Player"
|
export * from "./Player"
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Events } from "discord.js"
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { embedColor } from "~/config/options"
|
import { embedColor } from "~/config/options"
|
||||||
import { IAutocomplete } from "~/typings"
|
import { IAutocomplete, LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel"
|
import logToChannel from "~/utils/Functions/logtochannel"
|
||||||
import tryCatch from "../Functions/trycatch"
|
import tryCatch from "../Functions/trycatch"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
|
|
||||||
export default async function loadAutocompleteEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadAutocompleteEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const autocompletePath = path.join(process.cwd(), folder, "components", "autocomplete")
|
const autocompletePath = path.join(process.cwd(), dir, "components", "autocomplete")
|
||||||
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(`.${ft}`))
|
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of autocompleteFiles) {
|
for (const file of autocompleteFiles) {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Events, MessageFlags } from "discord.js"
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { embedColor } from "~/config/options"
|
import { embedColor } from "~/config/options"
|
||||||
import { IButton } from "~/typings"
|
import { IButton, LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel"
|
import logToChannel from "~/utils/Functions/logtochannel"
|
||||||
import tryCatch from "../Functions/trycatch"
|
import tryCatch from "../Functions/trycatch"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
|
|
||||||
export default async function loadButtonEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadButtonEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const btnPath = path.join(process.cwd(), folder, "components", "buttons")
|
const btnPath = path.join(process.cwd(), dir, "components", "buttons")
|
||||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(`.${ft}`))
|
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of btnFiles) {
|
for (const file of btnFiles) {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Events, MessageFlags } from "discord.js"
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { embedColor } from "~/config/options"
|
import { embedColor } from "~/config/options"
|
||||||
import { ICommand } from "~/typings"
|
import { ICommand, LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel"
|
import logToChannel from "~/utils/Functions/logtochannel"
|
||||||
import tryCatch from "../Functions/trycatch"
|
import tryCatch from "../Functions/trycatch"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
|
|
||||||
export default async function loadSlashCommandsEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadSlashCommandsEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const cmdPath = path.join(process.cwd(), folder, "commands")
|
const cmdPath = path.join(process.cwd(), dir, "commands")
|
||||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(`.${ft}`))
|
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of cmdFiles) {
|
for (const file of cmdFiles) {
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Events, MessageFlags } from "discord.js"
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { embedColor } from "~/config/options"
|
import { embedColor } from "~/config/options"
|
||||||
import { IContextMenu } from "~/typings"
|
import { IContextMenu, LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel"
|
import logToChannel from "~/utils/Functions/logtochannel"
|
||||||
import tryCatch from "../Functions/trycatch"
|
import tryCatch from "../Functions/trycatch"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
|
|
||||||
export default async function loadContextMenuEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadContextMenuEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const contextMenuPath = path.join(process.cwd(), folder, "commands-contextmenu")
|
const contextMenuPath = path.join(process.cwd(), dir, "commands-contextmenu")
|
||||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(`.${ft}`))
|
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of contextMenuFiles) {
|
for (const file of contextMenuFiles) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { CronJob } from "cron"
|
import { CronJob } from "cron"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { ICron } from "~/typings"
|
import { ICron, LoadEventsOptions } from "~/typings"
|
||||||
|
|
||||||
export default async function loadCronEvents(ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadCronEvents({ ft, dir }: LoadEventsOptions) {
|
||||||
const cronPath = path.join(process.cwd(), folder, "events", "cron")
|
const cronPath = path.join(process.cwd(), dir, "events", "cron")
|
||||||
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(`.${ft}`))
|
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of cronFiles) {
|
for (const file of cronFiles) {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
|
|
||||||
export default async function loadEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const serverDir = path.join(process.cwd(), folder, "events", "server")
|
const serverDir = path.join(process.cwd(), dir, "events", "server")
|
||||||
const eventDirs = fs.readdirSync(serverDir)
|
const eventDirs = fs.readdirSync(serverDir)
|
||||||
for (const eventDir of eventDirs) {
|
for (const eventDir of eventDirs) {
|
||||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)).filter(file => file.endsWith(`.${ft}`))
|
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LoadEventsOptions } from "src/typings"
|
||||||
import { ExtendedClient } from "../Client"
|
import { ExtendedClient } from "../Client"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
import loadAutocompleteEvents from "./autocomplete"
|
import loadAutocompleteEvents from "./autocomplete"
|
||||||
@@ -8,12 +9,12 @@ import loadCronEvents from "./cron"
|
|||||||
import loadEvents from "./events"
|
import loadEvents from "./events"
|
||||||
import loadModalEvents from "./modal"
|
import loadModalEvents from "./modal"
|
||||||
|
|
||||||
export default async function loadAllEvents(client: ExtendedClient, ft: "js" | "ts", folder: "dist" | "src") {
|
export default async function loadAllEvents(client: ExtendedClient, opts: LoadEventsOptions) {
|
||||||
await loadEvents(client, ft, folder).then(() => log.info("Events loaded"))
|
await loadEvents(client, opts).then(() => log.info("Events loaded"))
|
||||||
await loadButtonEvents(client, ft, folder).then(() => log.info("Button events loaded"))
|
await loadButtonEvents(client, opts).then(() => log.info("Button events loaded"))
|
||||||
await loadSlashCommandsEvents(client, ft, folder).then(() => log.info("Slash commands loaded"))
|
await loadSlashCommandsEvents(client, opts).then(() => log.info("Slash commands loaded"))
|
||||||
await loadContextMenuEvents(client, ft, folder).then(() => log.info("Context menu events loaded"))
|
await loadContextMenuEvents(client, opts).then(() => log.info("Context menu events loaded"))
|
||||||
await loadModalEvents(client, ft, folder).then(() => log.info("Modal events loaded"))
|
await loadModalEvents(client, opts).then(() => log.info("Modal events loaded"))
|
||||||
await loadAutocompleteEvents(client, ft, folder).then(() => log.info("Autocomplete events loaded"))
|
await loadAutocompleteEvents(client, opts).then(() => log.info("Autocomplete events loaded"))
|
||||||
await loadCronEvents(ft, folder).then(() => log.info("Cron events loaded"))
|
await loadCronEvents(opts).then(() => log.info("Cron events loaded"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Events, MessageFlags } from "discord.js"
|
|||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { embedColor } from "~/config/options"
|
import { embedColor } from "~/config/options"
|
||||||
import { IModal } from "~/typings"
|
import { IModal, LoadEventsOptions } from "~/typings"
|
||||||
import { ExtendedClient as Client } from "~/utils/Client"
|
import { ExtendedClient as Client } from "~/utils/Client"
|
||||||
import logToChannel from "~/utils/Functions/logtochannel"
|
import logToChannel from "~/utils/Functions/logtochannel"
|
||||||
import tryCatch from "../Functions/trycatch"
|
import tryCatch from "../Functions/trycatch"
|
||||||
import { log } from "../Logger"
|
import { log } from "../Logger"
|
||||||
|
|
||||||
export default async function loadModalEvents(client: Client, ft: "ts" | "js", folder: "src" | "dist") {
|
export default async function loadModalEvents(client: Client, { ft, dir }: LoadEventsOptions) {
|
||||||
const modalPath = path.join(process.cwd(), folder, "components", "modals")
|
const modalPath = path.join(process.cwd(), dir, "components", "modals")
|
||||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(`.${ft}`))
|
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(`.${ft}`))
|
||||||
|
|
||||||
for (const file of modalFiles) {
|
for (const file of modalFiles) {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ const client = new Client()
|
|||||||
const redis = new RedisClient(env.prod.REDISURI)
|
const redis = new RedisClient(env.prod.REDISURI)
|
||||||
|
|
||||||
const ft = process.env.BUILD !== "true" ? "ts" : "js"
|
const ft = process.env.BUILD !== "true" ? "ts" : "js"
|
||||||
const folder = process.env.BUILD !== "true" ? "src" : "dist"
|
const dir = process.env.DOCKER === "1" ? "" : process.env.BUILD !== "true" ? "src" : "dist"
|
||||||
|
|
||||||
class Illegitimate {
|
class Illegitimate {
|
||||||
async start() {
|
async start() {
|
||||||
await loadAllEvents(client, ft, folder)
|
await loadAllEvents(client, { ft, dir })
|
||||||
await client.start()
|
await client.start()
|
||||||
await this.databases()
|
await this.databases()
|
||||||
this.loadMethods()
|
this.loadMethods()
|
||||||
|
|||||||
Reference in New Issue
Block a user