Fixing formatting

This commit is contained in:
2024-01-21 00:03:19 +01:00
parent 614feeff3e
commit 9ec53882d1
15 changed files with 138 additions and 277 deletions

View File

@@ -10,16 +10,8 @@ type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x"))
export default function loadAutocompleteEvents(client: Client, ft: FileType) {
const autocompletePath = path.join(
__dirname,
"..",
"..",
"components",
"autocomplete"
)
const autocompleteFiles = fs
.readdirSync(autocompletePath)
.filter(file => file.endsWith(ft))
const autocompletePath = path.join(__dirname, "..", "..", "components", "autocomplete")
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(ft))
for (const file of autocompleteFiles) {
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)
if (!autocomplete) {
console.error(
`No autocomplete matching ${interaction.commandName} was found.`
)
console.error(`No autocomplete matching ${interaction.commandName} was found.`)
return
}
@@ -54,21 +44,15 @@ export default function loadAutocompleteEvents(client: Client, ft: FileType) {
} catch (error) {
if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", {
embeds: [
{
title: "Autocomplete error occured",
description: String(error),
color: embedColor,
footer: {
icon_url:
interaction.guild!.iconURL() || undefined,
text:
interaction.user.username +
" | " +
interaction.commandName
}
embeds: [{
title: "Autocomplete error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.user.username + " | " + interaction.commandName
}
]
}]
})
}
console.error(error)

View File

@@ -35,9 +35,7 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
const button = client.buttons.get(interaction.customId)
if (!button) {
console.error(
`No event matching ${interaction.customId} was found.`
)
console.error(`No event matching ${interaction.customId} was found.`)
return
}
@@ -46,45 +44,33 @@ export default function loadButtonEvents(client: Client, ft: FileType) {
} catch (error) {
if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", {
embeds: [
{
title: "Button error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url:
interaction.guild!.iconURL() || undefined,
text:
interaction.user.username +
" | " +
interaction.customId
}
embeds: [{
title: "Button error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.user.username + " | " + interaction.customId
}
]
}]
})
}
console.error(error)
if (!interaction.deferred) {
await interaction.reply({
embeds: [
{
description:
"There was an error while executing this button!",
color: embedColor
}
],
embeds: [{
description: "There was an error while executing this button!",
color: embedColor
}],
ephemeral: true
})
} else {
await interaction.editReply({
embeds: [
{
description:
"There was an error while executing this button! 2",
color: embedColor
}
]
embeds: [{
description: "There was an error while executing this button! 2",
color: embedColor
}]
})
}
}

View File

@@ -47,45 +47,33 @@ export default function loadSlashCommandsEvents(client: Client, ft: FileType) {
} catch (error) {
if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", {
embeds: [
{
title: "Command error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url:
interaction.guild!.iconURL() || undefined,
text:
interaction.user.username +
" | " +
interaction.commandName
}
embeds: [{
title: "Command error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.user.username + " | " + interaction.commandName
}
]
}]
})
}
console.error(error)
if (!interaction.deferred) {
await interaction.reply({
embeds: [
{
description:
"There was an error while executing this command!",
color: embedColor
}
],
embeds: [{
description: "There was an error while executing this command!",
color: embedColor
}],
ephemeral: true
})
} else {
await interaction.editReply({
embeds: [
{
description:
"There was an error while executing this command!",
color: embedColor
}
]
embeds: [{
description: "There was an error while executing this command!",
color: embedColor
}]
})
}
}

View File

@@ -10,15 +10,8 @@ type FileType = "js" | "ts"
const embedColor = Number(color.replace("#", "0x"))
export default function loadContextMenuEvents(client: Client, ft: FileType) {
const contextMenuPath = path.join(
__dirname,
"..",
"..",
"commands-contextmenu"
)
const contextMenuFiles = fs
.readdirSync(contextMenuPath)
.filter(file => file.endsWith(ft))
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(ft))
for (const file of contextMenuFiles) {
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)
if (!command) {
console.error(
`No command matching ${interaction.commandName} was found.`
)
console.error(`No command matching ${interaction.commandName} was found.`)
return
}
@@ -54,45 +45,33 @@ export default function loadContextMenuEvents(client: Client, ft: FileType) {
} catch (error) {
if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", {
embeds: [
{
title: "Contextmenu error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url:
interaction.guild!.iconURL() || undefined,
text:
interaction.user.username +
" | " +
interaction.commandName
}
embeds: [{
title: "Contextmenu error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.user.username + " | " + interaction.commandName
}
]
}]
})
}
console.error(error)
if (!interaction.deferred) {
await interaction.reply({
embeds: [
{
description:
"There was an error while executing this contextmenu command!",
color: embedColor
}
],
embeds: [{
description: "There was an error while executing this contextmenu command!",
color: embedColor
}],
ephemeral: true
})
} else {
await interaction.editReply({
embeds: [
{
description:
"There was an error while executing this contextmenu command!",
color: embedColor
}
]
embeds: [{
description: "There was an error while executing this contextmenu command!",
color: embedColor
}]
})
}
}

View File

@@ -5,33 +5,20 @@ 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.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()
}
}

View File

@@ -6,9 +6,8 @@ import loadContextMenuEvents from "./contextmenu"
import loadCronEvents from "./cron"
import loadEvents from "./events"
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)
loadButtonEvents(client, ft)
loadSlashCommandsEvents(client, ft)

View File

@@ -11,9 +11,7 @@ const embedColor = Number(color.replace("#", "0x"))
export default function loadModalEvents(client: Client, ft: FileType) {
const modalPath = path.join(__dirname, "..", "..", "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) {
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)
if (!modal) {
console.error(
`No modal matching ${interaction.customId} was found.`
)
console.error(`No modal matching ${interaction.customId} was found.`)
return
}
@@ -48,44 +44,32 @@ export default function loadModalEvents(client: Client, ft: FileType) {
} catch (error) {
if (process.env.NODE_ENV !== "dev") {
await logToChannel("error", {
embeds: [
{
title: "Button error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url:
interaction.guild!.iconURL() || undefined,
text:
interaction.user.username +
" | " +
interaction.customId
}
embeds: [{
title: "Button error occured",
description: "```" + error + "```",
color: embedColor,
footer: {
icon_url: interaction.guild!.iconURL() || undefined,
text: interaction.user.username + " | " + interaction.customId
}
]
}]
})
}
console.error(error)
if (!interaction.deferred) {
await interaction.reply({
embeds: [
{
description:
"There was an error while executing this modal!",
color: embedColor
}
]
embeds: [{
description: "There was an error while executing this modal!",
color: embedColor
}]
})
} else {
await interaction.editReply({
embeds: [
{
description:
"There was an error while executing this modal!",
color: embedColor
}
]
embeds: [{
description: "There was an error while executing this modal!",
color: embedColor
}]
})
}
}