Compare commits
No commits in common. "2c5dbdf0387722fc4e47f76d2e6b0627f202f299" and "a4eab091c78cab9c91e93c728aed25c4c5a39c7d" have entirely different histories.
2c5dbdf038
...
a4eab091c7
8 changed files with 42 additions and 41 deletions
|
@ -3,7 +3,7 @@ import { MessageEmbed, MessageActionRow, MessageSelectMenu } from 'discord.js';
|
|||
import { exec } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import utils from '../../utils/videos.js';
|
||||
import utils from '../utils/videos.js';
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
|
@ -5,6 +5,6 @@ export default {
|
|||
.setName('ping')
|
||||
.setDescription('Replies with Pong!'),
|
||||
async execute(interaction) {
|
||||
await interaction.reply(`Pong! \`${Math.round(interaction.client.ws.ping)} ms\``);
|
||||
await interaction.reply('Pong!');
|
||||
},
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
import { SlashCommandBuilder } from '@discordjs/builders';
|
||||
import utils from '../../utils/videos.js';
|
||||
import utils from '../utils/videos.js';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
@ -55,7 +55,7 @@ export default {
|
|||
|
||||
async function gifski(output, input) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
exec(`gifski --quality 70 -o ${output} ${input}`, (err, stdout, stderr) => {
|
||||
exec(`gifski -o ${output} ${input}`, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
export default {
|
||||
name: 'uncaughtException',
|
||||
async execute(error) {
|
||||
return console.error(`\x1b[31mUncaughtException: ${error}\x1b[37m`);
|
||||
},
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
export default {
|
||||
name: 'unhandledRejection',
|
||||
once: true,
|
||||
async execute(error) {
|
||||
return console.error(`\x1b[31mUncaught Promise Rejection: ${error}\x1b[37m`);
|
||||
console.error('Unhandled promise rejection:', error);
|
||||
},
|
||||
};
|
||||
|
|
46
index.js
46
index.js
|
@ -11,19 +11,9 @@ const __dirname = path.dirname(__filename);
|
|||
|
||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
||||
|
||||
// Load commands
|
||||
// Load commands from the commands folder
|
||||
client.commands = new Collection();
|
||||
await loadCommandFromDir('fun');
|
||||
await loadCommandFromDir('utility');
|
||||
|
||||
// Load events
|
||||
loadEventFromDir('client', client);
|
||||
loadEventFromDir('process', process);
|
||||
|
||||
client.login(token);
|
||||
|
||||
async function loadCommandFromDir(dir) {
|
||||
const commandsPath = path.join(`${__dirname}/commands`, dir);
|
||||
const commandsPath = path.join(__dirname, 'commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of commandFiles) {
|
||||
|
@ -33,21 +23,37 @@ async function loadCommandFromDir(dir) {
|
|||
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadEventFromDir(dir, listener) {
|
||||
const eventsPath = path.join(`${__dirname}/events`, dir);
|
||||
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
||||
// Load client events from the events folder
|
||||
const clientEventsPath = path.join(__dirname, 'events/client');
|
||||
const clientEventFiles = fs.readdirSync(clientEventsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const filePath = path.join(eventsPath, file);
|
||||
for (const file of clientEventFiles) {
|
||||
const filePath = path.join(clientEventsPath, file);
|
||||
let event = await import(filePath);
|
||||
event = event.default;
|
||||
if (event.once) {
|
||||
listener.once(event.name, (...args) => event.execute(...args));
|
||||
client.once(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
else {
|
||||
listener.on(event.name, (...args) => event.execute(...args));
|
||||
client.on(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
}
|
||||
|
||||
// Load process events from the events folder
|
||||
const processEventsPath = path.join(__dirname, 'events/process');
|
||||
const processEventFiles = fs.readdirSync(processEventsPath).filter(file => file.endsWith('.js'));
|
||||
|
||||
for (const file of processEventFiles) {
|
||||
const filePath = path.join(processEventsPath, file);
|
||||
let event = await import(filePath);
|
||||
event = event.default;
|
||||
if (event.once) {
|
||||
process.once(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
else {
|
||||
process.on(event.name, (...args) => event.execute(...args));
|
||||
}
|
||||
}
|
||||
|
||||
client.login(token);
|
||||
|
|
Loading…
Reference in a new issue