Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!144
This commit is contained in:
@@ -11,5 +11,6 @@ scripts
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
Dockerfile.cache
|
||||
nodemon-ts.json
|
||||
nodemon.json
|
||||
README.old
|
||||
14
nodemon-ts.json
Normal file
14
nodemon-ts.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"restartable": "rs",
|
||||
"ignore": [
|
||||
".git",
|
||||
"node_modules/**/node_modules",
|
||||
"dist/config"
|
||||
],
|
||||
"verbose": true,
|
||||
"env": {
|
||||
"NODE_ENV": "dev",
|
||||
"TYPESCRIPT": "true"
|
||||
},
|
||||
"ext": "ts, json"
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"dev": "nodemon dist/src/index.js",
|
||||
"dev:ts": "nodemon --config nodemon-ts.json",
|
||||
"dev:build": "ts-node scripts/dev-deploy.ts",
|
||||
"dev:delete": "ts-node scripts/delete-commands.ts",
|
||||
"format": "prettier --write src/",
|
||||
|
||||
@@ -13,3 +13,5 @@ export type Profile2 = {
|
||||
profileActions: []
|
||||
}
|
||||
}
|
||||
|
||||
export type FileType = "js" | "ts"
|
||||
@@ -1,3 +1,3 @@
|
||||
import { Profile, Profile2 } from "./Profile"
|
||||
import { Profile, Profile2, FileType } from "./Types"
|
||||
|
||||
export { Profile, Profile2 }
|
||||
export { Profile, Profile2, FileType }
|
||||
@@ -8,15 +8,20 @@ import {
|
||||
Routes,
|
||||
} from "discord.js"
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../typings"
|
||||
|
||||
async function autoDeployCommands() {
|
||||
async function autoDeployCommands(fileType: FileType) {
|
||||
const commands = []
|
||||
const commandFiles = fs
|
||||
.readdirSync("./dist/src/commands/")
|
||||
.filter(file => file.endsWith(".js"))
|
||||
const contentMenuCommands = fs
|
||||
.readdirSync("./dist/src/commands-contextmenu/")
|
||||
.filter(file => file.endsWith(".js"))
|
||||
let commandFiles: string[] = []
|
||||
let contentMenuCommands: string[] = []
|
||||
|
||||
if (fileType === "js") {
|
||||
commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(fileType))
|
||||
contentMenuCommands = fs.readdirSync("./dist/src/commands-contextmenu/").filter(file => file.endsWith(fileType))
|
||||
} else if (fileType === "ts") {
|
||||
commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(fileType))
|
||||
contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(fileType))
|
||||
}
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`)
|
||||
@@ -79,7 +84,6 @@ async function autoDeployCommands() {
|
||||
return
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
try {
|
||||
console.log(
|
||||
color.colorize(
|
||||
@@ -108,7 +112,6 @@ async function autoDeployCommands() {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
export { autoDeployCommands }
|
||||
|
||||
@@ -35,15 +35,21 @@ export class ExtendedClient extends Client {
|
||||
}
|
||||
|
||||
async start() {
|
||||
loadAllEvents(this)
|
||||
|
||||
let token: string
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
console.log("Running in development mode.")
|
||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
||||
console.log("Running in development mode. [ts-node]")
|
||||
loadAllEvents(this, "ts")
|
||||
token = config.dev.devtoken!
|
||||
autoDeployCommands()
|
||||
autoDeployCommands("ts")
|
||||
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
|
||||
console.log("Running in development mode.")
|
||||
loadAllEvents(this, "js")
|
||||
token = config.dev.devtoken!
|
||||
autoDeployCommands("js")
|
||||
} else {
|
||||
console.log("Running in production mode.")
|
||||
loadAllEvents(this, "js")
|
||||
token = config.prod.token!
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import { loadContextMenuEvents } from "./eventHandlers/contextmenu"
|
||||
import { loadModalEvents } from "./eventHandlers/modal"
|
||||
import { loadEvents } from "./eventHandlers/events"
|
||||
import { loadAutocompleteEvents } from "./eventHandlers/autocomplete"
|
||||
import { FileType } from "../typings"
|
||||
|
||||
export function loadAllEvents(client: Client) {
|
||||
export function loadAllEvents(client: Client, ft: FileType) {
|
||||
loadEvents(client)
|
||||
loadButtonEvents(client)
|
||||
loadSlashCommandsEvents(client)
|
||||
loadContextMenuEvents(client)
|
||||
loadModalEvents(client)
|
||||
loadAutocompleteEvents(client)
|
||||
loadButtonEvents(client, ft)
|
||||
loadSlashCommandsEvents(client, ft)
|
||||
loadContextMenuEvents(client, ft)
|
||||
loadModalEvents(client, ft)
|
||||
loadAutocompleteEvents(client, ft)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import { Autocomplete } from "../../interfaces"
|
||||
import { Events } from "discord.js"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadAutocompleteEvents(client: Client) {
|
||||
function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
const autocompletePath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
@@ -14,7 +15,7 @@ function loadAutocompleteEvents(client: Client) {
|
||||
)
|
||||
const autocompleteFiles = fs
|
||||
.readdirSync(autocompletePath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
.filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of autocompleteFiles) {
|
||||
const filePath = path.join(autocompletePath, file)
|
||||
|
||||
@@ -3,12 +3,13 @@ import { Button } from "../../interfaces"
|
||||
import { Events } from "discord.js"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadButtonEvents(client: Client) {
|
||||
function loadButtonEvents(client: Client, ft: FileType) {
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
|
||||
const btnFiles = fs
|
||||
.readdirSync(btnPath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
.filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of btnFiles) {
|
||||
const filePath = path.join(btnPath, file)
|
||||
|
||||
@@ -3,12 +3,11 @@ import { Command } from "../../interfaces"
|
||||
import { Events } from "discord.js"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadSlashCommandsEvents(client: Client) {
|
||||
function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs
|
||||
.readdirSync(cmdPath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
const cmdFiles = fs .readdirSync(cmdPath) .filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of cmdFiles) {
|
||||
const filePath = path.join(cmdPath, file)
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ContextMenu } from "../../interfaces"
|
||||
import { Events } from "discord.js"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadContextMenuEvents(client: Client) {
|
||||
function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
const contextMenuPath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
@@ -13,7 +14,7 @@ function loadContextMenuEvents(client: Client) {
|
||||
)
|
||||
const contextMenuFiles = fs
|
||||
.readdirSync(contextMenuPath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
.filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of contextMenuFiles) {
|
||||
const filePath = path.join(contextMenuPath, file)
|
||||
|
||||
@@ -3,12 +3,13 @@ import { Modal } from "../../interfaces"
|
||||
import { Events } from "discord.js"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadModalEvents(client: Client) {
|
||||
function loadModalEvents(client: Client, ft: FileType) {
|
||||
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
|
||||
const modalFiles = fs
|
||||
.readdirSync(modalPath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
.filter(file => file.endsWith(ft))
|
||||
|
||||
for (const file of modalFiles) {
|
||||
const filePath = path.join(modalPath, file)
|
||||
|
||||
Reference in New Issue
Block a user