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}/;
|
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 {
|
export function isSnowflake(v: string): boolean {
|
||||||
return isSnowflakeRegex.test(v);
|
return isSnowflakeRegex.test(v);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ export async function findRelevantAuditLogEntry(
|
||||||
actionType: number,
|
actionType: number,
|
||||||
userId: string,
|
userId: string,
|
||||||
attempts: number = 3,
|
attempts: number = 3,
|
||||||
attemptDelay: number = 3000
|
attemptDelay: number = 3000,
|
||||||
): Promise<GuildAuditLogEntry> {
|
): Promise<GuildAuditLogEntry> {
|
||||||
const auditLogEntries = await guild.getAuditLogs(5, null, actionType);
|
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;
|
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) {
|
export function trimLines(str: string) {
|
||||||
return str
|
return str
|
||||||
.trim()
|
.trim()
|
||||||
|
@ -310,7 +314,7 @@ export function downloadFile(attachmentUrl: string, retries = 3): Promise<{ path
|
||||||
writeStream.end();
|
writeStream.end();
|
||||||
resolve({
|
resolve({
|
||||||
path,
|
path,
|
||||||
deleteFn
|
deleteFn,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue