Update all packages to latest
This commit is contained in:
@@ -1,7 +1,18 @@
|
|||||||
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
|
|
||||||
|
// TODO - Add insults as the response to this command
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'ping',
|
data: new SlashCommandBuilder()
|
||||||
description: 'Ping!',
|
.setName('ping')
|
||||||
execute(message) {
|
.setDescription('Replies with your input!'),
|
||||||
message.channel.send('**Pong.**');
|
/*
|
||||||
|
.addStringOption(option =>
|
||||||
|
option.setName('input')
|
||||||
|
.setDescription('The input to echo back')),
|
||||||
|
*/
|
||||||
|
example: "ping",
|
||||||
|
isPrivileged: false,
|
||||||
|
async execute(message) {
|
||||||
|
await message.channel.send('**Pong.**');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
53
index.js
53
index.js
@@ -9,6 +9,7 @@ const fs = require('fs');
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const libCore = require("./libCore");
|
const libCore = require("./libCore");
|
||||||
const libUtils = require("./libUtils");
|
const libUtils = require("./libUtils");
|
||||||
|
const deployCommands = require("./utilities/deployCommands");
|
||||||
|
|
||||||
const { DebugBuilder } = require("./utilities/debugBuilder");
|
const { DebugBuilder } = require("./utilities/debugBuilder");
|
||||||
const log = new DebugBuilder("server", "index");
|
const log = new DebugBuilder("server", "index");
|
||||||
@@ -20,15 +21,16 @@ const {
|
|||||||
//const Discord = require('discord.js');Client, Collection, Intents
|
//const Discord = require('discord.js');Client, Collection, Intents
|
||||||
const {
|
const {
|
||||||
Client,
|
Client,
|
||||||
|
Events,
|
||||||
Collection,
|
Collection,
|
||||||
Intents,
|
GatewayIntentBits,
|
||||||
MessageActionRow,
|
MessageActionRow,
|
||||||
MessageButton
|
MessageButton
|
||||||
} = require('discord.js');
|
} = require('discord.js');
|
||||||
//const client = new Discord.Client();
|
//const client = new Discord.Client();
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS]
|
intents: [GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds]
|
||||||
});
|
});
|
||||||
|
|
||||||
prefix = process.env.PREFIX
|
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'));
|
//const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
const command = require(filePath);
|
const command = require(filePath);
|
||||||
// Set a new item in the Collection
|
// Set a new item in the Collection
|
||||||
// With the key as the command name and the value as the exported module
|
// 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', () => {
|
client.on('ready', () => {
|
||||||
log.DEBUG(`Discord server up and running with client: ${client.user.tag}`);
|
log.DEBUG(`Discord server up and running with client: ${client.user.tag}`);
|
||||||
log.DEBUG(`Starting HTTP Server`);
|
log.DEBUG(`Starting HTTP Server`);
|
||||||
@@ -122,38 +127,26 @@ client.on('ready', () => {
|
|||||||
log.INFO("HTTP server started!");
|
log.INFO("HTTP server started!");
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('interactionCreate', async interaction => {
|
client.on(Events.InteractionCreate, async interaction => {
|
||||||
//if (!interaction.isCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
if (!interaction.isSelectMenu()) return;
|
|
||||||
|
|
||||||
let aaa = interaction.values[0];
|
const command = interaction.client.commands.get(interaction.commandName);
|
||||||
await interaction.channel.send({
|
log.DEBUG("Interaction: ", interaction.client.commands);
|
||||||
content: 'You picked something',
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
if (!command) {
|
||||||
//await command.execute(interaction);
|
console.error(`No command matching ${interaction.commandName} was found.`);
|
||||||
} catch (error) {
|
return;
|
||||||
log.ERROR(error);
|
|
||||||
//console.error(error);
|
|
||||||
//await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
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 {
|
try {
|
||||||
client.commands.get(command).execute(message, args);
|
await command.execute(interaction);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.ERROR(error);
|
console.error(error);
|
||||||
//message.reply('there was an error trying to execute that command!');
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
38
package.json
38
package.json
@@ -4,22 +4,21 @@
|
|||||||
"description": "Discord RSS News Bot",
|
"description": "Discord RSS News Bot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/builders": "^0.15.0",
|
"@discordjs/builders": "~1.4.0",
|
||||||
"@discordjs/rest": "^0.5.0",
|
"@discordjs/rest": "~1.5.0",
|
||||||
"axios": "^0.24.0",
|
"axios": "~1.3.4",
|
||||||
"chatgpt": "^1.4.0",
|
"chatgpt": "~4.7.2",
|
||||||
"discord-api-types": "^0.35.0",
|
"discord-api-types": "~0.37.35",
|
||||||
"discord.js": "^13.8.1",
|
"discord.js": "~14.7.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "~16.0.3",
|
||||||
"express": "^4.17.1",
|
"express": "~4.18.2",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "~0.0.1-security",
|
||||||
"js-doc": "^0.5.0",
|
"jsdoc": "~3.6.7",
|
||||||
"jsonfile": "^6.1.0",
|
"jsonfile": "~6.1.0",
|
||||||
"mathjs": "^10.6.4",
|
"openai": "~3.1.0",
|
||||||
"openai": "^3.1.0",
|
"parse-files": "~0.1.1",
|
||||||
"parse-files": "^0.1.1",
|
"rss-parser": "~3.12.0",
|
||||||
"rss-parser": "^3.12.0",
|
"mysql": "~2.18.1",
|
||||||
"mysql": "2.18.1",
|
|
||||||
"cookie-parser": "~1.4.4",
|
"cookie-parser": "~1.4.4",
|
||||||
"debug": "~2.6.9",
|
"debug": "~2.6.9",
|
||||||
"ejs": "~2.6.1",
|
"ejs": "~2.6.1",
|
||||||
@@ -30,9 +29,6 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "node index.js"
|
"start": "node index.js"
|
||||||
},
|
},
|
||||||
"author": "John Facey",
|
"author": "Logan Cusano",
|
||||||
"license": "ISC",
|
"license": "ISC"
|
||||||
"devDependencies": {
|
|
||||||
"jsdoc": "^3.6.7"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
45
utilities/deployCommands.js
Normal file
45
utilities/deployCommands.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
const { REST, Routes } = require('discord.js');
|
||||||
|
|
||||||
|
require('dotenv').config();
|
||||||
|
const token = process.env.TOKEN;
|
||||||
|
const clientId = process.env.clientId;
|
||||||
|
const guildId = process.env.guildId;
|
||||||
|
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
const commands = [];
|
||||||
|
// Grab all the command files from the commands directory you created earlier
|
||||||
|
const commandsPath = path.resolve('./commands');
|
||||||
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
exports.deploy = (guildIDs) => {
|
||||||
|
if (Array.isArray(guildIDs)) guildIDs = [guildIDs];
|
||||||
|
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
const command = require(`${path.resolve(commandsPath, file)}`);
|
||||||
|
commands.push(command.data.toJSON());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct and prepare an instance of the REST module
|
||||||
|
const rest = new REST({ version: '10' }).setToken(token);
|
||||||
|
|
||||||
|
// and deploy your commands!
|
||||||
|
for (const guildId of guildIDs){
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
console.log(`Started refreshing ${commands.length} application (/) commands for guild ID: ${guildId}.`);
|
||||||
|
// The put method is used to fully refresh all commands in the guild with the current set
|
||||||
|
const data = await rest.put(
|
||||||
|
Routes.applicationGuildCommands(clientId, guildId),
|
||||||
|
{ body: commands },
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`Successfully reloaded ${data.length} application (/) commands for guild ID: ${guildId}.`);
|
||||||
|
} catch (error) {
|
||||||
|
// And of course, make sure you catch and log any errors!
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user