-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eric
committed
Jun 18, 2023
1 parent
dcf81c6
commit 114b79a
Showing
5 changed files
with
31 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
import { Snowyflake, Epoch } from "snowyflake"; | ||
import { MJOptions } from "../interfaces"; | ||
|
||
export const sleep = async (ms: number): Promise<void> => | ||
await new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
export const random = (min: number, max: number): number => | ||
Math.floor(Math.random() * (max - min) + min); | ||
|
||
// const snowflake = new Snowflake(1); | ||
const snowflake = new Snowyflake({ | ||
workerId: 0n, | ||
processId: 0n, | ||
epoch: Epoch.Discord, // BigInt timestamp | ||
}); | ||
|
||
export const nextNonce = (): string => snowflake.nextId().toString(); | ||
|
||
export const formatOptions = (components: any) => { | ||
var data: MJOptions[] = []; | ||
for (var i = 0; i < components.length; i++) { | ||
const component = components[i]; | ||
if (component.components && component.components.length > 0) { | ||
const item = formatOptions(component.components); | ||
data = data.concat(item); | ||
} | ||
data.push({ | ||
type: component.type, | ||
label: component.label || component.emoji?.name, | ||
custom: component.custom_id, | ||
}); | ||
} | ||
return data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters