mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
utils: fix isSnowflakeRegex; add isUnicodeEmoji
This commit is contained in:
parent
52db74005b
commit
2e245ab16b
1 changed files with 7 additions and 3 deletions
10
src/utils.ts
10
src/utils.ts
|
@ -88,7 +88,7 @@ export function formatTemplateString(str: string, values) {
|
|||
|
||||
export const snowflakeRegex = /[1-9][0-9]{5,19}/;
|
||||
|
||||
const isSnowflakeRegex = new RegExp(`^${snowflakeRegex}$`);
|
||||
const isSnowflakeRegex = new RegExp(`^${snowflakeRegex.source}$`);
|
||||
export function isSnowflake(v: string): boolean {
|
||||
return isSnowflakeRegex.test(v);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export async function findRelevantAuditLogEntry(
|
|||
actionType: number,
|
||||
userId: string,
|
||||
attempts: number = 3,
|
||||
attemptDelay: number = 3000
|
||||
attemptDelay: number = 3000,
|
||||
): Promise<GuildAuditLogEntry> {
|
||||
const auditLogEntries = await guild.getAuditLogs(5, null, actionType);
|
||||
|
||||
|
@ -186,6 +186,10 @@ export function isEmoji(str: string): boolean {
|
|||
return str.match(`^(${unicodeEmojiRegex.source})|(${customEmojiRegex.source})$`) !== null;
|
||||
}
|
||||
|
||||
export function isUnicodeEmoji(str: string): boolean {
|
||||
return str.match(`^${unicodeEmojiRegex.source}$`) !== null;
|
||||
}
|
||||
|
||||
export function trimLines(str: string) {
|
||||
return str
|
||||
.trim()
|
||||
|
@ -310,7 +314,7 @@ export function downloadFile(attachmentUrl: string, retries = 3): Promise<{ path
|
|||
writeStream.end();
|
||||
resolve({
|
||||
path,
|
||||
deleteFn
|
||||
deleteFn,
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue