19
src/index.js
19
src/index.js
@@ -1,11 +1,13 @@
|
||||
const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js")
|
||||
const { loadSlashCommandsEvents, loadContextMenuEvents, loadModalEvents, loadButtonEvents, loadEvents, loadAutocompleteEvents } = require("./utils/eventHandler.js")
|
||||
const { Client, GatewayIntentBits, Partials } = require("discord.js")
|
||||
const { autoDeployCommands } = require("./utils/autodeploy.js")
|
||||
const { loadAllEvents } = require("./utils/loadEvents.js")
|
||||
const { init } = require("./utils/init.js")
|
||||
require("dotenv").config()
|
||||
const mongoURI = process.env.MONGOURI
|
||||
const { connect } = require("mongoose")
|
||||
|
||||
init()
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
@@ -23,18 +25,7 @@ const client = new Client({
|
||||
]
|
||||
})
|
||||
|
||||
client.commands = new Collection()
|
||||
client.buttons = new Collection()
|
||||
client.modals = new Collection()
|
||||
client.autocomplete = new Collection()
|
||||
|
||||
init()
|
||||
loadSlashCommandsEvents(client)
|
||||
loadAutocompleteEvents(client)
|
||||
loadContextMenuEvents(client)
|
||||
loadButtonEvents(client)
|
||||
loadModalEvents(client)
|
||||
loadEvents(client)
|
||||
loadAllEvents(client)
|
||||
|
||||
let token = ""
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { Events } = require("discord.js")
|
||||
const { Events, Collection } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadAutocompleteEvents(client) {
|
||||
client.autocomplete = new Collection()
|
||||
|
||||
const autocompletePath = path.join(__dirname, "..", "..", "events", "autocomplete")
|
||||
const autocompleteFiles = fs.readdirSync(autocompletePath).filter(file => file.endsWith(".js"))
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { Events } = require("discord.js")
|
||||
const { Events, Collection } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadButtonEvents(client) {
|
||||
client.buttons = new Collection()
|
||||
|
||||
const btnPath = path.join(__dirname, "..", "..", "events", "buttons")
|
||||
const btnFiles = fs.readdirSync(btnPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { Events } = require("discord.js")
|
||||
const { Events, Collection } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadSlashCommandsEvents(client) {
|
||||
client.commands = new Collection()
|
||||
|
||||
const cmdPath = path.join(__dirname, "..", "..", "commands")
|
||||
const cmdFiles = fs.readdirSync(cmdPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const { Events } = require("discord.js")
|
||||
const { Events, Collection } = require("discord.js")
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
/** @param { import('discord.js').Client } client */
|
||||
|
||||
function loadModalEvents(client) {
|
||||
client.modals = new Collection()
|
||||
|
||||
const modalPath = path.join(__dirname, "..", "..", "events", "modals")
|
||||
const modalFiles = fs.readdirSync(modalPath).filter(file => file.endsWith(".js"))
|
||||
|
||||
|
||||
12
src/utils/loadEvents.js
Normal file
12
src/utils/loadEvents.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const { loadSlashCommandsEvents, loadContextMenuEvents, loadModalEvents, loadButtonEvents, loadEvents, loadAutocompleteEvents } = require("./eventHandler.js")
|
||||
|
||||
function loadAllEvents(client) {
|
||||
loadSlashCommandsEvents(client)
|
||||
loadAutocompleteEvents(client)
|
||||
loadContextMenuEvents(client)
|
||||
loadButtonEvents(client)
|
||||
loadModalEvents(client)
|
||||
loadEvents(client)
|
||||
}
|
||||
|
||||
module.exports = { loadAllEvents }
|
||||
Reference in New Issue
Block a user