Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
♻️ Misc cleanup and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Mayone committed Aug 22, 2022
1 parent b561bbf commit b83f40b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/database/connectDatabase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmbedBuilder } from "discord.js";
import { connect } from "mongoose";
import mongoose from "mongoose";

import { Heptagram } from "../interfaces/Heptagram";
import { heptagramErrorHandler } from "../modules/heptagramErrorHandler";
Expand All @@ -14,7 +14,21 @@ export const connectDatabase = async (
Heptagram: Heptagram
): Promise<boolean> => {
try {
await connect(Heptagram.configs.mongoUri);
const dbOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
autoIndex: false,
reconnectTries: 5,
reconnectInterval: 1000,
poolSize: 5,
connectTimeoutMS: 10000,
family: 4,
useFindAndModify: false,
};

await mongoose.connect(Heptagram.configs.mongoUri, dbOptions);
// eslint-disable-next-line require-atomic-updates
mongoose.Promise = global.Promise;

const databaseEmbed = new EmbedBuilder();
databaseEmbed.setTitle("Database connected!");
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void (async () => {
const Heptagram = new Client({
shards: "auto",
intents: IntentOptions,
allowedMentions: { parse: ["users", "roles"], repliedUser: true },
}) as Heptagram;

heptagramLogHandler.log("info", "Validating environment variables...");
Expand Down

0 comments on commit b83f40b

Please sign in to comment.