Fixing formatting
This commit is contained in:
@@ -10,8 +10,5 @@ export default interface Command {
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
subcommands?: boolean
|
subcommands?: boolean
|
||||||
data: SlashCommandBuilder
|
data: SlashCommandBuilder
|
||||||
execute: (
|
execute: (interaction: ChatInputCommandInteraction, client: Client) => Promise<void>
|
||||||
interaction: ChatInputCommandInteraction,
|
|
||||||
client: Client
|
|
||||||
) => Promise<void>
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import { Command } from "interfaces"
|
import { Command } from "interfaces"
|
||||||
import color from "./functions/colors"
|
import color from "./functions/colors"
|
||||||
import env from "./Env"
|
import env from "./Env"
|
||||||
import {
|
import { REST, RESTGetAPIApplicationGuildCommandResult, RESTPutAPIApplicationGuildCommandsJSONBody, Routes } from "discord.js"
|
||||||
REST,
|
|
||||||
RESTGetAPIApplicationGuildCommandResult,
|
|
||||||
RESTPutAPIApplicationGuildCommandsJSONBody,
|
|
||||||
Routes
|
|
||||||
} from "discord.js"
|
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
type FileType = "js" | "ts"
|
type FileType = "js" | "ts"
|
||||||
|
|
||||||
@@ -16,19 +11,11 @@ export default async function autoDeployCommands(fileType: FileType) {
|
|||||||
let contentMenuCommands: string[] = []
|
let contentMenuCommands: string[] = []
|
||||||
|
|
||||||
if (fileType === "js") {
|
if (fileType === "js") {
|
||||||
commandFiles = fs
|
commandFiles = fs.readdirSync("./dist/commands/").filter(file => file.endsWith(fileType))
|
||||||
.readdirSync("./dist/commands/")
|
contentMenuCommands = fs.readdirSync("./dist/commands-contextmenu/").filter(file => file.endsWith(fileType))
|
||||||
.filter(file => file.endsWith(fileType))
|
|
||||||
contentMenuCommands = fs
|
|
||||||
.readdirSync("./dist/commands-contextmenu/")
|
|
||||||
.filter(file => file.endsWith(fileType))
|
|
||||||
} else if (fileType === "ts") {
|
} else if (fileType === "ts") {
|
||||||
commandFiles = fs
|
commandFiles = fs.readdirSync("./src/commands/").filter(file => file.endsWith(fileType))
|
||||||
.readdirSync("./src/commands/")
|
contentMenuCommands = fs.readdirSync("./src/commands-contextmenu/").filter(file => file.endsWith(fileType))
|
||||||
.filter(file => file.endsWith(fileType))
|
|
||||||
contentMenuCommands = fs
|
|
||||||
.readdirSync("./src/commands-contextmenu/")
|
|
||||||
.filter(file => file.endsWith(fileType))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
@@ -70,24 +57,15 @@ export default async function autoDeployCommands(fileType: FileType) {
|
|||||||
a.name.localeCompare(b.name)
|
a.name.localeCompare(b.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
const newCmds = sortedNewCommandsInfo
|
const newCmds = sortedNewCommandsInfo.map(cmd => {
|
||||||
.map(cmd => {
|
return " " + cmd.name + " was registered."
|
||||||
return " " + cmd.name + " was registered."
|
}).join("\n")
|
||||||
})
|
const currentCmds = sortedCurrentCommandsInfo.map(cmd => {
|
||||||
.join("\n")
|
return " " + cmd.name + " was unregistered."
|
||||||
const currentCmds = sortedCurrentCommandsInfo
|
}).join("\n")
|
||||||
.map(cmd => {
|
|
||||||
return " " + cmd.name + " was unregistered."
|
|
||||||
})
|
|
||||||
.join("\n")
|
|
||||||
|
|
||||||
if (
|
if (JSON.stringify(sortedNewCommandsInfo) === JSON.stringify(sortedCurrentCommandsInfo)) {
|
||||||
JSON.stringify(sortedNewCommandsInfo) ===
|
console.log(color("Commands are the same, skipping deploy.", "lavender"))
|
||||||
JSON.stringify(sortedCurrentCommandsInfo)
|
|
||||||
) {
|
|
||||||
console.log(
|
|
||||||
color("Commands are the same, skipping deploy.", "lavender")
|
|
||||||
)
|
|
||||||
console.log(color(newCmds, "lavender"))
|
console.log(color(newCmds, "lavender"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -95,9 +73,7 @@ export default async function autoDeployCommands(fileType: FileType) {
|
|||||||
try {
|
try {
|
||||||
console.log(color("Commands are different, starting deploy.", "red"))
|
console.log(color("Commands are different, starting deploy.", "red"))
|
||||||
console.log(color(currentCmds, "red"))
|
console.log(color(currentCmds, "red"))
|
||||||
console.log(
|
console.log(`Started refreshing ${commands.length} application (/) commands.`)
|
||||||
`Started refreshing ${commands.length} application (/) commands.`
|
|
||||||
)
|
|
||||||
|
|
||||||
const data = (await rest.put(
|
const data = (await rest.put(
|
||||||
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
Routes.applicationGuildCommands(env.dev.devid!, env.dev.guildid!),
|
||||||
@@ -106,9 +82,7 @@ export default async function autoDeployCommands(fileType: FileType) {
|
|||||||
|
|
||||||
console.log(color("New commands deployed.", "lavender"))
|
console.log(color("New commands deployed.", "lavender"))
|
||||||
console.log(color(newCmds, "lavender"))
|
console.log(color(newCmds, "lavender"))
|
||||||
console.log(
|
console.log(`Successfully reloaded ${data.length} application (/) commands.`)
|
||||||
`Successfully reloaded ${data.length} application (/) commands.`
|
|
||||||
)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import color from "./functions/colors"
|
|||||||
import { Command, ContextMenu, Button, Modal, Autocomplete } from "interfaces"
|
import { Command, ContextMenu, Button, Modal, Autocomplete } from "interfaces"
|
||||||
import env from "./Env"
|
import env from "./Env"
|
||||||
import autoDeployCommands from "./Autodeploy"
|
import autoDeployCommands from "./Autodeploy"
|
||||||
import { loadAllEvents } from "./Events"
|
|
||||||
|
|
||||||
export class ExtendedClient extends Client {
|
export class ExtendedClient extends Client {
|
||||||
commands: Collection<string, Command> = new Collection()
|
commands: Collection<string, Command> = new Collection()
|
||||||
@@ -34,20 +33,15 @@ export class ExtendedClient extends Client {
|
|||||||
async start() {
|
async start() {
|
||||||
let token: string
|
let token: string
|
||||||
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT) {
|
||||||
console.log(
|
console.log(color("Running in development mode. [ts-node]", "lavender"))
|
||||||
color("Running in development mode. [ts-node]", "lavender")
|
|
||||||
)
|
|
||||||
loadAllEvents(this, "ts")
|
|
||||||
token = env.dev.devtoken!
|
token = env.dev.devtoken!
|
||||||
autoDeployCommands("ts")
|
autoDeployCommands("ts")
|
||||||
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
|
} else if (process.env.NODE_ENV === "dev" && !process.env.TYPESCRIPT) {
|
||||||
console.log(color("Running in development mode.", "lavender"))
|
console.log(color("Running in development mode.", "lavender"))
|
||||||
loadAllEvents(this, "js")
|
|
||||||
token = env.dev.devtoken!
|
token = env.dev.devtoken!
|
||||||
autoDeployCommands("js")
|
autoDeployCommands("js")
|
||||||
} else {
|
} else {
|
||||||
console.log(color("Running in production mode.", "green"))
|
console.log(color("Running in production mode.", "green"))
|
||||||
loadAllEvents(this, "js")
|
|
||||||
token = env.prod.token!
|
token = env.prod.token!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,8 @@ type FileType = "js" | "ts"
|
|||||||
const embedColor = Number(color.replace("#", "0x"))
|
const embedColor = Number(color.replace("#", "0x"))
|
||||||
|
|
||||||
export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
||||||
const autocompletePath = path.join(
|
const autocompletePath = path.join(__dirname, "..", "..", "components", "autocomplete")
|
||||||
__dirname,
|
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(ft))
|
||||||
"..",
|
|
||||||
"..",
|
|
||||||
"components",
|
|
||||||
"autocomplete"
|
|
||||||
)
|
|
||||||
const autocompleteFiles = fs
|
|
||||||
.readdirSync(autocompletePath)
|
|
||||||
.filter(file => file.endsWith(ft))
|
|
||||||
|
|
||||||
for (const file of autocompleteFiles) {
|
for (const file of autocompleteFiles) {
|
||||||
const filePath = path.join(autocompletePath, file)
|
const filePath = path.join(autocompletePath, file)
|
||||||
@@ -43,9 +35,7 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
|||||||
const autocomplete = client.autocomplete.get(interaction.commandName)
|
const autocomplete = client.autocomplete.get(interaction.commandName)
|
||||||
|
|
||||||
if (!autocomplete) {
|
if (!autocomplete) {
|
||||||
console.error(
|
console.error(`No autocomplete matching ${interaction.commandName} was found.`)
|
||||||
`No autocomplete matching ${interaction.commandName} was found.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,21 +44,15 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (process.env.NODE_ENV !== "dev") {
|
if (process.env.NODE_ENV !== "dev") {
|
||||||
await logToChannel("error", {
|
await logToChannel("error", {
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
title: "Autocomplete error occured",
|
||||||
title: "Autocomplete error occured",
|
description: "```" + error + "```",
|
||||||
description: String(error),
|
color: embedColor,
|
||||||
color: embedColor,
|
footer: {
|
||||||
footer: {
|
icon_url: interaction.guild!.iconURL() || undefined,
|
||||||
icon_url:
|
text: interaction.user.username + " | " + interaction.commandName
|
||||||
interaction.guild!.iconURL() || undefined,
|
|
||||||
text:
|
|
||||||
interaction.user.username +
|
|
||||||
" | " +
|
|
||||||
interaction.commandName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
|||||||
const button = client.buttons.get(interaction.customId)
|
const button = client.buttons.get(interaction.customId)
|
||||||
|
|
||||||
if (!button) {
|
if (!button) {
|
||||||
console.error(
|
console.error(`No event matching ${interaction.customId} was found.`)
|
||||||
`No event matching ${interaction.customId} was found.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,45 +44,33 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (process.env.NODE_ENV !== "dev") {
|
if (process.env.NODE_ENV !== "dev") {
|
||||||
await logToChannel("error", {
|
await logToChannel("error", {
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
title: "Button error occured",
|
||||||
title: "Button error occured",
|
description: "```" + error + "```",
|
||||||
description: "```" + error + "```",
|
color: embedColor,
|
||||||
color: embedColor,
|
footer: {
|
||||||
footer: {
|
icon_url: interaction.guild!.iconURL() || undefined,
|
||||||
icon_url:
|
text: interaction.user.username + " | " + interaction.customId
|
||||||
interaction.guild!.iconURL() || undefined,
|
|
||||||
text:
|
|
||||||
interaction.user.username +
|
|
||||||
" | " +
|
|
||||||
interaction.customId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
if (!interaction.deferred) {
|
if (!interaction.deferred) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this button!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this button!",
|
}],
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
],
|
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this button! 2",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this button! 2",
|
}]
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,45 +47,33 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (process.env.NODE_ENV !== "dev") {
|
if (process.env.NODE_ENV !== "dev") {
|
||||||
await logToChannel("error", {
|
await logToChannel("error", {
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
title: "Command error occured",
|
||||||
title: "Command error occured",
|
description: "```" + error + "```",
|
||||||
description: "```" + error + "```",
|
color: embedColor,
|
||||||
color: embedColor,
|
footer: {
|
||||||
footer: {
|
icon_url: interaction.guild!.iconURL() || undefined,
|
||||||
icon_url:
|
text: interaction.user.username + " | " + interaction.commandName
|
||||||
interaction.guild!.iconURL() || undefined,
|
|
||||||
text:
|
|
||||||
interaction.user.username +
|
|
||||||
" | " +
|
|
||||||
interaction.commandName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
if (!interaction.deferred) {
|
if (!interaction.deferred) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this command!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this command!",
|
}],
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
],
|
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this command!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this command!",
|
}]
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,8 @@ type FileType = "js" | "ts"
|
|||||||
const embedColor = Number(color.replace("#", "0x"))
|
const embedColor = Number(color.replace("#", "0x"))
|
||||||
|
|
||||||
export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
||||||
const contextMenuPath = path.join(
|
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
|
||||||
__dirname,
|
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(ft))
|
||||||
"..",
|
|
||||||
"..",
|
|
||||||
"commands-contextmenu"
|
|
||||||
)
|
|
||||||
const contextMenuFiles = fs
|
|
||||||
.readdirSync(contextMenuPath)
|
|
||||||
.filter(file => file.endsWith(ft))
|
|
||||||
|
|
||||||
for (const file of contextMenuFiles) {
|
for (const file of contextMenuFiles) {
|
||||||
const filePath = path.join(contextMenuPath, file)
|
const filePath = path.join(contextMenuPath, file)
|
||||||
@@ -43,9 +36,7 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
|||||||
const command = client.contextmenus.get(interaction.commandName)
|
const command = client.contextmenus.get(interaction.commandName)
|
||||||
|
|
||||||
if (!command) {
|
if (!command) {
|
||||||
console.error(
|
console.error(`No command matching ${interaction.commandName} was found.`)
|
||||||
`No command matching ${interaction.commandName} was found.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,45 +45,33 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (process.env.NODE_ENV !== "dev") {
|
if (process.env.NODE_ENV !== "dev") {
|
||||||
await logToChannel("error", {
|
await logToChannel("error", {
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
title: "Contextmenu error occured",
|
||||||
title: "Contextmenu error occured",
|
description: "```" + error + "```",
|
||||||
description: "```" + error + "```",
|
color: embedColor,
|
||||||
color: embedColor,
|
footer: {
|
||||||
footer: {
|
icon_url: interaction.guild!.iconURL() || undefined,
|
||||||
icon_url:
|
text: interaction.user.username + " | " + interaction.commandName
|
||||||
interaction.guild!.iconURL() || undefined,
|
|
||||||
text:
|
|
||||||
interaction.user.username +
|
|
||||||
" | " +
|
|
||||||
interaction.commandName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
if (!interaction.deferred) {
|
if (!interaction.deferred) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this contextmenu command!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this contextmenu command!",
|
}],
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
],
|
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this contextmenu command!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this contextmenu command!",
|
}]
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,33 +5,20 @@ import { Cron } from "interfaces"
|
|||||||
|
|
||||||
export default function loadCronEvents() {
|
export default function loadCronEvents() {
|
||||||
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
|
const cronPath = path.join(__dirname, "..", "..", "events", "cron")
|
||||||
const cronFiles = fs
|
const cronFiles = fs.readdirSync(cronPath).filter(file => file.endsWith(".js"))
|
||||||
.readdirSync(cronPath)
|
|
||||||
.filter(file => file.endsWith(".js"))
|
|
||||||
|
|
||||||
for (const file of cronFiles) {
|
for (const file of cronFiles) {
|
||||||
const filePath = path.join(cronPath, file)
|
const filePath = path.join(cronPath, file)
|
||||||
const cron: Cron = require(filePath)
|
const cron: Cron = require(filePath)
|
||||||
|
|
||||||
const time =
|
const time =
|
||||||
cron.time.seconds +
|
cron.time.seconds + " " +
|
||||||
" " +
|
cron.time.minutes + " " +
|
||||||
cron.time.minutes +
|
cron.time.hours + " " +
|
||||||
" " +
|
cron.time.dayOfMonth + " " +
|
||||||
cron.time.hours +
|
cron.time.month + " " +
|
||||||
" " +
|
|
||||||
cron.time.dayOfMonth +
|
|
||||||
" " +
|
|
||||||
cron.time.month +
|
|
||||||
" " +
|
|
||||||
cron.time.dayOfWeek
|
cron.time.dayOfWeek
|
||||||
|
|
||||||
new CronJob(
|
new CronJob(time, cron.execute, cron.onComplete, cron.start, cron.timeZone).start()
|
||||||
time,
|
|
||||||
cron.execute,
|
|
||||||
cron.onComplete,
|
|
||||||
cron.start,
|
|
||||||
cron.timeZone
|
|
||||||
).start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import loadContextMenuEvents from "./contextmenu"
|
|||||||
import loadCronEvents from "./cron"
|
import loadCronEvents from "./cron"
|
||||||
import loadEvents from "./events"
|
import loadEvents from "./events"
|
||||||
import loadModalEvents from "./modal"
|
import loadModalEvents from "./modal"
|
||||||
type FileType = "js" | "ts"
|
|
||||||
|
|
||||||
export function loadAllEvents(client: Client, ft: FileType) {
|
export default function loadAllEvents(client: Client, ft: "js" | "ts") {
|
||||||
loadEvents(client)
|
loadEvents(client)
|
||||||
loadButtonEvents(client, ft)
|
loadButtonEvents(client, ft)
|
||||||
loadSlashCommandsEvents(client, ft)
|
loadSlashCommandsEvents(client, ft)
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ const embedColor = Number(color.replace("#", "0x"))
|
|||||||
|
|
||||||
export default function loadModalEvents(client: Client, ft: FileType) {
|
export default function loadModalEvents(client: Client, ft: FileType) {
|
||||||
const modalPath = path.join(__dirname, "..", "..", "components", "modals")
|
const modalPath = path.join(__dirname, "..", "..", "components", "modals")
|
||||||
const modalFiles = fs
|
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(ft))
|
||||||
.readdirSync(modalPath)
|
|
||||||
.filter(file => file.endsWith(ft))
|
|
||||||
|
|
||||||
for (const file of modalFiles) {
|
for (const file of modalFiles) {
|
||||||
const filePath = path.join(modalPath, file)
|
const filePath = path.join(modalPath, file)
|
||||||
@@ -37,9 +35,7 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
|||||||
const modal = client.modals.get(interaction.customId)
|
const modal = client.modals.get(interaction.customId)
|
||||||
|
|
||||||
if (!modal) {
|
if (!modal) {
|
||||||
console.error(
|
console.error(`No modal matching ${interaction.customId} was found.`)
|
||||||
`No modal matching ${interaction.customId} was found.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,44 +44,32 @@ export default function loadModalEvents(client: Client, ft: FileType) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (process.env.NODE_ENV !== "dev") {
|
if (process.env.NODE_ENV !== "dev") {
|
||||||
await logToChannel("error", {
|
await logToChannel("error", {
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
title: "Button error occured",
|
||||||
title: "Button error occured",
|
description: "```" + error + "```",
|
||||||
description: "```" + error + "```",
|
color: embedColor,
|
||||||
color: embedColor,
|
footer: {
|
||||||
footer: {
|
icon_url: interaction.guild!.iconURL() || undefined,
|
||||||
icon_url:
|
text: interaction.user.username + " | " + interaction.customId
|
||||||
interaction.guild!.iconURL() || undefined,
|
|
||||||
text:
|
|
||||||
interaction.user.username +
|
|
||||||
" | " +
|
|
||||||
interaction.customId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
if (!interaction.deferred) {
|
if (!interaction.deferred) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this modal!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this modal!",
|
}]
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [
|
embeds: [{
|
||||||
{
|
description: "There was an error while executing this modal!",
|
||||||
description:
|
color: embedColor
|
||||||
"There was an error while executing this modal!",
|
}]
|
||||||
color: embedColor
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const mojanguuid = "https://sessionserver.mojang.com/session/minecraft/profile/"
|
|||||||
const hypixel = "https://api.hypixel.net/player"
|
const hypixel = "https://api.hypixel.net/player"
|
||||||
const guild = "https://api.hypixel.net/guild"
|
const guild = "https://api.hypixel.net/guild"
|
||||||
const minotar = "https://minotar.net/helm/"
|
const minotar = "https://minotar.net/helm/"
|
||||||
type GuildQuerqType = "player" | "name" | "id"
|
type GuildQueryType = "player" | "name" | "id"
|
||||||
|
|
||||||
type Profile = {
|
type Profile = {
|
||||||
data: {
|
data: {
|
||||||
@@ -47,8 +47,10 @@ async function getIGN(uuid: string): Promise<string | null> {
|
|||||||
async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
||||||
const playerReq: Player = await fetch(hypixel, {
|
const playerReq: Player = await fetch(hypixel, {
|
||||||
params: {
|
params: {
|
||||||
key: apikey,
|
|
||||||
uuid: uuid
|
uuid: uuid
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"API-Key": apikey
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -59,16 +61,15 @@ async function getPlayer(uuid: string): Promise<PlayerData | null> {
|
|||||||
return playerReq.data.player
|
return playerReq.data.player
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGuild(
|
async function getGuild(query: string, type?: GuildQueryType): Promise<GuildData | null> {
|
||||||
query: string,
|
|
||||||
type?: GuildQuerqType
|
|
||||||
): Promise<GuildData | null> {
|
|
||||||
const reqType = type ? type : "player"
|
const reqType = type ? type : "player"
|
||||||
|
|
||||||
const guildReq: Guild = await fetch(guild, {
|
const guildReq: Guild = await fetch(guild, {
|
||||||
params: {
|
params: {
|
||||||
key: apikey,
|
|
||||||
[reqType]: query
|
[reqType]: query
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
"API-Key": apikey
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,8 @@ function guildLevel(exp: number): number {
|
|||||||
*/
|
*/
|
||||||
function scaledGEXP(input: number): number {
|
function scaledGEXP(input: number): number {
|
||||||
if (input <= 200000) return Number(input)
|
if (input <= 200000) return Number(input)
|
||||||
if (input <= 700000)
|
if (input <= 700000) return Number(Math.round((input - 200000) / 10 + 200000))
|
||||||
return Number(Math.round((input - 200000) / 10 + 200000))
|
if (input > 700000) return Number(Math.round((input - 700000) / 33 + 250000))
|
||||||
if (input > 700000)
|
|
||||||
return Number(Math.round((input - 700000) / 33 + 250000))
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,25 @@ import color from "utils/functions/colors"
|
|||||||
import { Redis } from "ioredis"
|
import { Redis } from "ioredis"
|
||||||
import env from "utils/Env"
|
import env from "utils/Env"
|
||||||
import { connect } from "mongoose"
|
import { connect } from "mongoose"
|
||||||
|
import loadAllEvents from "./Events"
|
||||||
const client = new Client()
|
const client = new Client()
|
||||||
const redis = new Redis(env.prod.redisURI!)
|
const redis = new Redis(env.prod.redisURI!)
|
||||||
|
let ft: "js" | "ts"
|
||||||
|
if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
|
||||||
|
ft = "ts"
|
||||||
|
} else {
|
||||||
|
ft = "js"
|
||||||
|
}
|
||||||
|
|
||||||
class Bot {
|
class Bot {
|
||||||
async start() {
|
async start() {
|
||||||
this.init()
|
this.init()
|
||||||
|
loadAllEvents(client, ft)
|
||||||
client.start()
|
client.start()
|
||||||
|
this.databases()
|
||||||
|
}
|
||||||
|
|
||||||
|
private async databases() {
|
||||||
redis.on("ready", () => {
|
redis.on("ready", () => {
|
||||||
console.log(color("Connected to Redis", "green"))
|
console.log(color("Connected to Redis", "green"))
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ const channels = {
|
|||||||
|
|
||||||
type Channel = keyof typeof channels
|
type Channel = keyof typeof channels
|
||||||
|
|
||||||
export default async function logToChannel(
|
export default async function logToChannel(channel: Channel, message: MessageCreateOptions): Promise<void | null> {
|
||||||
channel: Channel,
|
|
||||||
message: MessageCreateOptions
|
|
||||||
): Promise<void | null> {
|
|
||||||
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
|
const guild = Illegitimate.client.guilds.cache.get(guildid) as Guild
|
||||||
let logChannel: TextChannel
|
let logChannel: TextChannel
|
||||||
|
|
||||||
@@ -35,9 +32,7 @@ export default async function logToChannel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!logChannel) {
|
if (!logChannel) {
|
||||||
console.log(
|
console.log(`[ERROR] Could not find channel used for ${channel} logging.`)
|
||||||
`[ERROR] Could not find channel used for ${channel} logging.`
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,63 +30,46 @@ type RoleType =
|
|||||||
| "default"
|
| "default"
|
||||||
| "all"
|
| "all"
|
||||||
|
|
||||||
export default function roleManage(role: RoleType): {
|
export default function roleManage(role: RoleType): { rolesToRemove: string[], rolesToAdd: string[] } {
|
||||||
rolesToRemove: string[]
|
|
||||||
rolesToAdd: string[]
|
|
||||||
} {
|
|
||||||
if (role === "gm") {
|
if (role === "gm") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== gm && role !== guildStaff && role !== guildRole)
|
||||||
role => role !== gm && role !== guildStaff && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [gm, guildStaff, guildRole]
|
const rolesToAdd = [gm, guildStaff, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "manager") {
|
if (role === "manager") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== manager && role !== guildStaff && role !== guildRole)
|
||||||
role =>
|
|
||||||
role !== manager && role !== guildStaff && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [manager, guildStaff, guildRole]
|
const rolesToAdd = [manager, guildStaff, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "moderator") {
|
if (role === "moderator") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== moderator && role !== guildStaff && role !== guildRole)
|
||||||
role =>
|
|
||||||
role !== moderator && role !== guildStaff && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [moderator, guildStaff, guildRole]
|
const rolesToAdd = [moderator, guildStaff, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "beast") {
|
if (role === "beast") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== beast && role !== guildRole)
|
||||||
role => role !== beast && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [beast, guildRole]
|
const rolesToAdd = [beast, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "elite") {
|
if (role === "elite") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== elite && role !== guildRole)
|
||||||
role => role !== elite && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [elite, guildRole]
|
const rolesToAdd = [elite, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "member") {
|
if (role === "member") {
|
||||||
const rolesToRemove = roles.filter(
|
const rolesToRemove = roles.filter(role => role !== member && role !== guildRole)
|
||||||
role => role !== member && role !== guildRole
|
|
||||||
)
|
|
||||||
const rolesToAdd = [member, guildRole]
|
const rolesToAdd = [member, guildRole]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === "default") {
|
if (role === "default") {
|
||||||
const rolesToRemove = roles
|
const rolesToRemove = roles
|
||||||
const rolesToAdd: string[] = [defaultMember]
|
const rolesToAdd = [defaultMember]
|
||||||
return { rolesToRemove, rolesToAdd }
|
return { rolesToRemove, rolesToAdd }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user