detritus

Toolsnamespace

Small helpers, like working out which shard a guild is on.

On this page
import { Tools } from 'detritus-utils';
4 type aliases · 3 functions

Functions

Standalone helpers.

guildIdToShardId()

function src/tools.ts:8
function guildIdToShardId(guildId: string, shardCount?: number): number
guildId
string
shardCount?
number
Default 0

normalize()

function src/tools.ts:1
function normalize(object: { [key: string]: any }): Readonly<{ [key: string]: any }>

Type aliases

Named types used across the API.

URIEncodedArgument

type src/tools.ts:32
type URIEncodedArgument<T> = string | Extract<T, "" | 0 | 0n | false | null | undefined>

What a wrapped function actually gets for an argument: truthy ones are stringified and encoded, falsy ones pass through

URIEncodeWrapFunc

type src/tools.ts:26
type URIEncodeWrapFunc = (...args: any[]) => string

URIEncodeWrapped

type src/tools.ts:27
type URIEncodeWrapped = { [key: string]: any }

URIEncodeWrapSafe

type src/tools.ts:37
type URIEncodeWrapSafe<T> = { [K in keyof T]: T[K] extends (...args: infer A) => any ? (...args: { [I in keyof A]: URIEncodedArgument<…[…]> }) => any : T[K] }

Parameters must accept strings, so a number or bigint one is a type error instead of id + 1n silently concatenating