Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!145
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
"ignore": [
|
||||
".git",
|
||||
"node_modules/**/node_modules",
|
||||
"dist/config"
|
||||
"dist/config",
|
||||
"src"
|
||||
],
|
||||
"verbose": true,
|
||||
"env": {
|
||||
"NODE_ENV": "dev",
|
||||
"TYPESCRIPT": "true"
|
||||
"NODE_ENV": "dev"
|
||||
},
|
||||
"ext": "ts, json"
|
||||
}
|
||||
"ext": "js, json"
|
||||
}
|
||||
10
nodemon.json
10
nodemon.json
@@ -3,12 +3,12 @@
|
||||
"ignore": [
|
||||
".git",
|
||||
"node_modules/**/node_modules",
|
||||
"dist/config",
|
||||
"src"
|
||||
"dist/config"
|
||||
],
|
||||
"verbose": true,
|
||||
"env": {
|
||||
"NODE_ENV": "dev"
|
||||
"NODE_ENV": "dev",
|
||||
"TYPESCRIPT": "true"
|
||||
},
|
||||
"ext": "js, json"
|
||||
}
|
||||
"ext": "ts, json"
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
"start": "node dist/src/index.js",
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"dev": "nodemon dist/src/index.js",
|
||||
"dev:ts": "nodemon --config nodemon-ts.json",
|
||||
"dev": "nodemon",
|
||||
"dev:js": "nodemon --config nodemon-js.json dist/src/index.js",
|
||||
"dev:build": "ts-node scripts/dev-deploy.ts",
|
||||
"dev:delete": "ts-node scripts/delete-commands.ts",
|
||||
"format": "prettier --write src/",
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { getUUID, getPlayer, getGuild, getIGN } from "../../utils/Hypixel"
|
||||
import { color, devMessage } from "../../../config/options.json"
|
||||
import { ChannelType, ChatInputCommandInteraction } from "discord.js"
|
||||
import { redis } from "../../utils/Redis"
|
||||
import { GuildData } from "../../interfaces/Guild"
|
||||
import Illegitimate from "../../utils/Illegitimate"
|
||||
const redis = Illegitimate.redis
|
||||
|
||||
async function guildTop(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
|
||||
@@ -15,7 +15,7 @@ import staffapp from "../../schemas/staffAppSchema"
|
||||
import settings from "../../schemas/settingsSchema"
|
||||
import { getUUID } from "../../utils/Hypixel"
|
||||
import { Button } from "../../interfaces"
|
||||
import config from "../../utils/Config"
|
||||
import env from "../../utils/Env"
|
||||
|
||||
export = {
|
||||
name: "staffapply",
|
||||
@@ -42,7 +42,7 @@ export = {
|
||||
if (interaction.customId === "staffapply") {
|
||||
await interaction.deferReply({ ephemeral: true })
|
||||
|
||||
if (user.user.id !== config.prod.dev) {
|
||||
if (user.user.id !== env.prod.dev) {
|
||||
if (status === "0") {
|
||||
await interaction.editReply(
|
||||
"Staff applications are currently closed.",
|
||||
@@ -51,15 +51,15 @@ export = {
|
||||
}
|
||||
}
|
||||
|
||||
// if (!userRoles.has(guildRole)) {
|
||||
// await interaction.editReply("You must be a member of the guild to apply for staff.")
|
||||
// return
|
||||
// }
|
||||
if (!userRoles.has(guildRole)) {
|
||||
await interaction.editReply("You must be a member of the guild to apply for staff.")
|
||||
return
|
||||
}
|
||||
|
||||
// if (userRoles.has(guildStaff)) {
|
||||
// await interaction.editReply("You are already a staff member.")
|
||||
// return
|
||||
// }
|
||||
if (userRoles.has(guildStaff)) {
|
||||
await interaction.editReply("You are already a staff member.")
|
||||
return
|
||||
}
|
||||
|
||||
const application = await staffapp.findOne({ userID: user.user.id })
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface ProdConfig {
|
||||
interface ProdEnv {
|
||||
token: string | undefined
|
||||
mongoURI: string | undefined
|
||||
dev: string | undefined
|
||||
@@ -6,14 +6,14 @@ interface ProdConfig {
|
||||
redisURI: string | undefined
|
||||
}
|
||||
|
||||
interface DevConfig {
|
||||
interface DevEnv {
|
||||
devtoken: string | undefined
|
||||
clientid: string | undefined
|
||||
devid: string | undefined
|
||||
guildid: string | undefined
|
||||
}
|
||||
|
||||
export default interface Config {
|
||||
prod: ProdConfig
|
||||
dev: DevConfig
|
||||
export default interface Env {
|
||||
prod: ProdEnv
|
||||
dev: DevEnv
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import ContextMenu from "./ContextMenu"
|
||||
import Event from "./Event"
|
||||
import Modal from "./Modal"
|
||||
|
||||
import Config from "./Config"
|
||||
import Env from "./Env"
|
||||
import Cron from "./Cron"
|
||||
import TimeZones from "./TimeZones"
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Guild, GuildData } from "./Guild"
|
||||
import { Player, PlayerData } from "./Player"
|
||||
|
||||
export {
|
||||
Config,
|
||||
Env,
|
||||
Cron,
|
||||
TimeZones,
|
||||
Autocomplete,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Command } from "../interfaces"
|
||||
import config from "./Config"
|
||||
import color from "./Colors"
|
||||
import env from "./Env"
|
||||
import color from "./functions/colors"
|
||||
import {
|
||||
REST,
|
||||
RESTGetAPIApplicationGuildCommandResult,
|
||||
@@ -36,10 +36,10 @@ async function autoDeployCommands(fileType: FileType) {
|
||||
}
|
||||
}
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken!)
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
|
||||
|
||||
const currentCommands = (await rest.get(
|
||||
Routes.applicationGuildCommands(config.dev.devid!, config.dev.guildid!),
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
)) as RESTGetAPIApplicationGuildCommandResult[]
|
||||
|
||||
const currentCommandsInfo = currentCommands.map(command => {
|
||||
@@ -98,8 +98,8 @@ async function autoDeployCommands(fileType: FileType) {
|
||||
|
||||
const data = (await rest.put(
|
||||
Routes.applicationGuildCommands(
|
||||
config.dev.devid!,
|
||||
config.dev.guildid!,
|
||||
env.dev.devid!,
|
||||
env.dev.guildid!,
|
||||
),
|
||||
{ body: commands },
|
||||
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ContextMenu } from "../interfaces"
|
||||
import { Button } from "../interfaces"
|
||||
import { Modal } from "../interfaces"
|
||||
import { Autocomplete } from "../interfaces"
|
||||
import config from "./Config"
|
||||
import env from "./Env"
|
||||
import { autoDeployCommands } from "./Autodeploy"
|
||||
import { loadAllEvents } from "./Events"
|
||||
|
||||
@@ -40,17 +40,17 @@ export class ExtendedClient extends Client {
|
||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
||||
console.log("Running in development mode. [ts-node]")
|
||||
loadAllEvents(this, "ts")
|
||||
token = config.dev.devtoken!
|
||||
token = env.dev.devtoken!
|
||||
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!
|
||||
token = env.dev.devtoken!
|
||||
autoDeployCommands("js")
|
||||
} else {
|
||||
console.log("Running in production mode.")
|
||||
loadAllEvents(this, "js")
|
||||
token = config.prod.token!
|
||||
token = env.prod.token!
|
||||
}
|
||||
|
||||
this.login(token)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Config } from "../interfaces"
|
||||
import { Env } from "../interfaces"
|
||||
import "dotenv/config"
|
||||
|
||||
const config: Config = {
|
||||
const env: Env = {
|
||||
prod: {
|
||||
token: process.env.TOKEN,
|
||||
mongoURI: process.env.MONGOURI,
|
||||
@@ -17,4 +17,4 @@ const config: Config = {
|
||||
},
|
||||
}
|
||||
|
||||
export default config
|
||||
export default env
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ExtendedClient as Client } from "./Client"
|
||||
import { loadButtonEvents } from "./eventHandlers/button"
|
||||
import { loadSlashCommandsEvents } from "./eventHandlers/command"
|
||||
import { loadContextMenuEvents } from "./eventHandlers/contextmenu"
|
||||
import { loadModalEvents } from "./eventHandlers/modal"
|
||||
import { loadEvents } from "./eventHandlers/events"
|
||||
import { loadAutocompleteEvents } from "./eventHandlers/autocomplete"
|
||||
import { loadButtonEvents } from "./eventHandlers"
|
||||
import { loadSlashCommandsEvents } from "./eventHandlers"
|
||||
import { loadContextMenuEvents } from "./eventHandlers"
|
||||
import { loadModalEvents } from "./eventHandlers"
|
||||
import { loadEvents } from "./eventHandlers"
|
||||
import { loadAutocompleteEvents } from "./eventHandlers"
|
||||
import { FileType } from "../typings"
|
||||
|
||||
export function loadAllEvents(client: Client, ft: FileType) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ExtendedClient as Client } from "./Client"
|
||||
import config from "./Config"
|
||||
import { redis } from "./Redis"
|
||||
import { Redis } from "ioredis"
|
||||
import env from "./Env"
|
||||
import { connect } from "mongoose"
|
||||
import init from "./Init"
|
||||
import { loadCronEvents } from "./Cron"
|
||||
import { loadCronEvents } from "./eventHandlers"
|
||||
const client = new Client()
|
||||
const redis = new Redis(env.prod.redisURI!)
|
||||
|
||||
class Bot {
|
||||
constructor() {}
|
||||
@@ -16,10 +17,10 @@ class Bot {
|
||||
redis.on("ready", () => {
|
||||
console.log("Connected to Redis")
|
||||
})
|
||||
connect(config.prod.mongoURI!, {}).then(() => {
|
||||
connect(env.prod.mongoURI!, {}).then(() => {
|
||||
console.log("Connected to MongoDB")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default { Bot, client }
|
||||
export default { Bot, client, redis }
|
||||
@@ -1,7 +1,7 @@
|
||||
import config from "./Config"
|
||||
import env from "./Env"
|
||||
|
||||
const prodValues = config.prod
|
||||
const devValues = config.dev
|
||||
const prodValues = env.prod
|
||||
const devValues = env.dev
|
||||
|
||||
export default function init() {
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { Redis } from "ioredis"
|
||||
import config from "./Config"
|
||||
|
||||
const redis = new Redis(config.prod.redisURI!)
|
||||
|
||||
export { redis }
|
||||
@@ -5,7 +5,7 @@ import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
const autocompletePath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
@@ -52,6 +52,4 @@ function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { loadAutocompleteEvents }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadButtonEvents(client: Client, ft: FileType) {
|
||||
export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
|
||||
const btnFiles = fs
|
||||
.readdirSync(btnPath)
|
||||
@@ -46,6 +46,4 @@ function loadButtonEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { loadButtonEvents }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs .readdirSync(cmdPath) .filter(file => file.endsWith(ft))
|
||||
|
||||
@@ -45,6 +45,4 @@ function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { loadSlashCommandsEvents }
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
const contextMenuPath = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
@@ -52,6 +52,4 @@ function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { loadContextMenuEvents }
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { CronJob } from "cron"
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
import { Cron } from "../interfaces"
|
||||
import { Cron } from "../../interfaces"
|
||||
|
||||
function loadCronEvents() {
|
||||
const cronPath = path.join(__dirname, "..", "events", "cron")
|
||||
export default function loadCronEvents() {
|
||||
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
|
||||
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cronFiles) {
|
||||
@@ -15,6 +15,4 @@ function loadCronEvents() {
|
||||
|
||||
new CronJob(time, cron.execute, cron.onComplete, cron.start, cron.timeZone).start()
|
||||
}
|
||||
}
|
||||
|
||||
export { loadCronEvents }
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { Event } from "../../interfaces"
|
||||
import path = require("path")
|
||||
import fs = require("fs")
|
||||
|
||||
function loadEvents(client: Client) {
|
||||
export default function loadEvents(client: Client) {
|
||||
const serverDir = path.join(__dirname, "..", "..", "events", "server")
|
||||
const eventDirs = fs.readdirSync(serverDir)
|
||||
for (const eventDir of eventDirs) {
|
||||
@@ -14,6 +14,4 @@ function loadEvents(client: Client) {
|
||||
client.on(event.event, event.execute)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { loadEvents }
|
||||
}
|
||||
17
src/utils/eventHandlers/index.ts
Normal file
17
src/utils/eventHandlers/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import loadAutocompleteEvents from "./autocomplete"
|
||||
import loadButtonEvents from "./button"
|
||||
import loadSlashCommandsEvents from "./command"
|
||||
import loadContextMenuEvents from "./contextmenu"
|
||||
import loadCronEvents from "./cron"
|
||||
import loadEvents from "./events"
|
||||
import loadModalEvents from "./modal"
|
||||
|
||||
export {
|
||||
loadAutocompleteEvents,
|
||||
loadButtonEvents,
|
||||
loadSlashCommandsEvents,
|
||||
loadContextMenuEvents,
|
||||
loadCronEvents,
|
||||
loadEvents,
|
||||
loadModalEvents
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import path = require("path")
|
||||
import fs = require("fs")
|
||||
import { FileType } from "../../typings"
|
||||
|
||||
function loadModalEvents(client: Client, ft: FileType) {
|
||||
export default function loadModalEvents(client: Client, ft: FileType) {
|
||||
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
|
||||
const modalFiles = fs
|
||||
.readdirSync(modalPath)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import fetch from "axios"
|
||||
import config from "../Config"
|
||||
import env from "../Env"
|
||||
import { Profile, Profile2 } from "../../typings"
|
||||
import { Player, PlayerData } from "../../interfaces"
|
||||
import { Guild, GuildData } from "../../interfaces"
|
||||
const apikey = config.prod.hypixelapikey
|
||||
const apikey = env.prod.hypixelapikey
|
||||
const mojang = "https://api.mojang.com/users/profiles/minecraft/"
|
||||
const mojanguuid = "https://sessionserver.mojang.com/session/minecraft/profile/"
|
||||
const hypixel = "https://api.hypixel.net/player"
|
||||
|
||||
Reference in New Issue
Block a user