Merge branch 'dev' into 'main'
Moved all handlers into one file See merge request illegitimate/illegitimate-bot!76
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
module.exports = {
|
||||
name: "logBtnsCmds",
|
||||
description: "Logs all button and command interactions",
|
||||
type: "interaction",
|
||||
type: "event",
|
||||
event: "interactionCreate",
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module.exports = {
|
||||
name: 'ur mom',
|
||||
description: 'ur moms someone',
|
||||
type: 'message',
|
||||
type: 'event',
|
||||
event: 'messageCreate',
|
||||
|
||||
/** @param { import('discord.js').Message } message */
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module.exports = {
|
||||
name: 'conolelog',
|
||||
description: "console log",
|
||||
type: 'ready',
|
||||
type: 'event',
|
||||
event: 'ready',
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
execute(client) {
|
||||
@@ -1,9 +1,10 @@
|
||||
const { onlineLogChannel, color } = require('../../config/options.json');
|
||||
const { onlineLogChannel, color } = require('../../../config/options.json');
|
||||
|
||||
module.exports = {
|
||||
name: 'sendonlinemessage',
|
||||
description: "send an online message",
|
||||
type: 'ready',
|
||||
type: 'event',
|
||||
event: 'ready',
|
||||
|
||||
execute(client) {
|
||||
if (process.env.NODE_ENV !== 'dev') {
|
||||
@@ -1,9 +1,10 @@
|
||||
const statuses = require('../../config/statuses.json')
|
||||
const statuses = require('../../../config/statuses.json')
|
||||
|
||||
module.exports = {
|
||||
name: 'status',
|
||||
description: 'Sets the status of the bot',
|
||||
type: 'ready',
|
||||
type: 'event',
|
||||
event: 'ready',
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const { userMention, channelMention } = require('discord.js')
|
||||
const { botLogChannel, color } = require('../../config/options.json')
|
||||
const { botLogChannel, color } = require('../../../config/options.json')
|
||||
|
||||
module.exports = {
|
||||
name: 'vcJoinLeave',
|
||||
description: 'Logs when a user joins or leaves a voice channel.',
|
||||
type: 'other',
|
||||
type: 'event',
|
||||
event: 'voiceStateUpdate',
|
||||
|
||||
/**
|
||||
20
index.js
20
index.js
@@ -1,14 +1,5 @@
|
||||
const { Client, GatewayIntentBits, Partials, Collection } = require('discord.js');
|
||||
const {
|
||||
loadSlashCommands,
|
||||
loadMessageEvents,
|
||||
loadContextMenu,
|
||||
loadModalEvents,
|
||||
loadButtonEvents,
|
||||
loadReadyEvents,
|
||||
loadInteractionEvents,
|
||||
loadOtherEvents
|
||||
} = require('./utils/eventHandler.js')
|
||||
const { loadSlashCommandsEvents, loadContextMenuEvents, loadModalEvents, loadButtonEvents, loadEvents } = require('./utils/eventHandler.js')
|
||||
const { autoDeployCommands } = require('./utils/autodeploy.js');
|
||||
require('dotenv').config();
|
||||
const mongoURI = process.env.MONGOURI;
|
||||
@@ -44,14 +35,11 @@ client.commands = new Collection();
|
||||
client.events = new Collection();
|
||||
client.modals = new Collection();
|
||||
|
||||
loadSlashCommands(client);
|
||||
loadContextMenu(client);
|
||||
loadSlashCommandsEvents(client);
|
||||
loadContextMenuEvents(client);
|
||||
loadButtonEvents(client);
|
||||
loadModalEvents(client);
|
||||
loadMessageEvents(client);
|
||||
loadReadyEvents(client)
|
||||
loadInteractionEvents(client);
|
||||
loadOtherEvents(client);
|
||||
loadEvents(client);
|
||||
|
||||
client.login(token);
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
const { loadButtonEvents } = require('./eventHandlers/button.js')
|
||||
const { loadSlashCommands } = require('./eventHandlers/command.js')
|
||||
const { loadContextMenu } = require('./eventHandlers/contextmenu.js')
|
||||
const { loadMessageEvents } = require('./eventHandlers/message.js')
|
||||
const { loadSlashCommandsEvents } = require('./eventHandlers/command.js')
|
||||
const { loadContextMenuEvents } = require('./eventHandlers/contextmenu.js')
|
||||
const { loadModalEvents } = require('./eventHandlers/modal.js')
|
||||
const { loadReadyEvents } = require('./eventHandlers/ready.js')
|
||||
const { loadInteractionEvents } = require('./eventHandlers/interaction.js')
|
||||
const { loadOtherEvents } = require('./eventHandlers/other.js')
|
||||
const { loadEvents } = require('./eventHandlers/events.js')
|
||||
|
||||
module.exports = {
|
||||
loadSlashCommands,
|
||||
loadSlashCommandsEvents,
|
||||
loadButtonEvents,
|
||||
loadContextMenu,
|
||||
loadMessageEvents,
|
||||
loadContextMenuEvents,
|
||||
loadModalEvents,
|
||||
loadReadyEvents,
|
||||
loadInteractionEvents,
|
||||
loadOtherEvents
|
||||
loadEvents
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadSlashCommands(client) {
|
||||
function loadSlashCommandsEvents(client) {
|
||||
const cmdPath = path.join(__dirname, '..', '..', 'commands');
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
@@ -60,4 +60,4 @@ function loadSlashCommands(client) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { loadSlashCommands }
|
||||
module.exports = { loadSlashCommandsEvents }
|
||||
|
||||
@@ -4,7 +4,7 @@ const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadContextMenu(client) {
|
||||
function loadContextMenuEvents(client) {
|
||||
const contextMenuPath = path.join(__dirname, '..', '..', 'commands-contextmenu');
|
||||
const contextMenuFiles = fs.readdirSync(contextMenuPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
@@ -44,4 +44,4 @@ function loadContextMenu(client) {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { loadContextMenu }
|
||||
module.exports = { loadContextMenuEvents }
|
||||
|
||||
24
utils/eventHandlers/events.js
Normal file
24
utils/eventHandlers/events.js
Normal file
@@ -0,0 +1,24 @@
|
||||
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 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') {
|
||||
client.on(event.event, event.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The event at ${eventPath} is missing a required "name", "execute", "type" or "event" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = { loadEvents }
|
||||
@@ -1,23 +0,0 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadInteractionEvents(client) {
|
||||
const interactionsPath = path.join(__dirname, '..', '..', 'events', 'interactions')
|
||||
const interactionsFiles = fs.readdirSync(interactionsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of interactionsFiles) {
|
||||
const filePath = path.join(interactionsPath, file);
|
||||
const interactionFile = require(filePath);
|
||||
|
||||
if ('name' in interactionFile && 'execute' in interactionFile && interactionFile.type === 'interaction') {
|
||||
client.on(Events.InteractionCreate, interactionFile.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The interactions event at ${filePath} is missing a required "name", "execute" or "type" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadInteractionEvents }
|
||||
@@ -1,24 +0,0 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadMessageEvents(client) {
|
||||
const messagePath = path.join(__dirname, '..', '..', 'events', 'messages');
|
||||
const messageFiles = fs.readdirSync(messagePath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of messageFiles) {
|
||||
|
||||
const filePath = path.join(messagePath, file);
|
||||
const message = require(filePath);
|
||||
|
||||
if (message.type === 'message') {
|
||||
client.on(Events.MessageCreate, message.execute);
|
||||
} else {
|
||||
console.log(`[WARNING] The message at ${filePath} is missing a required "type" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadMessageEvents }
|
||||
@@ -1,22 +0,0 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadOtherEvents(client) {
|
||||
const otherPath = path.join(__dirname, '..', '..', 'events', 'other')
|
||||
const otherFiles = fs.readdirSync(otherPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of otherFiles) {
|
||||
const filePath = path.join(otherPath, file);
|
||||
const other = require(filePath);
|
||||
|
||||
if ('name' in other && 'execute' in other && 'event' in other && other.type === 'other') {
|
||||
client.on(other.event, other.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The other event at ${filePath} is missing a required "name", "execute", "type" or "event" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadOtherEvents }
|
||||
@@ -1,23 +0,0 @@
|
||||
const { Events } = require('discord.js')
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadReadyEvents(client) {
|
||||
const readyPath = path.join(__dirname, '..', '..', 'events', 'ready')
|
||||
const readyFiles = fs.readdirSync(readyPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of readyFiles) {
|
||||
const filePath = path.join(readyPath, file);
|
||||
const ready = require(filePath);
|
||||
|
||||
if ('name' in ready && 'execute' in ready && ready.type === 'ready') {
|
||||
client.on(Events.ClientReady, ready.execute)
|
||||
} else {
|
||||
console.log(`[WARNING] The ready event at ${filePath} is missing a required "name", "execute" or "type" property.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { loadReadyEvents }
|
||||
Reference in New Issue
Block a user