Update all packages to latest
This commit is contained in:
53
index.js
53
index.js
@@ -9,6 +9,7 @@ const fs = require('fs');
|
||||
require('dotenv').config();
|
||||
const libCore = require("./libCore");
|
||||
const libUtils = require("./libUtils");
|
||||
const deployCommands = require("./utilities/deployCommands");
|
||||
|
||||
const { DebugBuilder } = require("./utilities/debugBuilder");
|
||||
const log = new DebugBuilder("server", "index");
|
||||
@@ -20,15 +21,16 @@ const {
|
||||
//const Discord = require('discord.js');Client, Collection, Intents
|
||||
const {
|
||||
Client,
|
||||
Events,
|
||||
Collection,
|
||||
Intents,
|
||||
GatewayIntentBits,
|
||||
MessageActionRow,
|
||||
MessageButton
|
||||
} = require('discord.js');
|
||||
//const client = new Discord.Client();
|
||||
|
||||
const client = new Client({
|
||||
intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS]
|
||||
intents: [GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds]
|
||||
});
|
||||
|
||||
prefix = process.env.PREFIX
|
||||
@@ -107,12 +109,15 @@ const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('
|
||||
//const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||
for (const file of commandFiles) {
|
||||
const filePath = path.join(commandsPath, file);
|
||||
const command = require(filePath);
|
||||
const command = require(filePath);
|
||||
// Set a new item in the Collection
|
||||
// With the key as the command name and the value as the exported module
|
||||
client.commands.set(command.name, command);
|
||||
client.commands.set(command.data.name, command);
|
||||
}
|
||||
|
||||
// Deploy commands
|
||||
deployCommands.deploy(client.guilds.cache.map(guild => guild.id));
|
||||
|
||||
client.on('ready', () => {
|
||||
log.DEBUG(`Discord server up and running with client: ${client.user.tag}`);
|
||||
log.DEBUG(`Starting HTTP Server`);
|
||||
@@ -122,38 +127,26 @@ client.on('ready', () => {
|
||||
log.INFO("HTTP server started!");
|
||||
});
|
||||
|
||||
client.on('interactionCreate', async interaction => {
|
||||
//if (!interaction.isCommand()) return;
|
||||
if (!interaction.isSelectMenu()) return;
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
let aaa = interaction.values[0];
|
||||
await interaction.channel.send({
|
||||
content: 'You picked something',
|
||||
ephemeral: true
|
||||
});
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
log.DEBUG("Interaction: ", interaction.client.commands);
|
||||
|
||||
try {
|
||||
//await command.execute(interaction);
|
||||
} catch (error) {
|
||||
log.ERROR(error);
|
||||
//console.error(error);
|
||||
//await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||
if (!command) {
|
||||
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
client.on('messageCreate', message => {
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
|
||||
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
||||
const command = args.shift().toLowerCase();
|
||||
|
||||
if (!client.commands.has(command)) return;
|
||||
|
||||
try {
|
||||
client.commands.get(command).execute(message, args);
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
log.ERROR(error);
|
||||
//message.reply('there was an error trying to execute that command!');
|
||||
console.error(error);
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||
} else {
|
||||
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user