# This is a combination of 12 commits.

# This is the 1st commit message:

Initial commit
# This is the commit message #2:

added whole syswtem

becuz i forgot to keep up with the github

# This is the commit message #3:

hihi hiha

# This is the commit message #4:

added startServer.sh

# This is the commit message #5:

hihi hiha

# This is the commit message #6:

fixed some packages

# This is the commit message #7:

fixed every bug with the stupid oop

# This is the commit message #8:

Revert "fixed every bug with the stupid oop"

This reverts commit d2255863aa44e2504f9f2cec9e1ae5d1094cb9cd.

# This is the commit message #9:

added prevention of breaking the system by manually filling in the project id

# This is the commit message #10:

fixed bug when adding bot

# This is the commit message #11:

made user-id not just count up from 0

# This is the commit message #12:

fixed the issue where if you load project page it woulnt show the commands until you refresh the page
This commit is contained in:
Valentijn :)
2023-11-24 11:04:00 +01:00
committed by HerpieDerpie@example.com
commit 48a5a3576d
20 changed files with 3712 additions and 0 deletions

55
example_bot/bot.js Executable file
View File

@@ -0,0 +1,55 @@
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { updateCommands } = require("./updateCommands");
const { token } = require('./config.json');
const fs = require('node:fs');
const path = require('node:path');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
updateCommands();
/** REGISTER COMMANDS **/
client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);
for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
/** SLASH COMMAND HANDLER **/
client.on(Events.InteractionCreate, async interaction => {
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
if (command) {
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (!(interaction.replied || interaction.deferred)) {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
} else {
console.error(`No command matching ${interaction.commandName} was found.`);
}
}
});
/** READY SEQUENCE **/
client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
client.login(token);