Files
commands
interactions
config.json
database.js
deploy-commands.js
index.js
package.json
panelBuilder.js
roblox.js
Code
13 529
index.js
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const fs = require('fs');
const path = require('path');
require('dotenv').config();
const { handleVerifyButton } = require('./interactions/verifyButton');
const { handleVerifyModal } = require('./interactions/verifyModal');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers
]
});
client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(path.join(commandsPath, file));
client.commands.set(command.data.name, command);
}
client.once('ready', () => {
console.log(`Bot is ready! Logged in as ${client.user.tag}`);
});
client.on('interactionCreate', async interaction => {
try {
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
if (!command) return;
await command.execute(interaction);
return;
}
if (interaction.isButton()) {
if (interaction.customId === 'roblox_verify_start') {
await handleVerifyButton(interaction);
}
return;
}
if (interaction.isModalSubmit()) {
if (interaction.customId === 'roblox_verify_modal') {
await handleVerifyModal(interaction);
}
return;
}
} catch (error) {
console.error('Error handling interaction:', error);
if (interaction.isRepliable()) {
const errorMessage = { content: 'An error occurred while processing your request.', ephemeral: true };
if (interaction.deferred || interaction.replied) {
await interaction.editReply(errorMessage);
} else {
await interaction.reply(errorMessage);
}
}
}
});
client.on('error', error => {
console.error('Client error:', error);
});
client.login(process.env.DISCORD_TOKEN);