diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-07-14 08:33:50 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-07-14 08:33:50 -0400 |
commit | afc334cb02a72627b9fb15a53efa3cfd4010463e (patch) | |
tree | 3e6ad1d1065dbd077fccd9980f9a05435a809694 /src | |
parent | 21a347e044d3cb8a1e5e433e2854d20dd7ba937b (diff) | |
download | tanzanite-afc334cb02a72627b9fb15a53efa3cfd4010463e.tar.gz tanzanite-afc334cb02a72627b9fb15a53efa3cfd4010463e.tar.bz2 tanzanite-afc334cb02a72627b9fb15a53efa3cfd4010463e.zip |
move some stuff around
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/utils/BushUtils.ts | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/src/lib/utils/BushUtils.ts b/src/lib/utils/BushUtils.ts index e3539a1..19260c8 100644 --- a/src/lib/utils/BushUtils.ts +++ b/src/lib/utils/BushUtils.ts @@ -28,6 +28,7 @@ import { type PermissionsString } from 'discord.js'; import got from 'got'; +import { DeepWritable } from 'ts-essentials'; import { inspect as inspectUtil, promisify } from 'util'; import * as Format from '../common/util/Format.js'; @@ -89,6 +90,25 @@ export async function mcUUID(username: string, dashed = false): Promise<string> return dashed ? apiRes.uuid : apiRes.uuid.replace(/-/g, ''); } +export interface UuidRes { + uuid: string; + username: string; + username_history?: { username: string }[] | null; + textures: { + custom: boolean; + slim: boolean; + skin: { + url: string; + data: string; + }; + raw: { + value: string; + signature: string; + }; + }; + created_at: string; +} + /** * Generate defaults for {@link inspect}. * @param options The options to create defaults with. @@ -106,7 +126,8 @@ function getDefaultInspectOptions(options?: BushInspectOptions): BushInspectOpti breakLength: options?.breakLength ?? 80, compact: options?.compact ?? 3, sorted: options?.sorted ?? false, - getters: options?.getters ?? true + getters: options?.getters ?? true, + numericSeparator: options?.numericSeparator ?? true }; } @@ -233,6 +254,11 @@ export function parseDuration(content: string, remove = true): ParsedDuration { return { duration, content: contentWithoutTime }; } +export interface ParsedDuration { + duration: number | null; + content: string | null; +} + /** * Converts a duration in milliseconds to a human readable form. * @param duration The duration in milliseconds to convert. @@ -278,6 +304,8 @@ export function timestamp<D extends Date | undefined | null>( return `<t:${Math.round(date.getTime() / 1_000)}:${style}>` as unknown as D extends Date ? string : undefined; } +export type TimestampStyle = 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R'; + /** * Creates a human readable representation between a date and the current time. * @param date The date to be compared with the current time. @@ -498,6 +526,11 @@ export async function castDurationContent( return { duration: res?.duration ?? 0, content: res?.content ?? '' }; } +export interface ParsedDurationRes { + duration: number; + content: string; +} + /** * Casts a string to a the specified argument type. * @param type The type of the argument to cast to. @@ -570,33 +603,6 @@ export function formatError(error: Error | any, colors = false): string { return error.stack; } -export interface UuidRes { - uuid: string; - username: string; - username_history?: { username: string }[] | null; - textures: { - custom: boolean; - slim: boolean; - skin: { - url: string; - data: string; - }; - raw: { - value: string; - signature: string; - }; - }; - created_at: string; -} - -export interface ParsedDuration { - duration: number | null; - content: string | null; +export function deepWriteable<T>(obj: T): DeepWritable<T> { + return obj as DeepWritable<T>; } - -export interface ParsedDurationRes { - duration: number; - content: string; -} - -export type TimestampStyle = 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R'; |