mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 16:55:55 +00:00
update logs to make them nicer and set dicsord activity
This commit is contained in:
parent
6ee0b874b5
commit
213fdbc582
3 changed files with 28 additions and 39 deletions
|
@ -17,7 +17,8 @@ module.exports = {
|
||||||
|
|
||||||
if (!code) {
|
if (!code) {
|
||||||
return interaction.reply({
|
return interaction.reply({
|
||||||
content: "Please provide the verification code.",
|
content:
|
||||||
|
"Please provide the verification code sent to your DCU email address.",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ const transporter = nodemailer.createTransport({
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName("verify")
|
.setName("verify")
|
||||||
.setDescription("Verify your account with an email address")
|
.setDescription("Verify your account with your DCU email address")
|
||||||
.addStringOption((option) =>
|
.addStringOption((option) =>
|
||||||
option
|
option
|
||||||
.setName("email")
|
.setName("email")
|
||||||
|
|
60
index.js
60
index.js
|
@ -1,14 +1,8 @@
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const {
|
|
||||||
Client,
|
|
||||||
GatewayIntentBits,
|
|
||||||
Collection,
|
|
||||||
REST,
|
|
||||||
Routes,
|
|
||||||
} = require("discord.js");
|
|
||||||
const mongoose = require("mongoose");
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
const { Client, GatewayIntentBits, Collection } = require("discord.js");
|
||||||
|
const mongoose = require("mongoose");
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [
|
intents: [
|
||||||
|
@ -18,41 +12,39 @@ const client = new Client({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const GUIlD_ID = process.env.GUILD_ID;
|
|
||||||
|
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
|
||||||
|
// Load command files dynamically
|
||||||
|
const commandsPath = path.join(__dirname, "commands");
|
||||||
const commandFiles = fs
|
const commandFiles = fs
|
||||||
.readdirSync(path.join(__dirname, "commands"))
|
.readdirSync(commandsPath)
|
||||||
.filter((file) => file.endsWith(".js"));
|
.filter((file) => file.endsWith(".js"));
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const command = require(`./commands/${file}`);
|
const filePath = path.join(commandsPath, file);
|
||||||
|
const command = require(filePath);
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.once("ready", async () => {
|
client.once("ready", () => {
|
||||||
console.log(`Logges in as ${client.user.tag}`);
|
console.log(`\n==============================`);
|
||||||
|
console.log(`🤖 Logged in as ${client.user.tag}`);
|
||||||
const commands = client.commands.map((cmd) => cmd.data.toJSON());
|
console.log(`==============================`);
|
||||||
|
console.log(`📋 Registered Commands:\n`);
|
||||||
const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN);
|
client.commands.forEach((command) => {
|
||||||
|
console.log(`🔹 /${command.data.name} - ${command.data.description}`);
|
||||||
try {
|
|
||||||
await rest.put(Routes.applicationGuildCommands(client.user.id, GUIlD_ID), {
|
|
||||||
body: commands,
|
|
||||||
});
|
|
||||||
console.log("Successfully registered application commands.");
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Error registering application commands:", err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
console.log(`\n==============================\n`);
|
||||||
|
|
||||||
// MongoDB connection
|
// Set the bot's activity here
|
||||||
|
client.user.setActivity("Degenerate Gamers", { type: "WATCHING" });
|
||||||
|
|
||||||
|
// Database connection (MongoDB)
|
||||||
mongoose
|
mongoose
|
||||||
.connect(process.env.MONGODB_URI)
|
.connect(process.env.MONGODB_URI)
|
||||||
.then(() => console.log("Connected to MongoDB"))
|
.then(() => console.log("✅ Connected to MongoDB"))
|
||||||
.catch((err) => console.error("Failed to connect to MongoDB", err));
|
.catch((err) => console.error("❌ Failed to connect to MongoDB", err));
|
||||||
|
});
|
||||||
|
|
||||||
client.on("interactionCreate", async (interaction) => {
|
client.on("interactionCreate", async (interaction) => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
|
@ -63,8 +55,8 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await command.execute(interaction, client);
|
await command.execute(interaction, client);
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
console.error(err);
|
console.error(error);
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: "There was an error while executing this command!",
|
content: "There was an error while executing this command!",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
|
@ -72,8 +64,4 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("Error", (err) => {
|
|
||||||
console.error("Client error:", err);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.login(process.env.BOT_TOKEN);
|
client.login(process.env.BOT_TOKEN);
|
||||||
|
|
Loading…
Reference in a new issue