Skip to main content

@sapphire/framework

Namespaces

Enumerations

Classes

Interfaces

References

ClientPermissionsCorePrecondition

Renames and re-exports ClientPermissions

Type aliases

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


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


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:345


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


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


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.run.

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:103


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:22


SimplePreconditionKeys

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

Defined in

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


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

Variables

Events

โ€ข Events: Object

Type declaration

NameType
ChannelCreate"channelCreate"
ChannelDelete"channelDelete"
ChannelPinsUpdate"channelPinsUpdate"
ChannelUpdate"channelUpdate"
ClientReady"ready"
CommandAccepted"commandAccepted"
CommandDenied"commandDenied"
CommandError"commandError"
CommandFinish"commandFinish"
CommandRun"commandRun"
CommandSuccess"commandSuccess"
CommandTypingError"commandTypingError"
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"
GuildUnavailable"guildUnavailable"
GuildUpdate"guildUpdate"
Invalidated"invalidated"
InviteCreate"inviteCreate"
InviteDelete"inviteDelete"
ListenerError"listenerError"
MentionPrefixOnly"mentionPrefixOnly"
MessageBulkDelete"messageDeleteBulk"
MessageCreate"messageCreate"
MessageDelete"messageDelete"
MessageReactionAdd"messageReactionAdd"
MessageReactionRemove"messageReactionRemove"
MessageReactionRemoveAll"messageReactionRemoveAll"
MessageUpdate"messageUpdate"
NonPrefixedMessage"nonPrefixedMessage"
PiecePostLoad"piecePostLoad"
PieceUnload"pieceUnload"
PluginLoaded"pluginLoaded"
PreCommandRun"preCommandRun"
PreMessageParsed"preMessageParsed"
PrefixedMessage"prefixedMessage"
PresenceUpdate"presenceUpdate"
RateLimit"rateLimit"
Raw"raw"
ShardDisconnect"shardDisconnect"
ShardError"shardError"
ShardReady"shardReady"
ShardReconnecting"shardReconnecting"
ShardResume"shardResume"
TypingStart"typingStart"
UnknownCommand"unknownCommand"
UnknownCommandName"unknownCommandName"
UserUpdate"userUpdate"
VoiceStateUpdate"voiceStateUpdate"
Warn"warn"
WebhooksUpdate"webhookUpdate"

Defined in

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


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:64

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