Skip to content

Commit 3f5a7d4

Browse files
committed
fine lets have it your way
1 parent 2a139f9 commit 3f5a7d4

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ const BaseEmbed = <Discord.WebhookMessageCreateOptions>{
3131
allowedMentions: { parse: ["users"] },
3232
};
3333

34-
const DefaultSeparator = {
35-
type: Discord.ComponentType.Separator,
36-
divider: true,
37-
} as Discord.SeparatorComponent;
38-
3934
const GetGithubChanges = (
4035
repoPath: string,
4136
sha: string,
@@ -522,58 +517,61 @@ export default async (bot: DiscordBot): Promise<void> => {
522517
)
523518
);
524519

525-
container.addTextDisplayComponents({
526-
type: Discord.ComponentType.TextDisplay,
527-
content: `# [Chatsound Update](${commit.url})`,
528-
});
520+
container.addTextDisplayComponents(text =>
521+
text.setContent(`# [Chatsound Update](${commit.url})`)
522+
);
529523

530-
container.addSeparatorComponents(DefaultSeparator);
524+
container.addSeparatorComponents(sep => sep);
531525

532526
const addedSounds = GroupSoundFilesByFolder(commit.added ?? []);
533527
const removedSounds = GroupSoundFilesByFolder(commit.removed ?? []);
534528
const modifiedSounds = GroupSoundFilesByFolder(commit.modified ?? []);
535529

536530
// maybe there is a better way instead of if-chaining this but whatever
537531
if (commit.added && addedSounds.size > 0) {
538-
container.addTextDisplayComponents({
539-
type: Discord.ComponentType.TextDisplay,
540-
content: `### Added ${commit.added.length} new sound${commit.added.length > 1 ? "s" : ""}:\n${Array.from(
541-
addedSounds
532+
container.addTextDisplayComponents(text =>
533+
text.setContent(
534+
`### Added ${commit.added?.length} new sound${(commit.added?.length ?? 0 > 1) ? "s" : ""}:\n${Array.from(
535+
addedSounds
536+
)
537+
.map(formatSounds)
538+
.join("\n\n")}`
542539
)
543-
.map(formatSounds)
544-
.join("\n\n")}`,
545-
});
540+
);
546541

547-
container.addSeparatorComponents(DefaultSeparator);
542+
container.addSeparatorComponents(sep => sep);
548543
}
549544
if (commit.removed && removedSounds.size > 0) {
550-
container.addTextDisplayComponents({
551-
type: Discord.ComponentType.TextDisplay,
552-
content: `### Removed ${commit.removed.length} sound${commit.removed.length > 1 ? "s" : ""}:\n${Array.from(
553-
removedSounds
545+
container.addTextDisplayComponents(text =>
546+
text.setContent(
547+
`### Removed ${commit.removed?.length} sound${(commit.removed?.length ?? 0 > 1) ? "s" : ""}:\n${Array.from(
548+
removedSounds
549+
)
550+
.map(formatSounds)
551+
.join("\n\n")}`
554552
)
555-
.map(formatSounds)
556-
.join("\n\n")}`,
557-
});
553+
);
558554

559-
container.addSeparatorComponents(DefaultSeparator);
555+
container.addSeparatorComponents(sep => sep);
560556
}
561557
if (commit.modified && modifiedSounds.size > 0) {
562-
container.addTextDisplayComponents({
563-
type: Discord.ComponentType.TextDisplay,
564-
content: `### Changed ${commit.modified.length} sound${commit.modified.length > 1 ? "s" : ""}:\n${Array.from(
565-
modifiedSounds
558+
container.addTextDisplayComponents(text =>
559+
text.setContent(
560+
`### Changed ${commit.modified?.length} sound${(commit.modified?.length ?? 0 > 1) ? "s" : ""}:\n${Array.from(
561+
modifiedSounds
562+
)
563+
.map(formatSounds)
564+
.join("\n\n")}`
566565
)
567-
.map(formatSounds)
568-
.join("\n\n")}`,
569-
});
566+
);
570567

571-
container.addSeparatorComponents(DefaultSeparator);
568+
container.addSeparatorComponents(sep => sep);
572569
}
573-
container.addTextDisplayComponents({
574-
type: Discord.ComponentType.TextDisplay,
575-
content: `-# added by ${commit.author.username ?? commit.author.name} via \`${commit.message.split("\n\n")[0]}\`, approved by ${payload.pusher.username ?? payload.pusher.name}`,
576-
});
570+
container.addTextDisplayComponents(text =>
571+
text.setContent(
572+
`-# added by ${commit.author.username ?? commit.author.name} via \`${commit.message.split("\n\n")[0]}\`, approved by ${payload.pusher.username ?? payload.pusher.name}`
573+
)
574+
);
577575
}
578576
const message = {
579577
username: payload.sender?.name ?? payload.sender?.login ?? "unknown",
@@ -614,21 +612,23 @@ export default async (bot: DiscordBot): Promise<void> => {
614612

615613
container.setAccentColor(payload.pull_request.state === "open" ? 5763719 : 15277667);
616614

617-
container.addTextDisplayComponents({
618-
type: Discord.ComponentType.TextDisplay,
619-
content: `# [Chatsound Request \`#${payload.number} ${payload.pull_request.title}\`](${payload.pull_request.html_url})`,
620-
});
615+
container.addTextDisplayComponents(text =>
616+
text.setContent(
617+
`# [Chatsound Request \`#${payload.number} ${payload.pull_request.title}\`](${payload.pull_request.html_url})`
618+
)
619+
);
621620

622-
container.addSeparatorComponents(DefaultSeparator);
621+
container.addSeparatorComponents(sep => sep);
623622

624-
container.addTextDisplayComponents({
625-
type: Discord.ComponentType.TextDisplay,
626-
content: `### [${payload.sender.login}](${payload.sender.html_url}) wants to add/change ${payload.pull_request.changed_files} sound${changedFiles.size > 1 ? "s" : ""}:\n${Array.from(
627-
changedFiles
623+
container.addTextDisplayComponents(text =>
624+
text.setContent(
625+
`### [${payload.sender.login}](${payload.sender.html_url}) wants to add/change ${payload.pull_request.changed_files} sound${changedFiles.size > 1 ? "s" : ""}:\n${Array.from(
626+
changedFiles
627+
)
628+
.map(formatSounds)
629+
.join("\n\n")}`
628630
)
629-
.map(formatSounds)
630-
.join("\n\n")}`,
631-
});
631+
);
632632

633633
webhook.send({
634634
username: payload.sender.name ?? payload.sender.login ?? "unknown",

0 commit comments

Comments
 (0)