Added eslintrc config and updated all files to it
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadButtonEvents(client) {
|
||||
const btnPath = path.join(__dirname, '..', '..', 'events', 'buttons');
|
||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith('.js'));
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
|
||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of btnFiles) {
|
||||
|
||||
const filePath = path.join(btnPath, file);
|
||||
const btn = require(filePath);
|
||||
const filePath = path.join(btnPath, file)
|
||||
const btn = require(filePath)
|
||||
|
||||
if ('name' in btn && 'execute' in btn && btn.type === 'button') {
|
||||
client.events.set(btn.name, btn);
|
||||
if ("name" in btn && "execute" in btn && btn.type === "button") {
|
||||
client.events.set(btn.name, btn)
|
||||
} else {
|
||||
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`);
|
||||
console.log(`[WARNING] The button at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
client.on(Events.InteractionCreate, async event => {
|
||||
if (!event.isButton())
|
||||
return;
|
||||
return
|
||||
|
||||
const event2 = event.client.events.get(event.customId);
|
||||
const event2 = event.client.events.get(event.customId)
|
||||
|
||||
if (!event2) {
|
||||
console.error(`No event matching ${event.customId} was found.`);
|
||||
return;
|
||||
console.error(`No event matching ${event.customId} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await event2.execute(event);
|
||||
await event2.execute(event)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(error)
|
||||
await event.reply({
|
||||
content: 'There was an error while executing this event!',
|
||||
content: "There was an error while executing this event!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadSlashCommandsEvents(client) {
|
||||
const cmdPath = path.join(__dirname, '..', '..', 'commands');
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith('.js'));
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cmdFiles) {
|
||||
|
||||
const filePath = path.join(cmdPath, file);
|
||||
const cmd = require(filePath);
|
||||
const filePath = path.join(cmdPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
|
||||
client.commands.set(cmd.data.name, cmd);
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! commands testing
|
||||
const cmdTestPath = path.join(__dirname, '..', '..', 'commands-testing');
|
||||
const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith('.js'));
|
||||
const cmdTestPath = path.join(__dirname, "..", "..", "commands-testing")
|
||||
const cmdTestFiles = fs.readdirSync(cmdTestPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of cmdTestFiles) {
|
||||
|
||||
const filePath = path.join(cmdTestPath, file);
|
||||
const cmd = require(filePath);
|
||||
const filePath = path.join(cmdTestPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ('data' in cmd && 'execute' in cmd && cmd.type === 'slash') {
|
||||
client.commands.set(cmd.data.name, cmd);
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "slash") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! command handler
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand())
|
||||
return;
|
||||
return
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
const command = interaction.client.commands.get(interaction.commandName)
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
console.error(`No command matching ${interaction.commandName} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
await command.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(error)
|
||||
await interaction.reply({
|
||||
content: 'There was an error while executing this command!',
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadContextMenuEvents(client) {
|
||||
const contextMenuPath = path.join(__dirname, '..', '..', 'commands-contextmenu');
|
||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith('.js'));
|
||||
const contextMenuPath = path.join(__dirname, "..", "..", "commands-contextmenu")
|
||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of contextMenuFiles) {
|
||||
|
||||
const filePath = path.join(contextMenuPath, file);
|
||||
const cmd = require(filePath);
|
||||
const filePath = path.join(contextMenuPath, file)
|
||||
const cmd = require(filePath)
|
||||
|
||||
if ('data' in cmd && 'execute' in cmd && cmd.type === 'contextmenu') {
|
||||
client.commands.set(cmd.data.name, cmd);
|
||||
if ("data" in cmd && "execute" in cmd && cmd.type === "contextmenu") {
|
||||
client.commands.set(cmd.data.name, cmd)
|
||||
} else {
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`);
|
||||
console.log(`[WARNING] The command at ${filePath} is missing a required "data", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
|
||||
//! context menu command handler
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isContextMenuCommand())
|
||||
return;
|
||||
return
|
||||
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
const command = interaction.client.commands.get(interaction.commandName)
|
||||
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
console.error(`No command matching ${interaction.commandName} was found.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
await command.execute(interaction)
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.error(error)
|
||||
await interaction.reply({
|
||||
content: 'There was an error while executing this command!',
|
||||
content: "There was an error while executing this command!",
|
||||
ephemeral: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadEvents(client) {
|
||||
const serverDir = path.join(__dirname, '..', '..', 'events', 'server')
|
||||
const serverDir = path.join(__dirname, "..", "..", "events", "server")
|
||||
const eventDirs = fs.readdirSync(serverDir)
|
||||
for (const eventDir of eventDirs) {
|
||||
const eventFiles = fs.readdirSync(path.join(serverDir, eventDir))
|
||||
for (const eventFile of eventFiles) {
|
||||
const eventPath = path.join(serverDir, eventDir, eventFile)
|
||||
const event = require(eventPath)
|
||||
if ('name' in event && 'execute' in event && 'event' in event && event.type === 'event') {
|
||||
if ("name" in event && "execute" in event && "event" in event && event.type === "event") {
|
||||
client.on(event.event, event.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The event at ${eventPath} is missing a required "name", "execute", "type" or "event" property.`);
|
||||
console.log(`[WARNING] The event at ${eventPath} is missing a required "name", "execute", "type" or "event" property.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { Events } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadModalEvents(client) {
|
||||
const modalPath = path.join(__dirname, '..', '..', 'events', 'modals');
|
||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith('.js'));
|
||||
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
|
||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
for (const file of modalFiles) {
|
||||
|
||||
const filePath = path.join(modalPath, file);
|
||||
const modal = require(filePath);
|
||||
const filePath = path.join(modalPath, file)
|
||||
const modal = require(filePath)
|
||||
|
||||
if ('name' in modal && 'execute' in modal && modal.type === 'modal') {
|
||||
client.on(Events.InteractionCreate, modal.execute);
|
||||
if ("name" in modal && "execute" in modal && modal.type === "modal") {
|
||||
client.on(Events.InteractionCreate, modal.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`);
|
||||
console.log(`[WARNING] The modal at ${filePath} is missing a required "name", "execute" or "type" property.`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user