Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!146
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { REST, Routes } from "discord.js"
|
||||
import config from "../src/utils/Config"
|
||||
import env from "../src/utils/Env"
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken)
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
|
||||
|
||||
async function deleteCommands() {
|
||||
try {
|
||||
console.log("Started deleting application (/) commands.")
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid),
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
{ body: [] },
|
||||
)
|
||||
console.log("Successfully deleted application (/) commands.")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
|
||||
import fs from "node:fs"
|
||||
import { Command } from "../src/interfaces"
|
||||
import config from "../src/utils/Config"
|
||||
const rest = new REST({ version: "10" }).setToken(config.prod.token)
|
||||
import env from "../src/utils/Env"
|
||||
const rest = new REST({ version: "10" }).setToken(env.prod.token!)
|
||||
|
||||
const commands: RESTPutAPIApplicationCommandsJSONBody = []
|
||||
const commandFiles = fs.readdirSync("./dist/src/commands").filter(file => file.endsWith(".js"))
|
||||
@@ -22,7 +22,7 @@ for (const file of contentMenuCommands) {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||
|
||||
const data = await rest.put(
|
||||
Routes.applicationCommands(config.dev.clientid),
|
||||
Routes.applicationCommands(env.dev.clientid!),
|
||||
{ body: commands },
|
||||
) as RESTGetAPIApplicationGuildCommandResult[]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationCommandsJSONBody, Routes } from "discord.js"
|
||||
import fs from "fs"
|
||||
import config from "../src/utils/Config"
|
||||
import env from "../src/utils/Env"
|
||||
import { Command } from "../src/interfaces"
|
||||
const rest = new REST({ version: "10" }).setToken(config.dev.devtoken)
|
||||
const rest = new REST({ version: "10" }).setToken(env.dev.devtoken!)
|
||||
|
||||
const commands: RESTPutAPIApplicationCommandsJSONBody = []
|
||||
const commandFiles = fs.readdirSync("./dist/src/commands/").filter(file => file.endsWith(".js"))
|
||||
@@ -26,7 +26,7 @@ for (const file of contentMenuCommands) {
|
||||
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(config.dev.devid, config.dev.guildid),
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
{ body: commands },
|
||||
) as RESTGetAPIApplicationGuildCommandResult[]
|
||||
|
||||
|
||||
@@ -52,7 +52,9 @@ export = {
|
||||
}
|
||||
|
||||
if (!userRoles.has(guildRole)) {
|
||||
await interaction.editReply("You must be a member of the guild to apply for staff.")
|
||||
await interaction.editReply(
|
||||
"You must be a member of the guild to apply for staff.",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
hypixelGuildID,
|
||||
guildLogChannel,
|
||||
color,
|
||||
devMessage
|
||||
devMessage,
|
||||
} from "../../../config/options.json"
|
||||
import { getGuild, getIGN } from "../../utils/Hypixel"
|
||||
import { Cron, GuildData } from "../../interfaces"
|
||||
@@ -23,10 +23,12 @@ async function guildWeekly() {
|
||||
const embedColor = Number(color.replace("#", "0x"))
|
||||
|
||||
const message = await channel.send({
|
||||
embeds: [{
|
||||
description: "Starting to fetch guild data...",
|
||||
color: embedColor
|
||||
}]
|
||||
embeds: [
|
||||
{
|
||||
description: "Starting to fetch guild data...",
|
||||
color: embedColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const guild = (await getGuild(hypixelGuildID, "id")) as GuildData
|
||||
|
||||
@@ -16,4 +16,4 @@ export default interface Cron {
|
||||
onComplete?: null | undefined
|
||||
start?: boolean | null | undefined
|
||||
timeZone: keyof TimeZones
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,4 +427,4 @@ export default interface TimeZones {
|
||||
"Pacific/Truk": string
|
||||
"Pacific/Wake": string
|
||||
"Pacific/Wallis": string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ export type Profile2 = {
|
||||
}
|
||||
}
|
||||
|
||||
export type FileType = "js" | "ts"
|
||||
export type FileType = "js" | "ts"
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { Profile, Profile2, FileType } from "./Types"
|
||||
|
||||
export { Profile, Profile2, FileType }
|
||||
export { Profile, Profile2, FileType }
|
||||
|
||||
@@ -16,11 +16,19 @@ async function autoDeployCommands(fileType: FileType) {
|
||||
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))
|
||||
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))
|
||||
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) {
|
||||
@@ -86,10 +94,7 @@ async function autoDeployCommands(fileType: FileType) {
|
||||
|
||||
try {
|
||||
console.log(
|
||||
color.colorize(
|
||||
"Commands are different, starting deploy.",
|
||||
"red",
|
||||
),
|
||||
color.colorize("Commands are different, starting deploy.", "red"),
|
||||
)
|
||||
console.log(color.colorize(currentCmds, "red"))
|
||||
console.log(
|
||||
@@ -97,10 +102,7 @@ async function autoDeployCommands(fileType: FileType) {
|
||||
)
|
||||
|
||||
const data = (await rest.put(
|
||||
Routes.applicationGuildCommands(
|
||||
env.dev.devid!,
|
||||
env.dev.guildid!,
|
||||
),
|
||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||
{ body: commands },
|
||||
)) as RESTPutAPIApplicationGuildCommandsJSONBody[]
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ export class ExtendedClient extends Client {
|
||||
}
|
||||
|
||||
async start() {
|
||||
|
||||
let token: string
|
||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
||||
console.log("Running in development mode. [ts-node]")
|
||||
|
||||
@@ -23,4 +23,4 @@ class Bot {
|
||||
}
|
||||
}
|
||||
|
||||
export default { Bot, client, redis }
|
||||
export default { Bot, client, redis }
|
||||
|
||||
@@ -17,5 +17,4 @@ export default function init() {
|
||||
if (!value) throw new Error(`No ${key} specified`)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,4 +52,4 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ import { FileType } from "../../typings"
|
||||
|
||||
export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "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) {
|
||||
const filePath = path.join(btnPath, file)
|
||||
@@ -46,4 +44,4 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { FileType } from "../../typings"
|
||||
|
||||
export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
const cmdPath = path.join(__dirname, "..", "..", "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) {
|
||||
const filePath = path.join(cmdPath, file)
|
||||
@@ -45,4 +45,4 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,4 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,33 @@ import { Cron } from "../../interfaces"
|
||||
|
||||
export default function loadCronEvents() {
|
||||
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
|
||||
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(".js"))
|
||||
const cronFiles = fs
|
||||
.readdirSync(cronPath)
|
||||
.filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cronFiles) {
|
||||
const filePath = path.join(cronPath, file)
|
||||
const cron: Cron = require(filePath)
|
||||
|
||||
const time = cron.time.seconds + " " + cron.time.minutes + " " + cron.time.hours + " " + cron.time.dayOfMonth + " " + cron.time.month + " " + cron.time.dayOfWeek
|
||||
const time =
|
||||
cron.time.seconds +
|
||||
" " +
|
||||
cron.time.minutes +
|
||||
" " +
|
||||
cron.time.hours +
|
||||
" " +
|
||||
cron.time.dayOfMonth +
|
||||
" " +
|
||||
cron.time.month +
|
||||
" " +
|
||||
cron.time.dayOfWeek
|
||||
|
||||
new CronJob(time, cron.execute, cron.onComplete, cron.start, cron.timeZone).start()
|
||||
new CronJob(
|
||||
time,
|
||||
cron.execute,
|
||||
cron.onComplete,
|
||||
cron.start,
|
||||
cron.timeZone,
|
||||
).start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ export default function loadEvents(client: Client) {
|
||||
client.on(event.event, event.execute)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ export {
|
||||
loadContextMenuEvents,
|
||||
loadCronEvents,
|
||||
loadEvents,
|
||||
loadModalEvents
|
||||
}
|
||||
loadModalEvents,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user