Files
discordeno/website/docs/generated/modules_bot.md
Skillz4Killz 3bbb03b8e3 cleanup cleanup cleanup on isle dd (#2792)
* cleanup cleanup cleanup on isle dd

* fix: rest manager import in test
2023-02-25 20:11:15 -06:00

64 KiB

discordeno-monorepo / Modules / @discordeno/bot

Module: @discordeno/bot

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ApiVersions

Ƭ ApiVersions: 9 | 10

Defined in

packages/rest/dist/types.d.ts:2325


AtLeastOne

Ƭ AtLeastOne<T, U>: Partial<T> & U[keyof U]

Type parameters

Name Type
T T
U { [K in keyof T]: Pick<T, K> }

Defined in

packages/types/dist/shared.d.ts:831


BigString

Ƭ BigString: bigint | string

Defined in

packages/types/dist/shared.d.ts:1


CamelCase

Ƭ CamelCase<S>: S extends `${infer T}_${infer U}` ? `${T}${Capitalize<CamelCase<U>>}` : S

Type parameters

Name Type
S extends string

Defined in

packages/types/dist/shared.d.ts:834


Camelize

Ƭ Camelize<T>: T extends any[] ? T extends Record<any, any>[] ? Camelize<T[number]>[] : T : T extends Record<any, any> ? { [K in keyof T as CamelCase<K & string>]: Camelize<T[K]> } : T

Type parameters

Name
T

Defined in

packages/types/dist/shared.d.ts:836


CreateApplicationCommand

Ƭ CreateApplicationCommand: CreateSlashApplicationCommand | CreateContextApplicationCommand

Defined in

packages/types/dist/discordeno.d.ts:309


DiscordArchivedThreads

Ƭ DiscordArchivedThreads: DiscordActiveThreads & { hasMore: boolean }

Defined in

packages/types/dist/discord.d.ts:2297


DiscordAuditLogChange

Ƭ DiscordAuditLogChange: { key: "name" | "description" | "discovery_splash_hash" | "banner_hash" | "preferred_locale" | "rules_channel_id" | "public_updates_channel_id" | "icon_hash" | "image_hash" | "splash_hash" | "owner_id" | "region" | "afk_channel_id" | "vanity_url_code" | "widget_channel_id" | "system_channel_id" | "topic" | "application_id" | "permissions" | "allow" | "deny" | "code" | "channel_id" | "inviter_id" | "nick" | "avatar_hash" | "id" | "location" | "command_id" ; new_value: string ; old_value: string } | { key: "afk_timeout" | "mfa_level" | "verification_level" | "explicit_content_filter" | "default_message_notifications" | "prune_delete_days" | "position" | "bitrate" | "rate_limit_per_user" | "color" | "max_uses" | "uses" | "max_age" | "expire_behavior" | "expire_grace_period" | "user_limit" | "privacy_level" | "auto_archive_duration" | "default_auto_archive_duration" | "entity_type" | "status" | "communication_disabled_until" ; new_value: number ; old_value: number } | { key: "$add" | "$remove" ; new_value: Partial<DiscordRole>[] ; old_value?: Partial<DiscordRole>[] } | { key: "widget_enabled" | "nsfw" | "hoist" | "mentionable" | "temporary" | "deaf" | "mute" | "enable_emoticons" | "archived" | "locked" | "invitable" ; new_value: boolean ; old_value: boolean } | { key: "permission_overwrites" ; new_value: DiscordOverwrite[] ; old_value: DiscordOverwrite[] } | { key: "type" ; new_value: string | number ; old_value: string | number }

https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure

Defined in

packages/types/dist/discord.d.ts:1368


DiscordMessageComponents

Ƭ DiscordMessageComponents: DiscordActionRow[]

Defined in

packages/types/dist/discord.d.ts:1014


DiscordMessageReactionRemoveEmoji

Ƭ DiscordMessageReactionRemoveEmoji: Pick<DiscordMessageReactionAdd, "channel_id" | "guild_id" | "message_id" | "emoji">

https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji

Defined in

packages/types/dist/discord.d.ts:2000


DiscordWebhook

Ƭ DiscordWebhook: DiscordIncomingWebhook | DiscordApplicationWebhook

https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure

Defined in

packages/types/dist/discord.d.ts:356


EmbedTypes

Ƭ EmbedTypes: "rich" | "image" | "video" | "gifv" | "article" | "link"

https://discord.com/developers/docs/resources/channel#embed-object-embed-types

Defined in

packages/types/dist/shared.d.ts:129


GatewayDispatchEventNames

Ƭ GatewayDispatchEventNames: "READY" | "APPLICATION_COMMAND_PERMISSIONS_UPDATE" | "AUTO_MODERATION_RULE_CREATE" | "AUTO_MODERATION_RULE_UPDATE" | "AUTO_MODERATION_RULE_DELETE" | "AUTO_MODERATION_ACTION_EXECUTION" | "CHANNEL_CREATE" | "CHANNEL_UPDATE" | "CHANNEL_DELETE" | "CHANNEL_PINS_UPDATE" | "THREAD_CREATE" | "THREAD_UPDATE" | "THREAD_DELETE" | "THREAD_LIST_SYNC" | "THREAD_MEMBER_UPDATE" | "THREAD_MEMBERS_UPDATE" | "GUILD_CREATE" | "GUILD_UPDATE" | "GUILD_DELETE" | "GUILD_BAN_ADD" | "GUILD_BAN_REMOVE" | "GUILD_EMOJIS_UPDATE" | "GUILD_STICKERS_UPDATE" | "GUILD_INTEGRATIONS_UPDATE" | "GUILD_MEMBER_ADD" | "GUILD_MEMBER_REMOVE" | "GUILD_MEMBER_UPDATE" | "GUILD_MEMBERS_CHUNK" | "GUILD_ROLE_CREATE" | "GUILD_ROLE_UPDATE" | "GUILD_ROLE_DELETE" | "GUILD_SCHEDULED_EVENT_CREATE" | "GUILD_SCHEDULED_EVENT_UPDATE" | "GUILD_SCHEDULED_EVENT_DELETE" | "GUILD_SCHEDULED_EVENT_USER_ADD" | "GUILD_SCHEDULED_EVENT_USER_REMOVE" | "INTEGRATION_CREATE" | "INTEGRATION_UPDATE" | "INTEGRATION_DELETE" | "INTERACTION_CREATE" | "INVITE_CREATE" | "INVITE_DELETE" | "MESSAGE_CREATE" | "MESSAGE_UPDATE" | "MESSAGE_DELETE" | "MESSAGE_DELETE_BULK" | "MESSAGE_REACTION_ADD" | "MESSAGE_REACTION_REMOVE" | "MESSAGE_REACTION_REMOVE_ALL" | "MESSAGE_REACTION_REMOVE_EMOJI" | "PRESENCE_UPDATE" | "STAGE_INSTANCE_CREATE" | "STAGE_INSTANCE_UPDATE" | "STAGE_INSTANCE_DELETE" | "TYPING_START" | "USER_UPDATE" | "VOICE_STATE_UPDATE" | "VOICE_SERVER_UPDATE" | "WEBHOOKS_UPDATE"

Defined in

packages/types/dist/shared.d.ts:643


GatewayEventNames

Ƭ GatewayEventNames: GatewayDispatchEventNames | "READY" | "RESUMED"

Defined in

packages/types/dist/shared.d.ts:644


GetMessagesOptions

Ƭ GetMessagesOptions: GetMessagesAfter | GetMessagesBefore | GetMessagesAround | GetMessagesLimit

Defined in

packages/types/dist/discordeno.d.ts:242


ImageFormat

Ƭ ImageFormat: "jpg" | "jpeg" | "png" | "webp" | "gif" | "json"

https://discord.com/developers/docs/reference#image-formatting json is only for stickers

Defined in

packages/types/dist/shared.d.ts:795


ImageSize

Ƭ ImageSize: 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096

https://discord.com/developers/docs/reference#image-formatting

Defined in

packages/types/dist/shared.d.ts:797


Localization

Ƭ Localization: Partial<Record<Locales, string>>

Defined in

packages/types/dist/shared.d.ts:830


MessageComponents

Ƭ MessageComponents: ActionRow[]

Defined in

packages/types/dist/discordeno.d.ts:35


PermissionStrings

Ƭ PermissionStrings: keyof typeof BitwisePermissionFlags

Defined in

packages/types/dist/shared.d.ts:584


PickPartial

Ƭ PickPartial<T, K>: { [P in keyof T]?: T[P] } & { [P in K]: T[P] }

Type parameters

Name Type
T T
K extends keyof T

Defined in

packages/types/dist/shared.d.ts:842


RequestMethods

Ƭ RequestMethods: "GET" | "POST" | "DELETE" | "PATCH" | "PUT"

Defined in

packages/rest/dist/types.d.ts:2324


SnakeCase

Ƭ SnakeCase<S>: S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? "_" : ""}${Lowercase<T>}${SnakeCase<U>}` : S

Type parameters

Name Type
S extends string

Defined in

packages/types/dist/shared.d.ts:835


Snakelize

Ƭ Snakelize<T>: T extends any[] ? T extends Record<any, any>[] ? Snakelize<T[number]>[] : T : T extends Record<any, any> ? { [K in keyof T as SnakeCase<K & string>]: Snakelize<T[K]> } : T

Type parameters

Name
T

Defined in

packages/types/dist/shared.d.ts:839

Variables

Intents

Const Intents: typeof GatewayIntents

https://discord.com/developers/docs/topics/gateway#list-of-intents

Defined in

packages/types/dist/shared.d.ts:767


logger

Const logger: Object

Type declaration

Name Type
debug (...args: any[]) => void
error (...args: any[]) => void
fatal (...args: any[]) => void
info (...args: any[]) => void
log (level: LogLevels, ...args: any[]) => void
setDepth (level: LogDepth) => void
setLevel (level: LogLevels) => void
warn (...args: any[]) => void

Defined in

packages/utils/dist/logger.d.ts:25

Functions

acquire

acquire(bucket, amount, highPriority?): Promise<void>

Parameters

Name Type
bucket LeakyBucket
amount number
highPriority? boolean

Returns

Promise<void>

Defined in

packages/utils/dist/bucket.d.ts:54


avatarUrl

avatarUrl(userId, discriminator, options?): string

Builds a URL to a user's avatar stored in the Discord CDN.

Parameters

Name Type Description
userId BigString The ID of the user to get the avatar of.
discriminator string The user's discriminator. (4-digit tag after the hashtag.)
options? Object The parameters for the building of the URL.
options.avatar undefined | BigString -
options.format? ImageFormat -
options.size? ImageSize -

Returns

string

The link to the resource.

Defined in

packages/utils/dist/images.d.ts:20


bgBlack

bgBlack(str): string

Set background color to black.

Parameters

Name Type Description
str string text to make its background black

Returns

string

Defined in

packages/utils/dist/colors.d.ts:148


bgBlue

bgBlue(str): string

Set background color to blue.

Parameters

Name Type Description
str string text to make its background blue

Returns

string

Defined in

packages/utils/dist/colors.d.ts:168


bgBrightBlack

bgBrightBlack(str): string

Set background color to bright black.

Parameters

Name Type Description
str string text to make its background bright-black

Returns

string

Defined in

packages/utils/dist/colors.d.ts:188


bgBrightBlue

bgBrightBlue(str): string

Set background color to bright blue.

Parameters

Name Type Description
str string text to make its background bright-blue

Returns

string

Defined in

packages/utils/dist/colors.d.ts:208


bgBrightCyan

bgBrightCyan(str): string

Set background color to bright cyan.

Parameters

Name Type Description
str string text to make its background bright-cyan

Returns

string

Defined in

packages/utils/dist/colors.d.ts:218


bgBrightGreen

bgBrightGreen(str): string

Set background color to bright green.

Parameters

Name Type Description
str string text to make its background bright-green

Returns

string

Defined in

packages/utils/dist/colors.d.ts:198


bgBrightMagenta

bgBrightMagenta(str): string

Set background color to bright magenta.

Parameters

Name Type Description
str string text to make its background bright-magenta

Returns

string

Defined in

packages/utils/dist/colors.d.ts:213


bgBrightRed

bgBrightRed(str): string

Set background color to bright red.

Parameters

Name Type Description
str string text to make its background bright-red

Returns

string

Defined in

packages/utils/dist/colors.d.ts:193


bgBrightWhite

bgBrightWhite(str): string

Set background color to bright white.

Parameters

Name Type Description
str string text to make its background bright-white

Returns

string

Defined in

packages/utils/dist/colors.d.ts:223


bgBrightYellow

bgBrightYellow(str): string

Set background color to bright yellow.

Parameters

Name Type Description
str string text to make its background bright-yellow

Returns

string

Defined in

packages/utils/dist/colors.d.ts:203


bgCyan

bgCyan(str): string

Set background color to cyan.

Parameters

Name Type Description
str string text to make its background cyan

Returns

string

Defined in

packages/utils/dist/colors.d.ts:178


bgGreen

bgGreen(str): string

Set background color to green.

Parameters

Name Type Description
str string text to make its background green

Returns

string

Defined in

packages/utils/dist/colors.d.ts:158


bgMagenta

bgMagenta(str): string

Set background color to magenta.

Parameters

Name Type Description
str string text to make its background magenta

Returns

string

Defined in

packages/utils/dist/colors.d.ts:173


bgRed

bgRed(str): string

Set background color to red.

Parameters

Name Type Description
str string text to make its background red

Returns

string

Defined in

packages/utils/dist/colors.d.ts:153


bgRgb24

bgRgb24(str, color): string

Set background color using 24bit rgb. color can be a number in range 0x000000 to 0xffffff or an Rgb.

To produce the color magenta:

     import { bgRgb24 } from "./colors.ts";
     bgRgb24("foo", 0xff00ff);
     bgRgb24("foo", {r: 255, g: 0, b: 255});

Parameters

Name Type Description
str string text color to apply 24bit rgb to
color number | Rgb code

Returns

string

Defined in

packages/utils/dist/colors.d.ts:269


bgRgb8

bgRgb8(str, color): string

Set background color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

Parameters

Name Type Description
str string text color to apply paletted 8bit background colors to
color number code

Returns

string

Defined in

packages/utils/dist/colors.d.ts:237


bgWhite

bgWhite(str): string

Set background color to white.

Parameters

Name Type Description
str string text to make its background white

Returns

string

Defined in

packages/utils/dist/colors.d.ts:183


bgYellow

bgYellow(str): string

Set background color to yellow.

Parameters

Name Type Description
str string text to make its background yellow

Returns

string

Defined in

packages/utils/dist/colors.d.ts:163


black

black(str): string

Set text color to black.

Parameters

Name Type Description
str string text to make black

Returns

string

Defined in

packages/utils/dist/colors.d.ts:63


blue

blue(str): string

Set text color to blue.

Parameters

Name Type Description
str string text to make blue

Returns

string

Defined in

packages/utils/dist/colors.d.ts:83


bold

bold(str): string

Make the text bold.

Parameters

Name Type Description
str string text to make bold

Returns

string

Defined in

packages/utils/dist/colors.d.ts:28


brightBlack

brightBlack(str): string

Set text color to bright black.

Parameters

Name Type Description
str string text to make bright-black

Returns

string

Defined in

packages/utils/dist/colors.d.ts:108


brightBlue

brightBlue(str): string

Set text color to bright blue.

Parameters

Name Type Description
str string text to make bright-blue

Returns

string

Defined in

packages/utils/dist/colors.d.ts:128


brightCyan

brightCyan(str): string

Set text color to bright cyan.

Parameters

Name Type Description
str string text to make bright-cyan

Returns

string

Defined in

packages/utils/dist/colors.d.ts:138


brightGreen

brightGreen(str): string

Set text color to bright green.

Parameters

Name Type Description
str string text to make bright-green

Returns

string

Defined in

packages/utils/dist/colors.d.ts:118


brightMagenta

brightMagenta(str): string

Set text color to bright magenta.

Parameters

Name Type Description
str string text to make bright-magenta

Returns

string

Defined in

packages/utils/dist/colors.d.ts:133


brightRed

brightRed(str): string

Set text color to bright red.

Parameters

Name Type Description
str string text to make bright-red

Returns

string

Defined in

packages/utils/dist/colors.d.ts:113


brightWhite

brightWhite(str): string

Set text color to bright white.

Parameters

Name Type Description
str string text to make bright-white

Returns

string

Defined in

packages/utils/dist/colors.d.ts:143


brightYellow

brightYellow(str): string

Set text color to bright yellow.

Parameters

Name Type Description
str string text to make bright-yellow

Returns

string

Defined in

packages/utils/dist/colors.d.ts:123


calculateBits

calculateBits(permissions): string

This function converts an array of permissions into the bitwise string.

Parameters

Name Type
permissions ("CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | "STREAM" | "VIEW_CHANNEL" | "SEND_MESSAGES" | "SEND_TTS_MESSAGES" | "MANAGE_MESSAGES" | "EMBED_LINKS" | "ATTACH_FILES" | "READ_MESSAGE_HISTORY" | "MENTION_EVERYONE" | "USE_EXTERNAL_EMOJIS" | "VIEW_GUILD_INSIGHTS" | "CONNECT" | "SPEAK" | "MUTE_MEMBERS" | "DEAFEN_MEMBERS" | "MOVE_MEMBERS" | "USE_VAD" | "CHANGE_NICKNAME" | "MANAGE_NICKNAMES" | "MANAGE_ROLES" | "MANAGE_WEBHOOKS" | "MANAGE_EMOJIS_AND_STICKERS" | "USE_SLASH_COMMANDS" | "REQUEST_TO_SPEAK" | "MANAGE_EVENTS" | "MANAGE_THREADS" | "CREATE_PUBLIC_THREADS" | "CREATE_PRIVATE_THREADS" | "USE_EXTERNAL_STICKERS" | "SEND_MESSAGES_IN_THREADS" | "USE_EMBEDDED_ACTIVITIES" | "MODERATE_MEMBERS")[]

Returns

string

Defined in

packages/utils/dist/permissions.d.ts:5


calculatePermissions

calculatePermissions(permissionBits): PermissionStrings[]

This function converts a bitwise string to permission strings

Parameters

Name Type
permissionBits bigint

Returns

PermissionStrings[]

Defined in

packages/utils/dist/permissions.d.ts:3


camelToSnakeCase

camelToSnakeCase(str): string

Parameters

Name Type
str string

Returns

string

Defined in

packages/utils/dist/casing.d.ts:5


camelize

camelize<T>(object): Camelize<T>

Type parameters

Name
T

Parameters

Name Type
object T

Returns

Camelize<T>

Defined in

packages/utils/dist/casing.d.ts:2


coerceToFileContent

coerceToFileContent(value): value is FileContent

Parameters

Name Type
value unknown

Returns

value is FileContent

Defined in

packages/utils/dist/files.d.ts:3


createBot

createBot(options): Bot

Create a bot object that will maintain the rest and gateway connection.

Parameters

Name Type Description
options CreateBotOptions Configurations options used to manage this bot.

Returns

Bot

Bot

Defined in

packages/bot/src/bot.ts:62


createGatewayManager

createGatewayManager(options): GatewayManager

Parameters

Name Type
options CreateGatewayManagerOptions

Returns

GatewayManager

Defined in

packages/gateway/dist/manager.d.ts:6


createInvalidRequestBucket

createInvalidRequestBucket(options): InvalidRequestBucket

A invalid request bucket is used in a similar manner as a leaky bucket but a invalid request bucket can be refilled as needed. It's purpose is to make sure the bot does not hit the limit to getting a 1 hr ban.

Parameters

Name Type Description
options InvalidRequestBucketOptions The options used to configure this bucket.

Returns

InvalidRequestBucket

RefillingBucket

Defined in

packages/rest/dist/invalidBucket.d.ts:9


createLeakyBucket

createLeakyBucket(«destructured»): LeakyBucket

Parameters

Name Type
«destructured» Omit<PickPartial<LeakyBucket, "max" | "refillInterval" | "refillAmount">, "tokens"> & { tokens?: number }

Returns

LeakyBucket

Defined in

packages/utils/dist/bucket.d.ts:43


createLogger

createLogger(«destructured»?): Object

Parameters

Name Type
«destructured» Object
› logLevel? LogLevels
› name? string

Returns

Object

Name Type
debug (...args: any[]) => void
error (...args: any[]) => void
fatal (...args: any[]) => void
info (...args: any[]) => void
log (level: LogLevels, ...args: any[]) => void
setDepth (level: LogDepth) => void
setLevel (level: LogLevels) => void
warn (...args: any[]) => void

Defined in

packages/utils/dist/logger.d.ts:12


createRestManager

createRestManager(options): RestManager

Parameters

Name Type
options CreateRestManagerOptions

Returns

RestManager

Defined in

packages/rest/dist/manager.d.ts:2


cyan

cyan(str): string

Set text color to cyan.

Parameters

Name Type Description
str string text to make cyan

Returns

string

Defined in

packages/utils/dist/colors.d.ts:93


decode

decode(data): Uint8Array

CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 Decodes RFC4648 base64 string into an Uint8Array

Parameters

Name Type
data string

Returns

Uint8Array

Defined in

packages/utils/dist/base64.d.ts:12


delay

delay(ms): Promise<void>

Pause the execution for a given amount of milliseconds.

Parameters

Name Type
ms number

Returns

Promise<void>

Defined in

packages/utils/dist/utils.d.ts:2


dim

dim(str): string

The text emits only a small amount of light.

Parameters

Name Type Description
str string text to dim

Returns

string

Defined in

packages/utils/dist/colors.d.ts:33


emojiUrl

emojiUrl(emojiId, animated?): string

Get the url for an emoji.

Parameters

Name Type Description
emojiId BigString The id of the emoji
animated? boolean Whether or not the emoji is animated

Returns

string

string

Defined in

packages/utils/dist/images.d.ts:11


encode

encode(data): string

CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation

Parameters

Name Type
data string | ArrayBuffer

Returns

string

Defined in

packages/utils/dist/base64.d.ts:6


findFiles

findFiles(file): FileContent[]

Parameters

Name Type
file unknown

Returns

FileContent[]

Defined in

packages/utils/dist/files.d.ts:2


formatImageUrl

formatImageUrl(url, size?, format?): string

Help format an image url.

Parameters

Name Type
url string
size? ImageSize
format? ImageFormat

Returns

string

Defined in

packages/utils/dist/images.d.ts:3


getBotIdFromToken

getBotIdFromToken(token): bigint

Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken.

Parameters

Name Type
token string

Returns

bigint

Defined in

packages/utils/dist/token.d.ts:4


getColorEnabled

getColorEnabled(): boolean

Get whether text color change is enabled or disabled.

Returns

boolean

Defined in

packages/utils/dist/colors.d.ts:18


getWidgetImageUrl

getWidgetImageUrl(guildId, options?): string

Builds a URL to the guild widget image stored in the Discord CDN.

Parameters

Name Type Description
guildId BigString The ID of the guild to get the link to the widget image for.
options? GetGuildWidgetImageQuery The parameters for the building of the URL.

Returns

string

The link to the resource.

Defined in

packages/utils/dist/images.d.ts:67


gray

gray(str): string

Set text color to gray.

Parameters

Name Type Description
str string text to make gray

Returns

string

Defined in

packages/utils/dist/colors.d.ts:103


green

green(str): string

Set text color to green.

Parameters

Name Type Description
str string text to make green

Returns

string

Defined in

packages/utils/dist/colors.d.ts:73


guildBannerUrl

guildBannerUrl(guildId, options): string | undefined

Builds a URL to the guild banner stored in the Discord CDN.

Parameters

Name Type Description
guildId BigString The ID of the guild to get the link to the banner for.
options Object The parameters for the building of the URL.
options.banner? string | bigint -
options.format? ImageFormat -
options.size? ImageSize -

Returns

string | undefined

The link to the resource or undefined if no banner has been set.

Defined in

packages/utils/dist/images.d.ts:32


guildIconUrl

guildIconUrl(guildId, imageHash, options?): string | undefined

Builds a URL to the guild icon stored in the Discord CDN.

Parameters

Name Type Description
guildId BigString The ID of the guild to get the link to the banner for.
imageHash undefined | BigString -
options? Object The parameters for the building of the URL.
options.format? ImageFormat -
options.size? ImageSize -

Returns

string | undefined

The link to the resource or undefined if no banner has been set.

Defined in

packages/utils/dist/images.d.ts:44


guildSplashUrl

guildSplashUrl(guildId, imageHash, options?): string | undefined

Builds the URL to a guild splash stored in the Discord CDN.

Parameters

Name Type Description
guildId BigString The ID of the guild to get the splash of.
imageHash undefined | BigString The hash identifying the splash image.
options? Object The parameters for the building of the URL.
options.format? ImageFormat -
options.size? ImageSize -

Returns

string | undefined

The link to the resource or undefined if the guild does not have a splash image set.

Defined in

packages/utils/dist/images.d.ts:56


hasProperty

hasProperty<T, Y>(obj, prop): obj is T & Record<Y, unknown>

TS save way to check if a property exists in an object

Type parameters

Name Type
T extends Object
Y extends PropertyKey = string

Parameters

Name Type
obj T
prop Y

Returns

obj is T & Record<Y, unknown>

Defined in

packages/utils/dist/utils.d.ts:4


hidden

hidden(str): string

Make the text hidden.

Parameters

Name Type Description
str string text to hide

Returns

string

Defined in

packages/utils/dist/colors.d.ts:53


iconBigintToHash

iconBigintToHash(icon): string

Parameters

Name Type
icon bigint

Returns

string

Defined in

packages/utils/dist/hash.d.ts:2


iconHashToBigInt

iconHashToBigInt(hash): bigint

Parameters

Name Type
hash string

Returns

bigint

Defined in

packages/utils/dist/hash.d.ts:1


inverse

inverse(str): string

Invert background color and text color.

Parameters

Name Type Description
str string text to invert its color

Returns

string

Defined in

packages/utils/dist/colors.d.ts:48


isGetMessagesAfter

isGetMessagesAfter(options): options is GetMessagesAfter

Parameters

Name Type
options GetMessagesOptions

Returns

options is GetMessagesAfter

Defined in

packages/utils/dist/typeguards.d.ts:2


isGetMessagesAround

isGetMessagesAround(options): options is GetMessagesAround

Parameters

Name Type
options GetMessagesOptions

Returns

options is GetMessagesAround

Defined in

packages/utils/dist/typeguards.d.ts:4


isGetMessagesBefore

isGetMessagesBefore(options): options is GetMessagesBefore

Parameters

Name Type
options GetMessagesOptions

Returns

options is GetMessagesBefore

Defined in

packages/utils/dist/typeguards.d.ts:3


isGetMessagesLimit

isGetMessagesLimit(options): options is GetMessagesLimit

Parameters

Name Type
options GetMessagesOptions

Returns

options is GetMessagesLimit

Defined in

packages/utils/dist/typeguards.d.ts:5


italic

italic(str): string

Make the text italic.

Parameters

Name Type Description
str string text to make italic

Returns

string

Defined in

packages/utils/dist/colors.d.ts:38


magenta

magenta(str): string

Set text color to magenta.

Parameters

Name Type Description
str string text to make magenta

Returns

string

Defined in

packages/utils/dist/colors.d.ts:88


nextRefill

nextRefill(bucket): number

Parameters

Name Type
bucket LeakyBucket

Returns

number

Defined in

packages/utils/dist/bucket.d.ts:53


processReactionString

processReactionString(reaction): string

Converts an reaction emoji unicode string to the discord required form of name:id

Parameters

Name Type
reaction string

Returns

string

Defined in

packages/utils/dist/reactions.d.ts:2


red

red(str): string

Set text color to red.

Parameters

Name Type Description
str string text to make red

Returns

string

Defined in

packages/utils/dist/colors.d.ts:68


removeTokenPrefix

removeTokenPrefix(token?, type?): string

Removes the Bot before the token.

Parameters

Name Type
token? string
type? "GATEWAY" | "REST"

Returns

string

Defined in

packages/utils/dist/token.d.ts:2


reset

reset(str): string

Reset the text modified

Parameters

Name Type Description
str string text to reset

Returns

string

Defined in

packages/utils/dist/colors.d.ts:23


rgb24

rgb24(str, color): string

Set text color using 24bit rgb. color can be a number in range 0x000000 to 0xffffff or an Rgb.

To produce the color magenta:

     import { rgb24 } from "./colors.ts";
     rgb24("foo", 0xff00ff);
     rgb24("foo", {r: 255, g: 0, b: 255});

Parameters

Name Type Description
str string text color to apply 24bit rgb to
color number | Rgb code

Returns

string

Defined in

packages/utils/dist/colors.d.ts:253


rgb8

rgb8(str, color): string

Set text color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

Parameters

Name Type Description
str string text color to apply paletted 8bit colors to
color number code

Returns

string

Defined in

packages/utils/dist/colors.d.ts:230


setColorEnabled

setColorEnabled(value): void

Set changing text color to enabled or disabled

Parameters

Name Type
value boolean

Returns

void

Defined in

packages/utils/dist/colors.d.ts:16


snakeToCamelCase

snakeToCamelCase(str): string

Parameters

Name Type
str string

Returns

string

Defined in

packages/utils/dist/casing.d.ts:4


snakelize

snakelize<T>(object): Snakelize<T>

Type parameters

Name
T

Parameters

Name Type
object T

Returns

Snakelize<T>

Defined in

packages/utils/dist/casing.d.ts:3


strikethrough

strikethrough(str): string

Put horizontal line through the center of the text.

Parameters

Name Type Description
str string text to strike through

Returns

string

Defined in

packages/utils/dist/colors.d.ts:58


stripColor

stripColor(string): string

Remove ANSI escape codes from the string.

Parameters

Name Type Description
string string to remove ANSI escape codes from

Returns

string

Defined in

packages/utils/dist/colors.d.ts:274


underline

underline(str): string

Make the text underline.

Parameters

Name Type Description
str string text to underline

Returns

string

Defined in

packages/utils/dist/colors.d.ts:43


updateTokens

updateTokens(bucket): number

Update the tokens of that bucket.

Parameters

Name Type
bucket LeakyBucket

Returns

number

The amount of current available tokens.

Defined in

packages/utils/dist/bucket.d.ts:52


urlToBase64

urlToBase64(url): Promise<string>

Converts a url to base 64. Useful for example, uploading/creating server emojis.

Parameters

Name Type
url string

Returns

Promise<string>

Defined in

packages/utils/dist/urlToBase64.d.ts:2


white

white(str): string

Set text color to white.

Parameters

Name Type Description
str string text to make white

Returns

string

Defined in

packages/utils/dist/colors.d.ts:98


yellow

yellow(str): string

Set text color to yellow.

Parameters

Name Type Description
str string text to make yellow

Returns

string

Defined in

packages/utils/dist/colors.d.ts:78