Skip to main content

@sapphire/framework

Namespaces

Enumerations

Classes

Interfaces

Type aliases

ApplicationCommandRegistryRegisterOptions

Ƭ ApplicationCommandRegistryRegisterOptions: RegisterOptions

Defined in

projects/framework/src/lib/utils/application-commands/ApplicationCommandRegistry.ts:453


ArgumentResult

Ƭ ArgumentResult<T>: Awaitable<Result<T, UserError>>

Defines a synchronous result of an Argument, check Argument.AsyncResult for the asynchronous version.

Type parameters

Name
T

Defined in

projects/framework/src/lib/structures/Argument.ts:13


AsyncArgumentResult

Ƭ AsyncArgumentResult<T>: Promise<Result<T, UserError>>

Defines an asynchronous result of an Argument, check Argument.Result for the synchronous version.

Type parameters

Name
T

Defined in

projects/framework/src/lib/structures/Argument.ts:18


AsyncPluginHooks

Ƭ AsyncPluginHooks: PreLogin | PostLogin

Defined in

projects/framework/src/lib/plugins/PluginManager.ts:8


AsyncPreconditionContainerReturn

Ƭ AsyncPreconditionContainerReturn: Promise<PreconditionContainerResult>

Async-only version of PreconditionContainerReturn, to be used when the run method is async.

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/IPreconditionContainer.ts:24


AsyncPreconditionResult

Ƭ AsyncPreconditionResult: Promise<Result<unknown, UserError>>

Defined in

projects/framework/src/lib/structures/Precondition.ts:11


AutocompleteCommand

Ƭ AutocompleteCommand: Command & Required<Pick<Command, "autocompleteRun">>

Defined in

projects/framework/src/lib/structures/Command.ts:504


Awaitable

Ƭ Awaitable<T>: PromiseLike<T> | T

ReturnType for a function that can return either a value or a Promise with that value

Type parameters

Name
T

Defined in

node_modules/@sapphire/utilities/dist/lib/utilityTypes.d.ts:44


ChatInputCommand

Ƭ ChatInputCommand: Command & Required<Pick<Command, "chatInputRun">>

Defined in

projects/framework/src/lib/structures/Command.ts:484


CommandOptionsRunType

Ƭ CommandOptionsRunType: "DM" | "GUILD_TEXT" | "GUILD_NEWS" | "GUILD_NEWS_THREAD" | "GUILD_PUBLIC_THREAD" | "GUILD_PRIVATE_THREAD" | "GUILD_ANY"

The allowed values for {@link Command.Options.runIn}.

remark It is discouraged to use this type, we recommend using {@link Command.OptionsRunTypeEnum} instead.

since 2.0.0

Defined in

projects/framework/src/lib/structures/Command.ts:519


ContextMenuCommand

Ƭ ContextMenuCommand: Command & Required<Pick<Command, "contextMenuRun">>

Defined in

projects/framework/src/lib/structures/Command.ts:494


Err

Ƭ Err<E>: Lexure.Err<E>

The computation failed.

Type parameters

NameDescription
EType of errors.

Defined in

projects/framework/src/lib/parsers/Result.ts:21


InteractionHandlerParseResult

Ƭ InteractionHandlerParseResult<Instance>: UnwrapMaybeValue<Awaited<ReturnType<Instance["parse"]>>>

Type parameters

NameType
Instanceextends InteractionHandler

Defined in

projects/framework/src/lib/structures/InteractionHandler.ts:97


LogMethods

Ƭ LogMethods: "trace" | "debug" | "info" | "warn" | "error"

Defined in

projects/framework/src/lib/utils/logger/Logger.ts:54


Maybe

Ƭ Maybe<T>: Some<T> | None

A type used to express a value that may or may not exist.

Type parameters

NameDescription
TThe value's type.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:7


MessageCommand

Ƭ MessageCommand: Command & Required<Pick<Command, "messageRun">>

Defined in

projects/framework/src/lib/structures/Command.ts:474


None

Ƭ None: option.None

An empty value.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:18


Ok

Ƭ Ok<T>: Lexure.Ok<T>

The computation is successful.

Type parameters

NameDescription
TType of results.

Defined in

projects/framework/src/lib/parsers/Result.ts:15


PreconditionArrayResolvable

Ƭ PreconditionArrayResolvable: readonly PreconditionEntryResolvable[] | PreconditionArrayResolvableDetails

Defines the data accepted by PreconditionContainerArray's constructor.

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/PreconditionContainerArray.ts:75


PreconditionContainerResult

Ƭ PreconditionContainerResult: Result<unknown, UserError>

Defines the result's value for a PreconditionContainer.

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/IPreconditionContainer.ts:12


PreconditionContainerReturn

Ƭ PreconditionContainerReturn: Awaitable<PreconditionContainerResult>

Defines the return type of the generic IPreconditionContainer.messageRun.

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/IPreconditionContainer.ts:18


PreconditionEntryResolvable

Ƭ PreconditionEntryResolvable: PreconditionSingleResolvable | PreconditionArrayResolvable

Defines the data accepted for each entry of the array.

since 1.0.0

seealso PreconditionArrayResolvable

seealso PreconditionArrayResolvableDetails.entries

Defined in

projects/framework/src/lib/utils/preconditions/PreconditionContainerArray.ts:83


PreconditionKeys

Ƭ PreconditionKeys: keyof Preconditions

Defined in

projects/framework/src/lib/structures/Precondition.ts:128


PreconditionResult

Ƭ PreconditionResult: Awaitable<Result<unknown, UserError>>

Defined in

projects/framework/src/lib/structures/Precondition.ts:10


PreconditionSingleResolvable

Ƭ PreconditionSingleResolvable: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionSingleResolvableDetails

Defines the data accepted by PreconditionContainerSingle's constructor.

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/PreconditionContainerSingle.ts:43


Result

Ƭ Result<T, E>: Ok<T> | Err<E>

A type used to express computations that can fail.

Type parameters

NameDescription
TThe result's type.
EThe error's type.

Defined in

projects/framework/src/lib/parsers/Result.ts:9


SapphirePrefix

Ƭ SapphirePrefix: string | readonly string[] | null

A valid prefix in Sapphire.

  • string: a single prefix, e.g. '!'.
  • string[]: an array of prefixes, e.g. ['!', '.'].
  • null: disabled prefix, locks the bot's command usage to mentions only.

Defined in

projects/framework/src/lib/SapphireClient.ts:26


SimplePreconditionKeys

Ƭ SimplePreconditionKeys: { [K in PreconditionKeys]: Preconditions[K] extends never ? K : never }[PreconditionKeys]

Defined in

projects/framework/src/lib/structures/Precondition.ts:129


Some

Ƭ Some<T>: option.Some<T>

A value that exists.

Type parameters

NameDescription
TThe value's type.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:13


SyncPluginHooks

Ƭ SyncPluginHooks: Exclude<PluginHook, AsyncPluginHooks>

Defined in

projects/framework/src/lib/plugins/PluginManager.ts:13


UnwrapMaybeValue

Ƭ UnwrapMaybeValue<T>: T extends Some<infer V> ? V : never

Type parameters

NameType
Textends Maybe<unknown>

Defined in

projects/framework/src/lib/parsers/Maybe.ts:98

Variables

ApplicationCommandRegistries

ApplicationCommandRegistries: Object

Type declaration

NameType
acquire(commandName: string) => ApplicationCommandRegistry
getDefaultBehaviorWhenNotIdentical() => RegisterBehavior
setDefaultBehaviorWhenNotIdentical(behavior?: null | RegisterBehavior) => void
`get registries(): ReadonlyMap<string, ApplicationCommandRegistry>`Object

Defined in

projects/framework/src/index.ts:22


CorePreconditions

CorePreconditions: Object

Type declaration

NameType
ClientPermissionstypeof CorePrecondition
Cooldowntypeof CorePrecondition
DMOnlytypeof CorePrecondition
Enabledtypeof CorePrecondition
GuildNewsOnlytypeof CorePrecondition
GuildNewsThreadOnlytypeof CorePrecondition
GuildOnlytypeof CorePrecondition
GuildPrivateThreadOnlytypeof CorePrecondition
GuildPublicThreadOnlytypeof CorePrecondition
GuildTextOnlytypeof CorePrecondition
GuildThreadOnlytypeof CorePrecondition
NSFWtypeof CorePrecondition
UserPermissionstypeof CorePrecondition

Defined in

projects/framework/src/index.ts:85


Events

Events: Object

Type declaration

NameType
ChannelCreate"channelCreate"
ChannelDelete"channelDelete"
ChannelPinsUpdate"channelPinsUpdate"
ChannelUpdate"channelUpdate"
ChatInputCommandAccepted"chatInputCommandAccepted"
ChatInputCommandDenied"chatInputCommandDenied"
ChatInputCommandError"chatInputCommandError"
ChatInputCommandFinish"chatInputCommandFinish"
ChatInputCommandRun"chatInputCommandRun"
ChatInputCommandSuccess"chatInputCommandSuccess"
ClientReady"ready"
CommandApplicationCommandRegistryError"commandApplicationCommandRegistryError"
CommandAutocompleteInteractionError"commandAutocompleteInteractionError"
CommandAutocompleteInteractionSuccess"commandAutocompleteInteractionSuccess"
CommandDoesNotHaveChatInputCommandHandler"commandDoesNotHaveChatInputCommandHandler"
CommandDoesNotHaveContextMenuCommandHandler"commandDoesNotHaveContextMenuCommandHandler"
CommandDoesNotHaveMessageCommandHandler"commandDoesNotHaveMessageCommandHandler"
ContextMenuCommandAccepted"contextMenuCommandAccepted"
ContextMenuCommandDenied"contextMenuCommandDenied"
ContextMenuCommandError"contextMenuCommandError"
ContextMenuCommandFinish"contextMenuCommandFinish"
ContextMenuCommandRun"contextMenuCommandRun"
ContextMenuCommandSuccess"contextMenuCommandSuccess"
Debug"debug"
Error"error"
GuildBanAdd"guildBanAdd"
GuildBanRemove"guildBanRemove"
GuildCreate"guildCreate"
GuildDelete"guildDelete"
GuildEmojiCreate"emojiCreate"
GuildEmojiDelete"emojiDelete"
GuildEmojiUpdate"emojiUpdate"
GuildIntegrationsUpdate"guildIntegrationsUpdate"
GuildMemberAdd"guildMemberAdd"
GuildMemberAvailable"guildMemberAvailable"
GuildMemberRemove"guildMemberRemove"
GuildMemberUpdate"guildMemberUpdate"
GuildMembersChunk"guildMembersChunk"
GuildRoleCreate"roleCreate"
GuildRoleDelete"roleDelete"
GuildRoleUpdate"roleUpdate"
GuildStickerCreate"stickerCreate"
GuildStickerDelete"stickerDelete"
GuildStickerUpdate"stickerUpdate"
GuildUnavailable"guildUnavailable"
GuildUpdate"guildUpdate"
InteractionCreate"interactionCreate"
InteractionHandlerError"interactionHandlerError"
InteractionHandlerParseError"interactionHandlerParseError"
InvalidRequestWarning"invalidRequestWarning"
Invalidated"invalidated"
InviteCreate"inviteCreate"
InviteDelete"inviteDelete"
ListenerError"listenerError"
MentionPrefixOnly"mentionPrefixOnly"
MessageBulkDelete"messageDeleteBulk"
MessageCommandAccepted"messageCommandAccepted"
MessageCommandDenied"messageCommandDenied"
MessageCommandError"messageCommandError"
MessageCommandFinish"messageCommandFinish"
MessageCommandRun"messageCommandRun"
MessageCommandSuccess"messageCommandSuccess"
MessageCommandTypingError"messageCommandTypingError"
MessageCreate"messageCreate"
MessageDelete"messageDelete"
MessageReactionAdd"messageReactionAdd"
MessageReactionRemove"messageReactionRemove"
MessageReactionRemoveAll"messageReactionRemoveAll"
MessageReactionRemoveEmoji"messageReactionRemoveEmoji"
MessageUpdate"messageUpdate"
NonPrefixedMessage"nonPrefixedMessage"
PiecePostLoad"piecePostLoad"
PieceUnload"pieceUnload"
PluginLoaded"pluginLoaded"
PossibleAutocompleteInteraction"possibleAutocompleteInteraction"
PossibleChatInputCommand"possibleChatInputCommand"
PossibleContextMenuCommand"possibleContextMenuCommand"
PreChatInputCommandRun"preChatInputCommandRun"
PreContextMenuCommandRun"preContextMenuCommandRun"
PreMessageCommandRun"preMessageCommandRun"
PreMessageParsed"preMessageParsed"
PrefixedMessage"prefixedMessage"
PresenceUpdate"presenceUpdate"
RateLimit"rateLimit"
Raw"raw"
ShardDisconnect"shardDisconnect"
ShardError"shardError"
ShardReady"shardReady"
ShardReconnecting"shardReconnecting"
ShardResume"shardResume"
StageInstanceCreate"stageInstanceCreate"
StageInstanceDelete"stageInstanceDelete"
StageInstanceUpdate"stageInstanceUpdate"
ThreadCreate"threadCreate"
ThreadDelete"threadDelete"
ThreadListSync"threadListSync"
ThreadMemberUpdate"threadMemberUpdate"
ThreadMembersUpdate"threadMembersUpdate"
ThreadUpdate"threadUpdate"
TypingStart"typingStart"
UnknownChatInputCommand"unknownChatInputCommand"
UnknownContextMenuCommand"unknownContextMenuCommand"
UnknownMessageCommand"unknownMessageCommand"
UnknownMessageCommandName"unknownMessageCommandName"
UserUpdate"userUpdate"
VoiceServerUpdate"voiceServerUpdate"
VoiceStateUpdate"voiceStateUpdate"
Warn"warn"
WebhooksUpdate"webhookUpdate"

Defined in

projects/framework/src/lib/types/Events.ts:18


InteractionHandlerFilters

InteractionHandlerFilters: Map<InteractionHandlerTypes, (interaction: Interaction<CacheType>) => boolean>

Defined in

projects/framework/src/lib/structures/InteractionHandlerStore.ts:78


PreconditionConditionAnd

PreconditionConditionAnd: IPreconditionCondition

An IPreconditionCondition which runs all containers similarly to doing (V0 && V1 [&& V2 [&& V3 ...]]).

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/conditions/PreconditionConditionAnd.ts:8


PreconditionConditionOr

PreconditionConditionOr: IPreconditionCondition

An IPreconditionCondition which runs all containers similarly to doing (V0 || V1 [|| V2 [|| V3 ...]]).

since 1.0.0

Defined in

projects/framework/src/lib/utils/preconditions/conditions/PreconditionConditionOr.ts:9


container

container: Container

The injected variables that will be accessible to any place. To add an extra property, simply add a property with a regular assignment, and it will be available in all places simultaneously.

example

// Add a reference to the Client:
import { container } from '@sapphire/pieces';

export class SapphireClient extends Client {
constructor(options) {
super(options);

container.client = this;
}
}

// Can be placed anywhere in a TypeScript file, for JavaScript projects,
// you can create an `augments.d.ts` and place the code there.
declare module '@sapphire/pieces' {
interface Container {
client: SapphireClient;
}
}

// In any piece, core, plugin, or custom:
export class UserCommand extends Command {
public run(message, args) {
// The injected client is available here:
const { client } = this.container;

// ...
}
}

example

// In a plugin's context, e.g. API:
class Api extends Plugin {
static [postInitialization]() {
const server = new Server(this);
container.server = server;

// ...
}
}

declare module '@sapphire/pieces' {
interface Container {
server: Server;
}
}

// In any piece, even those that aren't routes nor middlewares:
export class UserRoute extends Route {
public [methods.POST](message, args) {
// The injected server is available here:
const { server } = this.container;

// ...
}
}

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:648


postInitialization

postInitialization: unique symbol

Defined in

projects/framework/src/lib/plugins/symbols.ts:3


postLogin

postLogin: unique symbol

Defined in

projects/framework/src/lib/plugins/symbols.ts:6


preGenericsInitialization

preGenericsInitialization: unique symbol

Defined in

projects/framework/src/lib/plugins/symbols.ts:1


preInitialization

preInitialization: unique symbol

Defined in

projects/framework/src/lib/plugins/symbols.ts:2


preLogin

preLogin: unique symbol

Defined in

projects/framework/src/lib/plugins/symbols.ts:5


version

version: string = '[VI]{version}[/VI]'

The @sapphire/framework version that you are currently using. An example use of this is showing it of in a bot information command.

Note to Sapphire developers: This needs to explicitly be string so it is not typed as the string that gets replaced by Rollup

Defined in

projects/framework/src/index.ts:113

Functions

err

err(): Err<unknown>

Creates an Err with no error.

Returns

Err<unknown>

An erroneous Result.

Defined in

projects/framework/src/lib/parsers/Result.ts:43

err<E>(x): Err<E>

Creates an Err.

Type parameters

NameDescription
EThe error's type.

Parameters

NameTypeDescription
xEValue to use.

Returns

Err<E>

An erroneous Result.

Defined in

projects/framework/src/lib/parsers/Result.ts:50


from

from<T, E>(cb): Result<T, E>

Creates a Result out of a callback.

Type parameters

NameTypeDescription
TTThe result's type.
EunknownThe error's type.

Parameters

NameType
cb(...args: unknown[]) => T

Returns

Result<T, E>

Defined in

projects/framework/src/lib/parsers/Result.ts:78


fromAsync

fromAsync<T, E>(promiseOrCb): Promise<Result<T, E>>

Creates a Result out of a promise or async callback.

Type parameters

NameTypeDescription
TTThe result's type.
EunknownThe error's type.

Parameters

NameType
promiseOrCbAwaitable<T> | (...args: unknown[]) => Awaitable<T>

Returns

Promise<Result<T, E>>

Defined in

projects/framework/src/lib/parsers/Result.ts:91


isErr

isErr<T, E>(x): x is Err<E>

Determines whether or not a result is an Err.

Type parameters

NameDescription
TThe result's type.
EThe error's type.

Parameters

NameType
xResult<T, E>

Returns

x is Err<E>

Defined in

projects/framework/src/lib/parsers/Result.ts:69


isMaybe

isMaybe<T>(x): true

Type-safe helper to preserve the type parameter's type.

Type parameters

Name
T

Parameters

NameTypeDescription
xMaybe<T>The value to check.

Returns

true

Defined in

projects/framework/src/lib/parsers/Maybe.ts:88

isMaybe<T>(x): x is Maybe<T>

Determines whether or not an arbitrary value is a Maybe.

Type parameters

Name
T

Parameters

NameTypeDescription
xunknownThe value to check.

Returns

x is Maybe<T>

Defined in

projects/framework/src/lib/parsers/Maybe.ts:93


isNone

isNone<T>(x): x is None

Determines whether or not a Maybe is a None.

Type parameters

NameDescription
TThe value's type.

Parameters

NameType
xMaybe<T>

Returns

x is None

Defined in

projects/framework/src/lib/parsers/Maybe.ts:80


isOk

isOk<T, E>(x): x is Ok<T>

Determines whether or not a result is an Ok.

Type parameters

NameDescription
TThe result's type.
EThe error's type.

Parameters

NameType
xResult<T, E>

Returns

x is Ok<T>

Defined in

projects/framework/src/lib/parsers/Result.ts:60


isSome

isSome<T>(x): x is Some<T>

Determines whether or not a Maybe is a Some.

Type parameters

NameDescription
TThe value's type.

Parameters

NameType
xMaybe<T>

Returns

x is Some<T>

Defined in

projects/framework/src/lib/parsers/Maybe.ts:72


maybe

maybe<T, V>(value): V

Returns the maybe itself.

Type parameters

NameType
TT
Vextends Maybe<T>

Parameters

NameTypeDescription
valueVThe value to convert.

Returns

V

Defined in

projects/framework/src/lib/parsers/Maybe.ts:24

maybe(value): None

Creates a None from an existing None or a null.

Parameters

NameTypeDescription
valuenull | NoneThe value to convert.

Returns

None

Defined in

projects/framework/src/lib/parsers/Maybe.ts:29

maybe<T>(value): Maybe<T>

Creates a Some from a non-null value or an existing Some, or a None otherwise.

Type parameters

Name
T

Parameters

NameTypeDescription
valuenull | T | Maybe<T>The value to convert.

Returns

Maybe<T>

Defined in

projects/framework/src/lib/parsers/Maybe.ts:34

maybe<T>(value): Some<T>

Creates a Some from a non-null value or an existing Some.

Type parameters

Name
T

Parameters

NameTypeDescription
valueT | Some<T>The value to convert.

Returns

Some<T>

Defined in

projects/framework/src/lib/parsers/Maybe.ts:39


none

none(): None

Creates a None value.

Returns

None

A non-existing Maybe.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:64


ok

ok(): Ok<unknown>

Creates an Ok with no value.

Returns

Ok<unknown>

A successful Result.

Defined in

projects/framework/src/lib/parsers/Result.ts:27

ok<T>(x): Ok<T>

Creates an Ok.

Type parameters

NameDescription
TThe result's type.

Parameters

NameTypeDescription
xTValue to use.

Returns

Ok<T>

A successful Result.

Defined in

projects/framework/src/lib/parsers/Result.ts:34


some

some(): Some<unknown>

Creates a None with no value.

Returns

Some<unknown>

An existing Maybe.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:48

some<T>(x): Some<T>

Creates a None with a value.

Type parameters

NameDescription
TThe value's type.

Parameters

NameTypeDescription
xTValue to use.

Returns

Some<T>

An existing Maybe.

Defined in

projects/framework/src/lib/parsers/Maybe.ts:55