Refactor codebase to use ES modules, add logger utility, and update package dependencies

This commit is contained in:
2025-02-09 14:58:31 -05:00
parent 55b4111fe3
commit 876c3daa7f
10 changed files with 471 additions and 70 deletions
+3 -3
View File
@@ -6,8 +6,8 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
const { SlashCommandBuilder } = require('discord.js');
const axios = require('axios');
import { SlashCommandBuilder } from 'discord.js';
import axios from 'axios';
const config = {
webSearch: {
@@ -16,7 +16,7 @@ const config = {
},
};
module.exports = {
export default {
data: new SlashCommandBuilder()
.setName('ask')
.setDescription('Ask a question to the AI')
+3 -5
View File
@@ -6,12 +6,10 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js';
module.exports = {
data: new SlashCommandBuilder()
.setName('help')
.setDescription('Lists all available commands'),
export default {
data: new SlashCommandBuilder().setName('help').setDescription('Lists all available commands'),
async execute(interaction) {
const { commands } = interaction.client;
const helpEmbed = new EmbedBuilder()
+12 -16
View File
@@ -6,26 +6,23 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';
module.exports = {
// eslint-disable-next-line import/extensions
import logger from '../logger.js';
export default {
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('Kick a user from the server')
.addUserOption(option =>
option
.setName('target')
.setDescription('The user to kick')
.setRequired(true),
)
.addStringOption(option =>
option.setName('reason').setDescription('Reason for kicking'),
option.setName('target').setDescription('The user to kick').setRequired(true),
)
.addStringOption(option => option.setName('reason').setDescription('Reason for kicking'))
.setDefaultMemberPermissions(PermissionFlagsBits.KickMembers),
async execute(interaction) {
const target = interaction.options.getMember('target');
const reason =
interaction.options.getString('reason') ?? 'No reason provided';
const reason = interaction.options.getString('reason') ?? 'No reason provided';
if (!target) {
return interaction.reply({
@@ -36,21 +33,20 @@ module.exports = {
if (!target.kickable) {
return interaction.reply({
content:
'I cannot kick this user! They may have higher permissions than me.',
content: 'I cannot kick this user! They may have higher permissions than me.',
ephemeral: true,
});
}
try {
await target.kick(reason);
await interaction.reply({
return await interaction.reply({
content: `Successfully kicked ${target.user.tag}\nReason: ${reason}`,
ephemeral: true,
});
} catch (error) {
console.error(error);
await interaction.reply({
logger.error(error);
return interaction.reply({
content: 'There was an error trying to kick this user!',
ephemeral: true,
});
+3 -5
View File
@@ -6,12 +6,10 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
const { SlashCommandBuilder } = require('discord.js');
import { SlashCommandBuilder } from 'discord.js';
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
export default {
data: new SlashCommandBuilder().setName('ping').setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong! 🏓');
},
+2 -2
View File
@@ -6,9 +6,9 @@
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
import { SlashCommandBuilder, PermissionFlagsBits } from 'discord.js';
module.exports = {
export default {
data: new SlashCommandBuilder()
.setName('prune')
.setDescription('Prune up to 99 messages.')