Skip to content

Commit 6799225

Browse files
author
xyzjesper
committed
Fixed Logger Helper
1 parent 872e2e6 commit 6799225

File tree

3 files changed

+5
-152
lines changed

3 files changed

+5
-152
lines changed

src/api/services/loggerApi.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/helper/loggingHelper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
ActionRowBuilder,
3-
AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelSelectMenuBuilder,
3+
AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelSelectMenuBuilder, ChannelType,
44
ContainerBuilder,
55
FileBuilder,
66
MessageFlags, SeparatorBuilder, SeparatorSpacingSize,
@@ -58,6 +58,7 @@ export async function loggingHelper(
5858
new ActionRowBuilder<ChannelSelectMenuBuilder>().addComponents(
5959
new ChannelSelectMenuBuilder()
6060
.setCustomId("logging-to-channel:" + uuid)
61+
.setChannelTypes(ChannelType.GuildText, ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.AnnouncementThread, ChannelType.GuildAnnouncement)
6162
)
6263
)
6364
.addFileComponents(

src/main/logger.ts

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "discord.js";
1414
import color from "colors";
1515
import {randomUUID} from "crypto";
16-
import {Config} from "./config.js";
16+
import {Config, configStartup} from "./config.js";
1717

1818
color.enable();
1919

@@ -30,57 +30,6 @@ class DiscordTransport extends Transport {
3030

3131
const uuid = randomUUID();
3232

33-
// const data = await database.disBot.findFirst({
34-
// where: {
35-
// GetConf: "config"
36-
// }
37-
// });
38-
// if (data) {
39-
// if (data.Logs.length >= 1000) {
40-
// data.Logs.forEach(async (log) => {
41-
// if (log.UUID === uuid) return;
42-
// const logDate = new Date(log.Timestamp as string);
43-
// const now = new Date();
44-
// const diff = now.getTime() - logDate.getTime();
45-
// if (diff > ms("10m")) {
46-
// await database.disBot.update(
47-
// {
48-
// where: { GetConf: "config", },
49-
// data: {
50-
// Logs: {
51-
// set: data.Logs.filter((f) => f.UUID != log.UUID)
52-
// }
53-
// }
54-
// }
55-
// );
56-
// }
57-
// });
58-
// }
59-
// }
60-
61-
// await database.disBot.update(
62-
// {
63-
// where: { GetConf: "config", },
64-
// data: {
65-
// Logs: {
66-
// push: {
67-
// UUID: uuid.toString(),
68-
// GuildId: info.guildId ? info.guildId : "0",
69-
// UserId: info.userId ? info.userId : "0",
70-
// ChannelId: info.channelId ? info.channelId : "0",
71-
// MessageId: info.messageId ? info.messageId : "0",
72-
// Timestamp: info.timestamp ? info.timestamp : new Date().toISOString(),
73-
// Level: info.level ? info.level : "info",
74-
// Label: info.label ? info.label : "General",
75-
// Message: info.message ? info.message : "No message provided",
76-
// BotType: Config.BotType.toString() || "Unknown",
77-
// Action: info.action
78-
// }
79-
// }
80-
// }
81-
// })
82-
83-
const logUrl = `https://logs.disbot.app/log/${uuid}`;
8433
const emoji = this.getEmoji(info.level);
8534

8635
let truncatedMessage = "";
@@ -105,14 +54,6 @@ class DiscordTransport extends Transport {
10554
`**Bot Type:** ${Config.BotType.toString() || "Unknown"}`,
10655
`**Action:** ${info.action}`,
10756
].join("\n"))
108-
).addActionRowComponents(
109-
new ActionRowBuilder<ButtonBuilder>()
110-
.addComponents(
111-
new ButtonBuilder()
112-
.setLabel("View Log")
113-
.setStyle(ButtonStyle.Link)
114-
.setURL(logUrl)
115-
)
11657
)
11758
this.webhook.send({
11859
components: [container],
@@ -144,6 +85,7 @@ class DiscordTransport extends Transport {
14485
}
14586
}
14687

88+
await configStartup();
14789
export const Logger = winston.createLogger({
14890
format: winston.format.combine(
14991
winston.format.timestamp({format: "YYYY-MM-DD HH:mm:ss"}),
@@ -160,7 +102,6 @@ export const Logger = winston.createLogger({
160102
),
161103
transports: [
162104
new winston.transports.Console(),
163-
// TODO: Fix DiscordExporter
164-
// new DiscordTransport({webhookUrl: Config.Logging.BotLogger})
105+
new DiscordTransport({webhookUrl: Config.Logging.BotLogger})
165106
],
166107
});

0 commit comments

Comments
 (0)