mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 23:25:02 +00:00
utility: make !roles prettier, include search functionality
This commit is contained in:
parent
b94191004d
commit
04eaf70cd3
2 changed files with 70 additions and 30 deletions
15
src/utils.ts
15
src/utils.ts
|
@ -250,6 +250,21 @@ export function useMediaUrls(content: string): string {
|
|||
return content.replace(/cdn\.discordapp\.com/g, "media.discordapp.net");
|
||||
}
|
||||
|
||||
export function chunkArray<T>(arr: T[], chunkSize): T[][] {
|
||||
const chunks: T[][] = [];
|
||||
let currentChunk = [];
|
||||
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
currentChunk.push(arr[i]);
|
||||
if ((i !== 0 && i % chunkSize === 0) || i === arr.length - 1) {
|
||||
chunks.push(currentChunk);
|
||||
currentChunk = [];
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
export function chunkLines(str: string, maxChunkLength = 2000): string[] {
|
||||
if (str.length < maxChunkLength) {
|
||||
return [str];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue