commit
45125ada01
2 changed files with 14 additions and 14 deletions
|
@ -1,21 +1,22 @@
|
|||
import mongoose from "mongoose";
|
||||
import logger from "../../middlewares/logger";
|
||||
|
||||
// Function to connect to MongoDB server
|
||||
export const connect = async () => {
|
||||
await mongoose
|
||||
.connect(process.env.MONGO_URL)
|
||||
.then(async (connection) => {
|
||||
.then((connection) => {
|
||||
logger.info(`💾 Connected to database: ${connection.connection.name}`);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
logger.error("💾 Could not connect to database", e);
|
||||
.catch(() => {
|
||||
throw new Error("Error connecting to database.");
|
||||
});
|
||||
|
||||
mongoose.connection.on("error", async (error) => {
|
||||
logger.error(`💾 ${error}`);
|
||||
mongoose.connection.on("error", () => {
|
||||
throw new Error("Failed to connect to database.");
|
||||
});
|
||||
|
||||
mongoose.connection.on("warn", async (warning) => {
|
||||
mongoose.connection.on("warn", (warning) => {
|
||||
logger.warn(`💾 ${warning}`);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { BaseInteraction, EmbedBuilder, TextChannel } from "discord.js";
|
||||
import { BaseInteraction, ChannelType, EmbedBuilder } from "discord.js";
|
||||
import getEmbedConfig from "../../../helpers/getEmbedData";
|
||||
import logger from "../../../middlewares/logger";
|
||||
import guildSchema from "../../../models/guild";
|
||||
|
@ -26,9 +26,10 @@ export default {
|
|||
|
||||
const channel = client.channels.cache.get(`${guildData.audits.channelId}`);
|
||||
|
||||
if (channel === null) return;
|
||||
if (!channel) return;
|
||||
if (channel.type !== ChannelType.GuildText) return;
|
||||
|
||||
(channel as TextChannel)
|
||||
channel
|
||||
.send({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
|
@ -49,15 +50,13 @@ export default {
|
|||
}),
|
||||
],
|
||||
})
|
||||
.then(async () => {
|
||||
.then(() => {
|
||||
logger.debug(
|
||||
`Audit log sent for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})`
|
||||
);
|
||||
})
|
||||
.catch(async () => {
|
||||
logger.error(
|
||||
`Audit log failed to send for event interactionCreate in guild ${interaction?.guild?.name} (${interaction?.guild?.id})`
|
||||
);
|
||||
.catch(() => {
|
||||
logger.silly("Failed to send audit log for event interactionCreate");
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue