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