Skip to content

Commit 6992670

Browse files
Techbot121Meta Construct
authored andcommitted
add file count at the end of sounds
1 parent 774bf38 commit 6992670

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

app/services/discord/modules/webhook-handler.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const SERVER_EMOJI_MAP = {
8585
"1": "1️⃣",
8686
"2": "2️⃣",
8787
"3": "3️⃣",
88-
"4": "4️⃣"
88+
"4": "4️⃣",
8989
};
9090

9191
const REPO_SERVER_MAP = new Map([
@@ -114,7 +114,6 @@ export default async (bot: DiscordBot): Promise<void> => {
114114

115115
let webhook: Discord.Webhook;
116116
const bridge = await bot.container.getService("GameBridge");
117-
const chatWebhook = bridge.discordChatWH;
118117

119118
bot.discord.on("ready", async () => {
120119
const channel = bot.getTextChannel(bot.config.channels.publicCommits);
@@ -487,10 +486,21 @@ export default async (bot: DiscordBot): Promise<void> => {
487486
}, new Map<string, string[]>());
488487
}
489488

490-
const formatSounds = ([folderName, sounds]) =>
491-
`[**${folderName}**](https://github.com/Metastruct/garrysmod-chatsounds/tree/master/sound/chatsounds/autoadd/${folderName})\n${[...new Set(sounds)].map(s => `- \`${s}\``).join("\n")}`;
489+
const formatSounds = ([folderName, sounds]: [string, string[]]) => {
490+
// idk why but I feel like there has to be a better way to do this
491+
// but this seems fine after for now after 3 beer
492+
const soundCount = new Map<string, number>();
493+
for (const sound of sounds) {
494+
soundCount.set(sound, (soundCount.get(sound) ?? 0) + 1);
495+
}
496+
const fileName = Array.from(soundCount, ([sound, count]) => {
497+
return `- \`${sound}\`${count > 1 ? ` x${count}` : ""}`;
498+
}).join("\n");
499+
return `[**${folderName}**](https://github.com/Metastruct/garrysmod-chatsounds/tree/master/sound/chatsounds/autoadd/${folderName})\n${fileName}`;
500+
};
492501

493502
async function ChatsoundsPushHandler(event: EmitterWebhookEvent<"push">) {
503+
const chatWebhook = bridge.discordChatWH;
494504
const payload = event.payload;
495505
const commits = payload.commits;
496506

app/services/gamebridge/GameBridge.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class GameBridge extends Service {
2424
discordChatWH: Discord.WebhookClient;
2525
discordErrorWH: Discord.WebhookClient;
2626
discordPacErrorWH: Discord.WebhookClient;
27+
ready: boolean = false;
2728

2829
constructor(container: Container) {
2930
super(container);
@@ -51,6 +52,7 @@ export default class GameBridge extends Service {
5152
});
5253

5354
console.log(`Web socket server listening on ${this.webApp.config.port}`);
55+
this.ready = true;
5456
// this.handleResoniteConnection();
5557
}
5658

0 commit comments

Comments
 (0)