More intents and partials. Don't load process event if NODE_ENV is development and log loaded commands

This commit is contained in:
Supositware 2022-08-28 17:02:22 +02:00
parent 3ec5d0525b
commit bb49cfd490

View file

@ -1,15 +1,19 @@
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { Client, Collection, Intents } from 'discord.js'; import { Client, Collection, GatewayIntentBits, Partials } from 'discord.js';
import dotenv from 'dotenv'; import dotenv from 'dotenv';
dotenv.config(); dotenv.config();
const { token } = process.env; const { token, NODE_ENV } = process.env;
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
const client = new Client({ intents: [Intents.FLAGS.GUILDS], shards: 'auto' }); const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildMembers],
partials: [Partials.Message, Partials.Reaction, Partials.Channel],
shards: 'auto',
});
// Load commands // Load commands
client.commands = new Collection(); client.commands = new Collection();
@ -20,7 +24,9 @@ await loadCommandFromDir('owner');
// Load events // Load events
await loadEventFromDir('client', client); await loadEventFromDir('client', client);
if (NODE_ENV !== 'development') {
await loadEventFromDir('process', process); await loadEventFromDir('process', process);
}
client.login(token); client.login(token);
@ -34,6 +40,7 @@ async function loadCommandFromDir(dir) {
command = command.default; command = command.default;
client.commands.set(command.data.name, command); client.commands.set(command.data.name, command);
console.log(`Successfully loaded command \x1b[32m${command.category}/${command.data.name}\x1b[0m`);
} }
} }