Capitalize ref_type when using in embed
The GitHub API provides `ref_type` as lowercase. For consistency, this adds a utility function and makes use of it when formatting the `create` event from GitHub. tag => Tag branch => Branch
This commit is contained in:
parent
77dd481742
commit
82642d0e97
@ -15,6 +15,7 @@ import {
|
|||||||
handleFile,
|
handleFile,
|
||||||
ValidateName,
|
ValidateName,
|
||||||
EmbedType,
|
EmbedType,
|
||||||
|
capitalize,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import { NextFunction, Request, Response, Router } from "express";
|
import { NextFunction, Request, Response, Router } from "express";
|
||||||
import { HTTPError } from "lambert-server";
|
import { HTTPError } from "lambert-server";
|
||||||
@ -284,7 +285,7 @@ function transformGitHubToDiscord(
|
|||||||
username: "GitHub",
|
username: "GitHub",
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
title: `➕ ${payload.ref_type} created in ${payload.repository?.full_name}`,
|
title: `➕ ${capitalize(payload.ref_type)} created in ${payload.repository?.full_name}`,
|
||||||
type: EmbedType.rich,
|
type: EmbedType.rich,
|
||||||
description: `A new ${payload.ref_type} named \`${payload.ref}\` was created`,
|
description: `A new ${payload.ref_type} named \`${payload.ref}\` was created`,
|
||||||
color: 0x7289da,
|
color: 0x7289da,
|
||||||
|
|||||||
@ -22,3 +22,13 @@ export function trimSpecial(str?: string): string {
|
|||||||
if (!str) return "";
|
if (!str) return "";
|
||||||
return str.replace(SPECIAL_CHAR, "").trim();
|
return str.replace(SPECIAL_CHAR, "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capitalizes the first letter of a string.
|
||||||
|
* @param str The string to capitalize.
|
||||||
|
* @returns The capitalized string.
|
||||||
|
*/
|
||||||
|
export function capitalize(str: string): string {
|
||||||
|
if (!str) return "";
|
||||||
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user