chore: updates

chore(githubUtils): replace `

feat(github): add formatEmojiStatus
This commit is contained in:
xHyroM 2022-07-14 09:23:04 +02:00
parent 587c58bec8
commit 094a59aa58
3 changed files with 6 additions and 6 deletions

View file

@ -4,7 +4,7 @@ import { Command } from '../structures/Command';
import utilities from '../../files/utilities.toml'; import utilities from '../../files/utilities.toml';
import Collection from '@discordjs/collection'; import Collection from '@discordjs/collection';
import { CommandContext } from '../structures/contexts/CommandContext'; import { CommandContext } from '../structures/contexts/CommandContext';
import { getIssueOrPR, search, formatStatus } from '../utils/githubUtils'; import { getIssueOrPR, search, formatStatus, formatEmojiStatus } from '../utils/githubUtils';
const invalidIssue = (ctx: CommandContext, query: string) => { const invalidIssue = (ctx: CommandContext, query: string) => {
return ctx.editResponse( return ctx.editResponse(
@ -76,7 +76,7 @@ new Command({
} }
return ctx.editResponse([ return ctx.editResponse([
`[#${issueOrPR.number} ${repositoryOwner}/${repositoryName}](<${issueOrPR.html_url}>) by [${issueOrPR.user_login}](<${issueOrPR.user_html_url}>) ${formatStatus(issueOrPR)}`, `${formatEmojiStatus(issueOrPR)} [#${issueOrPR.number} ${repositoryOwner}/${repositoryName}](<${issueOrPR.html_url}>) by [${issueOrPR.user_login}](<${issueOrPR.user_html_url}>) ${formatStatus(issueOrPR)}`,
issueOrPR.title issueOrPR.title
].join('\n')); ].join('\n'));
} }

View file

@ -6,7 +6,7 @@ import MiniSearch from 'minisearch';
import { Logger } from './Logger'; import { Logger } from './Logger';
import { APIApplicationCommandOptionChoice } from 'discord-api-types/v10'; import { APIApplicationCommandOptionChoice } from 'discord-api-types/v10';
import { Database } from 'bun:sqlite'; import { Database } from 'bun:sqlite';
import { discordChoicesRegex } from './regexes'; import { githubTitleClean } from './regexes';
interface Issue { interface Issue {
id: number; id: number;
@ -186,7 +186,7 @@ export const search = async(query: string, repository: string): Promise<APIAppli
if (!query) { if (!query) {
const array = arrayFiltered.slice(0, 25); const array = arrayFiltered.slice(0, 25);
return array.map((issueOrPr: Issue | PullRequest) => new Object({ return array.map((issueOrPr: Issue | PullRequest) => new Object({
name: `${issueOrPr.type} ${formatEmojiStatus(issueOrPr)} ${issueOrPr.title.slice(0, 93)}`, name: `${issueOrPr.type} ${formatEmojiStatus(issueOrPr)} ${issueOrPr.title.slice(0, 93).replace(githubTitleClean, '')}`,
value: issueOrPr.number.toString() value: issueOrPr.number.toString()
})) as APIApplicationCommandOptionChoice[] })) as APIApplicationCommandOptionChoice[]
} }
@ -205,7 +205,7 @@ export const search = async(query: string, repository: string): Promise<APIAppli
const result = searcher.search(query); const result = searcher.search(query);
return (result as unknown as Issue[] | PullRequest[]).slice(0, 25).map((issueOrPr: Issue | PullRequest) => new Object({ return (result as unknown as Issue[] | PullRequest[]).slice(0, 25).map((issueOrPr: Issue | PullRequest) => new Object({
name: `${issueOrPr.type} ${formatEmojiStatus(issueOrPr)} ${issueOrPr.title.slice(0, 93)}`, name: `${issueOrPr.type} ${formatEmojiStatus(issueOrPr)} ${issueOrPr.title.slice(0, 93).replace(githubTitleClean, '')}`,
value: issueOrPr.number.toString() value: issueOrPr.number.toString()
})) as APIApplicationCommandOptionChoice[] })) as APIApplicationCommandOptionChoice[]
} catch(e) { } catch(e) {

View file

@ -1 +1 @@
export const discordChoicesRegex = /[^a-z0-9 (|)|-|*|/|+|,|<|>|&|!|?]/gi; export const githubTitleClean = /[`]/gi;