mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-14 02:48:07 +01:00
chore: updates
chore(githubUtils): replace ` feat(github): add formatEmojiStatus
This commit is contained in:
parent
587c58bec8
commit
094a59aa58
3 changed files with 6 additions and 6 deletions
|
@ -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'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export const discordChoicesRegex = /[^a-z0-9 (|)|-|*|/|+|,|<|>|&|!|?]/gi;
|
export const githubTitleClean = /[`]/gi;
|
Loading…
Reference in a new issue