Skip to content

Commit

Permalink
Refactor all code and update everything to the latest template (#351)
Browse files Browse the repository at this point in the history
* Delete the package-lock.json file and reinstall.

* Delete all the old files from the src folder and create new ones.

* Add the initial code to run the bot in the index file.

* Add the events/ready section and implement a new loadEvents method that is more modern and efficient by switching to ESM.

* Apply the changes in the index.js and test them.

* Change from loading as interactionCreate in loadEvents and add a check.

* Add command loading and add interaction handling for each command properly.

* Update version to 2.0.0 from the old 1.0.0

* Update SECURITY.md
  • Loading branch information
NekoSakuraLucia authored Jan 5, 2025
1 parent 768d26b commit 180ace3
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 149 deletions.
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
| 1.x.x ||
| 2.x.x ||

## Reporting a Vulnerability

Expand Down
116 changes: 78 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-bot-template",
"version": "1.0.0",
"version": "2.0.0",
"description": "Discord bot template",
"main": "src/index.js",
"type": "module",
Expand Down
3 changes: 0 additions & 3 deletions src/commands/index.js

This file was deleted.

8 changes: 3 additions & 5 deletions src/commands/ping.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { SlashCommandBuilder } from 'discord.js';

export const ping = {
export default {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
await interaction.reply('Pong!!!!');
await interaction.reply('Pong!');
}
};

export default ping;
23 changes: 0 additions & 23 deletions src/deploy.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/events/index.js

This file was deleted.

20 changes: 20 additions & 0 deletions src/events/interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default {
once: false,
async execute(interaction) {
if (!interaction.isCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

if (!command) {
console.warn(`⚠️ Command not found: ${interaction.commandName}`);
return;
}

try {
await command.execute(interaction);
} catch (error) {
console.error(`❌ Error executing command: ${error.message}`);
await interaction.reply({ content: 'There was an error executing this command!', ephemeral: true });
}
}
};
20 changes: 0 additions & 20 deletions src/events/interactions.js

This file was deleted.

13 changes: 2 additions & 11 deletions src/events/ready.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import chalk from 'chalk';

export const ready = {
name: 'ready',
export default {
once: true,
execute(client) {
console.log(
chalk.bgBlueBright.black(
` Successfully logged in as: ${client.user.tag} `
)
);
console.log(`Logged in as ${client.user.tag}`);
}
};

export default ready;
Loading

0 comments on commit 180ace3

Please sign in to comment.