A powerful and extendable Discord bot, with it's own module system :3 thevoid.cafe/projects/voidy

♻️ Add DB_URI env variable and reformat some code

Jo 7638b7b1 f3871cd0

+20 -9
+3 -2
.env.example
··· 1 - BOT_TOKEN=#Get this from https://discord.com/developers REQUIRED 2 - BOT_CLIENT_ID=#Get this from https://discord.com/developers REQUIRED 1 + BOT_TOKEN=#Get this from https://discord.com/developers - REQUIRED 2 + BOT_CLIENT_ID=#Get this from https://discord.com/developers - REQUIRED 3 + DB_URI=#Your MongoDB connection URI - REQUIRED
+2 -1
deno.json
··· 10 10 "@discord.js/builders": "npm:@discordjs/builders@1.10.0", 11 11 "discord-api-types/payloads": "npm:discord-api-types@0.37.118/payloads", 12 12 "mongoose": "npm:mongoose@^8.10.1" 13 - } 13 + }, 14 + "nodeModulesDir": "auto" 14 15 }
+15 -6
src/index.ts
··· 6 6 import * as mongoose from "mongoose"; 7 7 8 8 // Create bot client instance 9 - const client = new VoidyClient({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent] }); 9 + const client = new VoidyClient({ 10 + intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent], 11 + }); 10 12 11 13 // Attempt database connection 12 - await mongoose.connect("mongodb://127.0.0.1:27017/voidy").then(() => { 13 - console.log("[Voidy] Successfully connected to database at 127.0.0.1:27017"); 14 + await mongoose 15 + .connect(Deno.env.get("DB_URI") ?? "mongodb://") 16 + .then(() => { 17 + console.log( 18 + "[Voidy] Successfully connected to database!", 19 + ); 14 20 console.log(""); 15 - }).catch((err) => { 21 + }) 22 + .catch((err) => { 16 23 console.error("[Voidy] Database error: ", err); 17 24 Deno.exit(1); 18 - }); 25 + }); 19 26 20 27 // Handle standalone commands and events 21 28 await CommandHandler.loadCommands(client, ["src/commands"]); ··· 25 32 await FeatureHandler.loadAll(client, ["src/features"]); 26 33 27 34 // Login using the specified token 28 - client.login(Deno.env.get("BOT_TOKEN")).then(() => console.log("[Voidy] Successfully logged in!")); 35 + client 36 + .login(Deno.env.get("BOT_TOKEN")) 37 + .then(() => console.log("[Voidy] Successfully logged in!"));