### Install ForgeScript (Main) Source: https://github.com/tryforge/forgescript/blob/main/README.md Installs the main version of ForgeScript from GitHub. Ensure Node.js v16.11.0 or higher is installed. ```bash npm i https://github.com/tryforge/ForgeScript/tree/main ``` -------------------------------- ### Install ForgeScript (Dev) Source: https://github.com/tryforge/forgescript/blob/main/README.md Installs the development version of ForgeScript from GitHub. Ensure Node.js v16.11.0 or higher is installed. ```bash npm i https://github.com/tryforge/ForgeScript/tree/dev ``` -------------------------------- ### Install TypeScript Globally Source: https://github.com/tryforge/forgescript/blob/main/EXTENSIONS.md Installs the TypeScript compiler globally on your system. This is a prerequisite for compiling your extension. ```bash npm i --g typescript ``` -------------------------------- ### Install ForgeScript and TypeScript as Dev Dependencies Source: https://github.com/tryforge/forgescript/blob/main/EXTENSIONS.md Installs the ForgeScript library and TypeScript as development dependencies for your project. Ensure you are in your project's root directory. ```bash npm i typescript github:tryforge/ForgeScript#dev --save-dev ``` -------------------------------- ### get Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommandManager.html Retrieves commands based on type and an optional filter function. ```APIDOC ## get(type: T, fn?: (cmd) => boolean): BaseCommand[] ### Description Retrieves commands based on type and an optional filter function. ### Method (Implicitly a method of BaseCommandManager) ### Parameters * **type** (T) - The type of command to retrieve. * **fn** ((cmd) => boolean, Optional) - An optional function to filter the commands. * **cmd** (BaseCommand) - The command to check. * Returns **boolean** - True if the command matches the filter. ### Returns BaseCommand[] - An array of BaseCommand instances. ``` -------------------------------- ### obj Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets or sets the Sendable object associated with the context. ```APIDOC ## get obj() ### Description Retrieves the Sendable object associated with the current context. ### Method GET ### Endpoint `/context/obj` ### Returns - **Sendable** - The Sendable object. ``` ```APIDOC ## set obj(o: Sendable) ### Description Sets the Sendable object for the current context. ### Method PUT ### Endpoint `/context/obj` ### Parameters #### Request Body - **o** (Sendable) - Required - The Sendable object to set. ``` -------------------------------- ### sound Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the soundboard sound associated with the context. Returns null if no sound is present. ```APIDOC ## get sound() ### Description Retrieves the soundboard sound object associated with the current context. ### Returns - `SoundboardSound` | `null`: The soundboard sound object, or null if none is available. ### Source `src/structures/@internal/Context.ts:226` ``` -------------------------------- ### sticker Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the sticker associated with the context. Returns null if no sticker is present. ```APIDOC ## get sticker() ### Description Retrieves the sticker object associated with the current context. ### Returns - `Sticker` | `null`: The sticker object, or null if none is available. ### Source `src/structures/@internal/Context.ts:222` ``` -------------------------------- ### get Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Retrieves a value from the context using a specified key. The type of the returned value is determined by the generic type parameter T. ```APIDOC ## get ### Description Retrieves a value from the context by key. ### Method get ### Type Parameters * T ### Parameters #### Path Parameters * `key` (PropertyKey) - Required - The key of the property to retrieve. ### Returns T ``` -------------------------------- ### reason Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets or sets the reason string for the context. This is often used for audit logs or explanations. ```APIDOC ## reason ### Description Manages the reason string associated with the context. This can be retrieved or set. ### Getter - `get reason(): undefined | string` Retrieves the reason string. Returns undefined if no reason is set. ### Setter - `set reason(str: undefined | string): void` Sets the reason string for the context. ### Source - Getter: `src/structures/@internal/Context.ts:175` - Setter: `src/structures/@internal/Context.ts:171` ``` -------------------------------- ### Get Event Listeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Returns a copy of the array containing all listeners for a given event name. Includes an example of logging the listeners for a 'connection' event. ```typescript listeners(eventName: string | symbol): Function[] server.on('connection', (stream) => { console.log('someone connected!'); }); console.log(util.inspect(server.listeners('connection'))); // Prints: [ [Function] ] ``` -------------------------------- ### Initialize Project with npm Source: https://github.com/tryforge/forgescript/blob/main/EXTENSIONS.md Initializes a new Node.js project in the current directory with default settings. This creates a package.json file. ```bash npm init --y ``` -------------------------------- ### ApplicationCommand Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ApplicationCommand.html Initializes a new instance of the ApplicationCommand class. It takes an options object conforming to IApplicationCommandData. ```APIDOC ## constructor ### Description Initializes a new instance of the ApplicationCommand class. ### Parameters #### Parameters - **options** (IApplicationCommandData) - The data to initialize the ApplicationCommand with. ### Returns [ApplicationCommand] ### Defined in src/structures/base/ApplicationCommand.ts:14 ``` -------------------------------- ### init Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/InviteTracker.html Initializes the InviteTracker with a client. This is a private static method. ```APIDOC ## init ### Description Initializes the InviteTracker with a client. This method is intended for internal use. ### Method Static, Private ### Parameters #### client * client (ForgeClient) - The ForgeClient instance to initialize with. ### Returns * void - This method does not return a value. ``` -------------------------------- ### run Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ThreadManager.html Executes a task within a given context and returns the result. ```APIDOC ## run ### Description Executes a task within a given context and returns the result. ### Method run(ctx: IThreadContext): Promise ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **result** (null | string) - The result of the task execution. #### Response Example None ``` -------------------------------- ### get Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunctionManager.html Retrieves a specific function by its name. ```APIDOC ## get ### Description Retrieves a specific function by its name. ### Method get ### Endpoint /get ### Parameters #### Query Parameters - **name** (string) - Required - The name of the function to retrieve. ### Response #### Success Response (200) - **function** (CompiledFunction) - The compiled function object. ``` -------------------------------- ### VoiceTracker.init Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/VoiceTracker.html Initializes the VoiceTracker with a given client. This is a static method intended for internal use. ```APIDOC ## `Static` `Private` init ### Description Initializes the VoiceTracker with a given client. ### Parameters #### client: [ForgeClient](ForgeClient.html) ### Returns void ### Defined in [src/structures/trackers/VoiceTracker.ts:12](https://github.com/tryforge/ForgeScript/blob/42867929/src/structures/trackers/VoiceTracker.ts#L12) ``` -------------------------------- ### get Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Retrieves a value by its key. This method is defined in ForgeClient. ```APIDOC ## get ### Description Retrieves a value by its key. ### Method `get(key: string): T` ### Type Parameters #### T ### Parameters #### Path Parameters * **key** (string) - Required - The key of the value to retrieve. ### Returns T ``` -------------------------------- ### client Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunctionManager.html Gets the Forge client instance associated with this manager. ```APIDOC ## client ### Description Gets the Forge client instance associated with this manager. ### Method get ### Endpoint /client ### Parameters This method does not take any parameters. ### Response #### Success Response (200) - **client** (ForgeClient) - The associated Forge client instance. ``` -------------------------------- ### ApplicationCommand Methods Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ApplicationCommand.html Details the methods available on an ApplicationCommand instance. ```APIDOC ## Methods ### mustRegisterAs - **mustRegisterAs(type: Global | Guild)**: boolean - Checks if the command must be registered as a specific type. - #### Parameters - **type** (Global | Guild) - The registration type to check against. - #### Returns - boolean - True if the command must be registered as the specified type, false otherwise. - Defined in src/structures/base/ApplicationCommand.ts:26 ### toJSON - **toJSON()**: RESTPostAPIApplicationCommandsJSONBody - Converts the ApplicationCommand instance to a JSON object suitable for API requests. - #### Returns - RESTPostAPIApplicationCommandsJSONBody - The JSON representation of the command. - Defined in src/structures/base/ApplicationCommand.ts:30 ``` -------------------------------- ### populate Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunctionManager.html Populates functions into the client's context. ```APIDOC ## populate ### Description Populates functions into the client's context. ### Method populate ### Endpoint /populate ### Parameters This method does not take any parameters. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the functions were populated successfully. ``` -------------------------------- ### listeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommandManager.html Gets an array of listeners for a specific event. Inherited from TypedEmitter. ```APIDOC ## listeners(type: U): ICommandManagerEvents[U][] ### Description Gets an array of listeners for a specific event. ### Method (Implicitly a method of BaseCommandManager) ### Parameters * **type** (U) - The type of event for which to retrieve listeners. ### Returns ICommandManagerEvents[U][] - An array of listeners for the specified event. ``` -------------------------------- ### BaseCommand Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommand.html Initializes a new instance of the BaseCommand class. It accepts an IBaseCommand object containing data for the command. ```APIDOC ## constructor ### Description Initializes a new instance of the BaseCommand class. ### Parameters #### Parameters - **data** (IBaseCommand) - The data object for the command. ### Returns - [BaseCommand](BaseCommand.html) ### Type Parameters * #### T ``` -------------------------------- ### BaseCommandManager.count Accessor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommandManager.html Gets the number of commands currently managed by this instance. ```APIDOC ## count ### Description Gets the number of commands currently managed by this instance. ### Returns - **number** - The total count of commands. ### Defined in src/managers/BaseCommandManager.ts:64 ``` -------------------------------- ### options Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Client options, including intents and other Forge-specific configurations. ```APIDOC ## options ### Description Client options, including intents and other Forge-specific configurations. ### Type Omit & { intents: IntentsBitField; } & [IForgeClientOptions](../interfaces/IForgeClientOptions.html) ### Overrides Client.options ### Defined in [src/core/ForgeClient.ts:122](https://github.com/tryforge/ForgeScript/blob/42867929/src/core/ForgeClient.ts#L122) ``` -------------------------------- ### load Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ApplicationCommandManager.html Loads application commands from a specified path. This method is crucial for initializing command handlers. ```APIDOC ## load ### Description Loads application commands from a specified path. This method is crucial for initializing command handlers. ### Method load ### Parameters #### Path Parameters * **path** (string) - Optional - The path to the directory containing application command definitions. ### Returns void ``` -------------------------------- ### getTimeLeft Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/CooldownManager.html Gets the remaining time left for a cooldown on a specific identifier. ```APIDOC ## getTimeLeft ### Description Gets the remaining time left for a cooldown on a specific identifier. ### Parameters #### Path Parameters * **id** (string) - The identifier of the cooldown. ### Returns number - The remaining time in milliseconds. ``` -------------------------------- ### Check if Client is Ready Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Checks if the client instance is ready. This method is inherited from the Client class. ```typescript isReady(): this is Client ``` -------------------------------- ### user Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the user associated with the context. Returns null if no user is present. ```APIDOC ## get user() ### Description Retrieves the user object associated with the current context. ### Returns - `User` | `null`: The user object, or null if none is available. ### Source `src/structures/@internal/Context.ts:251` ``` -------------------------------- ### subscription Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the subscription associated with the context. Returns null if no subscription is present. ```APIDOC ## get subscription() ### Description Retrieves the subscription object associated with the current context. ### Returns - `Subscription` | `null`: The subscription object, or null if none is available. ### Source `src/structures/@internal/Context.ts:205` ``` -------------------------------- ### useInviteSystem Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Deprecated. Use `trackers: { invites: true }` instead. ```APIDOC ## useInviteSystem ### Description Deprecated. Use `trackers: { invites: true }` instead. ### Type `boolean` ### Optional Yes ### Deprecated use trackers: { invites: true } instead ``` -------------------------------- ### load Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunctionManager.html Loads functions from a specified directory. ```APIDOC ## load ### Description Loads functions from a specified directory. ### Method load ### Endpoint /load ### Parameters #### Query Parameters - **directory** (string) - Required - The path to the directory containing the function files. ### Response #### Success Response (200) - **loadedCount** (number) - The number of functions loaded. ``` -------------------------------- ### inviteCreateHandler Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/InviteTracker.html Handles the creation of an invite. This is a static method. ```APIDOC ## inviteCreateHandler ### Description Handles the event when an invite is created. ### Method Static ### Parameters #### invite * invite (Invite) - The invite object that was created. ### Returns * Promise - A promise that resolves when the handler has finished. ``` -------------------------------- ### states Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the states associated with the context. Returns undefined if no states are present. ```APIDOC ## get states() ### Description Retrieves the states object associated with the current context. ### Returns - `States` | `undefined`: The states object, or undefined if none is available. ### Source `src/structures/@internal/Context.ts:193` ``` -------------------------------- ### role Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the role associated with the context. Returns null if no role is present. ```APIDOC ## get role() ### Description Retrieves the role object associated with the current context. ### Returns - `Role` | `null`: The role object, or null if none is available. ### Source `src/structures/@internal/Context.ts:230` ``` -------------------------------- ### create Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Arg.html Creates a new argument definition with specified options. This is a generic static method that can be used to define arguments of various types. ```APIDOC ## Static create(opts) ### Description Creates a new argument definition with specified options. ### Method Static ### Type Parameters * **Type** extends `ArgType` * **Required** extends `boolean` * **Rest** extends `boolean` * **Enum** extends `EnumLike` ### Parameters * **opts** (`IArg` ### validate * **validate**(): void ``` -------------------------------- ### listenerCount Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommandManager.html Gets the number of listeners for a specific event type. Inherited from TypedEmitter. ```APIDOC ## listenerCount(type: "update"): number ### Description Gets the number of listeners for a specific event type. ### Method (Implicitly a method of BaseCommandManager) ### Parameters * **type** ("update") - The type of event to count listeners for. ### Returns number - The number of listeners for the specified event type. ``` -------------------------------- ### getMaxListeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommandManager.html Gets the maximum number of listeners that can be added to an event. Inherited from TypedEmitter. ```APIDOC ## getMaxListeners(): number ### Description Gets the maximum number of listeners that can be added to an event. ### Method (Implicitly a method of BaseCommandManager) ### Returns number - The maximum number of listeners. ``` -------------------------------- ### BaseCommand Static Method: from Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/BaseCommand.html A static method to create a BaseCommand instance from a given code string. ```APIDOC ## `Static` from ### from * **from**(code: string): [BaseCommand](BaseCommand.html) ### Parameters #### Parameters - **code** (string) - The code string to create the command from. ``` -------------------------------- ### getOptions Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Container.html Retrieves options from the container, optionally filtering by content. ```APIDOC ## getOptions ### Description Retrieves options from the container, optionally filtering by content. ### Method Signature `getOptions(content?: string): T` ### Type Parameters #### T - **Description**: The expected type of the options. ### Parameters #### content (Optional) - **Type**: `string` - **Description**: Optional content to filter the options by. ``` -------------------------------- ### Interpreter Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Interpreter.html Initializes a new instance of the Interpreter class. ```APIDOC ## constructor ### Description Initializes a new instance of the Interpreter class. ### Method constructor ### Returns - [Interpreter](Interpreter.html) ``` -------------------------------- ### reaction Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the message reaction associated with the context. Returns null if no reaction is present. ```APIDOC ## get reaction() ### Description Retrieves the message reaction associated with the current context. ### Returns - `MessageReaction` | `null`: The message reaction object, or null if none is available. ### Source `src/structures/@internal/Context.ts:234` ``` -------------------------------- ### IRawForgeClientOptions Interface Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html The IRawForgeClientOptions interface outlines all the configurable properties for a Forge client. These options allow customization of bot behavior, including event handling, command processing, network settings, and more. ```APIDOC ## Interface: IRawForgeClientOptions ### Description Defines the configuration options for initializing a Forge client. This interface allows for detailed customization of the client's behavior, including event subscriptions, command handling, network configurations, and more. ### Properties * **allowBots** (boolean) - Optional - Whether to allow bots to interact with the client. * **allowedMentions** (MessageMentionOptions) - Optional - Options to control which mentions are processed. * **closeTimeout** (number) - Optional - Timeout in milliseconds before closing the connection. * **commands** (string) - Optional - Configuration for command handling. * **disableConsoleErrors** (boolean) - Optional - If true, console errors will be suppressed. * **enforceNonce** (boolean) - Optional - If true, nonces will be enforced for requests. * **events** (Array) - Optional - An array of client event keys to subscribe to. * **extensions** (Array) - Optional - An array of Forge extensions to load. * **failIfNotExists** (boolean) - Optional - If true, operations will fail if the target does not exist. * **functions** (string) - Optional - Configuration for custom functions. * **intents** (BitFieldResolvable<"Guilds" | "GuildMembers" | "GuildModeration" | "GuildBans" | "GuildExpressions" | "GuildEmojisAndStickers" | "GuildIntegrations" | "GuildWebhooks" | "GuildInvites" | "GuildVoiceStates" | "GuildPresences" | "GuildMessages" | "GuildMessageReactions" | "GuildMessageTyping" | "DirectMessages" | "DirectMessageReactions" | "DirectMessageTyping" | "MessageContent" | "GuildScheduledEvents" | "AutoModerationConfiguration" | "AutoModerationExecution" | "GuildMessagePolls" | "DirectMessagePolls", number">) - Required - Specifies the intents for the client. * **jsonTransformer** ((obj) => unknown) - Optional - A function to transform JSON objects. * **logLevel** (LogPriority) - Optional - The minimum log level to report. * **makeCache** (CacheFactory) - Optional - A factory function for creating caches. * **mobile** (boolean) - Optional - Enables mobile client emulation. * **optionalGuildID** (boolean) - Optional - If true, guild ID is optional for certain operations. * **partials** (Array) - Optional - Specifies the partials to be cached. * **prefixCaseInsensitive** (boolean) - Optional - If true, command prefixes are case-insensitive. * **prefixes** (Array) - Optional - An array of command prefixes. * **presence** (PresenceData) - Optional - Initial presence data for the client. * **respondOnEdit** (number | boolean) - Optional - Controls response behavior on message edits. * **rest** (Partial) - Optional - Options for the REST API. * **restrictions** (IRestrictions) - Optional - Configuration for operation restrictions. * **shardCount** (number) - Optional - The total number of shards to use. * **shards** (number | Array | "auto") - Optional - Specifies which shards to use or 'auto' for automatic sharding. * **sweepers** (SweeperOptions) - Optional - Options for cache sweepers. * **token** (string) - Optional - The authentication token for the client. * **trackers** (ITrackers) - Optional - Configuration for trackers. * **useInviteSystem** (boolean) - Optional - If true, the invite system is enabled. * **waitGuildTimeout** (number) - Optional - Timeout in milliseconds for waiting for guild data. * **ws** (WebSocketOptions) - Optional - WebSocket specific options. ### Hierarchy * ClientOptions * IRawForgeClientOptions ### Defined in * [src/core/ForgeClient.ts:55](https://github.com/tryforge/ForgeScript/blob/42867929/src/core/ForgeClient.ts#L55) ``` -------------------------------- ### message Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the Message object associated with the context. Returns null if the context is not message-related. ```APIDOC ## get message() ### Description Retrieves the Message object associated with the current context. ### Method GET ### Endpoint `/context/message` ### Returns - **Message** | null - The Message object or null if not applicable. ``` -------------------------------- ### member Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the GuildMember object associated with the context. Returns null if the member is not available. ```APIDOC ## get member() ### Description Retrieves the GuildMember object associated with the current context. ### Method GET ### Endpoint `/context/member` ### Returns - **GuildMember** | null - The GuildMember object or null if not available. ``` -------------------------------- ### interaction Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the Interaction object associated with the context. Returns null if the context is not an interaction. ```APIDOC ## get interaction() ### Description Retrieves the Interaction object associated with the current context. ### Method GET ### Endpoint `/context/interaction` ### Returns - **Interaction** | null - The Interaction object or null if not an interaction. ``` -------------------------------- ### ws Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html WebSocket options for the client. Inherited from ClientOptions. ```APIDOC ## ws ### Description WebSocket options for the client. ### Type `WebSocketOptions` ### Optional Yes ### Inherited Yes, from `ClientOptions` ``` -------------------------------- ### makeCache Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Configuration for the cache factory. Inherited from ClientOptions. ```APIDOC ## makeCache ### Description Configuration for the cache factory. ### Type `CacheFactory` ### Optional Yes ### Inherited Yes, from `ClientOptions` ``` -------------------------------- ### guild Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the Guild object associated with the context. Returns null if the context is not guild-related. ```APIDOC ## get guild() ### Description Retrieves the Guild object associated with the current context. ### Method GET ### Endpoint `/context/guild` ### Returns - **Guild** | null - The Guild object or null if not applicable. ``` -------------------------------- ### entitlement Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Gets the entitlement information associated with the context. Returns null if no entitlement is found. ```APIDOC ## get entitlement() ### Description Retrieves the entitlement information for the current context. ### Method GET ### Endpoint `/context/entitlement` ### Returns - **Entitlement** | null - The entitlement object or null if not available. ``` -------------------------------- ### Initialize TypeScript Configuration Source: https://github.com/tryforge/forgescript/blob/main/EXTENSIONS.md Initializes a tsconfig.json file with specified target and output directories. This configures the TypeScript compiler for your project. ```bash tsc --init --target es2022 --rootdir src --outdir dist ``` -------------------------------- ### cloneEmpty Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Creates a new Context instance that is a clone of the current one but without any associated data or state, effectively creating an empty context. ```APIDOC ## cloneEmpty ### Description Creates an empty clone of the current context. ### Method cloneEmpty ### Returns [Context](Context.html) ``` -------------------------------- ### Get Message Prefix Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Asynchronously retrieves the prefix for a given message. Returns null if no prefix is found. ```typescript getPrefix(msg: Message): Promise ``` -------------------------------- ### partials Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Specifies the partials to be used. Inherited from ClientOptions. ```APIDOC ## partials ### Description Specifies the partials to be used. ### Type `readonly Partials[]` ### Optional Yes ### Inherited Yes, from `ClientOptions` ``` -------------------------------- ### Get Listener Count Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Returns the number of listeners for a specific event on an EventEmitter. Ensure EventEmitter and listenerCount are imported. ```typescript import { EventEmitter, listenerCount } from 'node:events'; const myEmitter = new EventEmitter(); myEmitter.on('event', () => {}); myEmitter.on('event', () => {}); console.log(listenerCount(myEmitter, 'event')); // Prints: 2 ``` -------------------------------- ### ForgeClient Initialization Source: https://github.com/tryforge/forgescript/blob/main/README.md Initializes a ForgeClient with specified intents, events, and prefixes. The 'MessageContent' intent is privileged and requires whitelisting. ```javascript const { ForgeClient } = require("@tryforge/forgescript") const client = new ForgeClient({ intents: [ "GuildMessages", "Guilds", "MessageContent" // This intent is privileged, must be whitelisted in dev portal, in your application. ], events: [ "messageCreate", "clientReady" ], // Events our bot will act on prefixes: [ "!", "?" ] // The prefixes to use for our bot! }) client.login("token") ``` -------------------------------- ### Get Listener Count Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Returns the number of listeners for a specific event. If a listener function is provided, it counts occurrences of that specific listener. ```typescript listenerCount(eventName: string | symbol, listener?: Function): number ``` -------------------------------- ### FileReader Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/FileReader.html Initializes a new instance of the FileReader class. ```APIDOC ## constructor ### Description Initializes a new instance of the FileReader class. ### Method constructor ### Parameters This method does not take any parameters. ``` -------------------------------- ### Get Username by ID Source: https://github.com/tryforge/forgescript/blob/main/src/__tests__/m.md Use the $username command to retrieve a user's username. This is the basic usage without specifying an ID. ```ForgeScript $username ``` -------------------------------- ### compile Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Compiler.html Compiles the provided code string. It can optionally take a path for context. This is a static method available for direct use. ```APIDOC ## compile ### Description Compiles the provided code string. It can optionally take a path for context. ### Method `static` ### Parameters #### Optional Parameters - **code** (string) - The code string to compile. - **path** (null | string) - An optional path for context. ### Returns - **[IExtendedCompilationResult](../interfaces/IExtendedCompilationResult.html)** - The result of the compilation. ``` -------------------------------- ### Get Current Max Listeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Retrieves the current maximum number of listeners for the EventEmitter. This value can be set using setMaxListeners or defaults to defaultMaxListeners. ```typescript getMaxListeners(): number[] ``` -------------------------------- ### Run Doc Generation Command Source: https://github.com/tryforge/forgescript/blob/main/EXTENSIONS.md Executes the 'docgen' script defined in your package.json. This command should be run after compiling your changes. ```bash npm run docgen ``` -------------------------------- ### ForgeClient Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Initializes a new instance of the ForgeClient class. This constructor is used to create a client instance with specified options, enabling connection and interaction with the Forge API. ```APIDOC ## constructor ForgeClient ### Description Initializes a new instance of the ForgeClient class. ### Parameters #### Parameters - **options** (IRawForgeClientOptions) - Description of the options parameter. ### Returns - [ForgeClient] ### Overrides Client.constructor ### Defined in src/core/ForgeClient.ts:137 ``` -------------------------------- ### Get Event Names Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Retrieves an array of event names for which the emitter has registered listeners. This is useful for inspecting the emitter's current event subscriptions. ```typescript import { EventEmitter } from 'node:events'; const myEE = new EventEmitter(); myEE.on('foo', () => {}); myEE.on('bar', () => {}); const sym = Symbol('symbol'); myEE.on(sym, () => {}); console.log(myEE.eventNames()); // Prints: [ 'foo', 'bar', Symbol(symbol) ] ``` -------------------------------- ### resolveSoundboardSound Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/CompiledFunction.html Resolves soundboard sounds based on the provided context, arguments, string, and reference. It can return an array of GuildSoundboardSound or void, potentially asynchronously. ```APIDOC ## resolveSoundboardSound ### Description Resolves soundboard sounds based on the provided context, arguments, string, and reference. It can return an array of GuildSoundboardSound or void, potentially asynchronously. ### Parameters * **ctx**: Context * **arg**: IArg> * **str**: string * **ref**: unknown[] ### Returns undefined | Promise[] ``` -------------------------------- ### Remove the most recently added listener instance Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html When a listener is added multiple times, `removeListener` removes the most recently added instance. This example shows `once('ping')` being removed. ```javascript import { EventEmitter } from 'node:events'; const ee = new EventEmitter(); function pong() { console.log('pong'); } ee.on('ping', pong); ee.once('ping', pong); ee.removeListener('ping', pong); ee.emit('ping'); ee.emit('ping'); ``` -------------------------------- ### getMaxListeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Returns the currently set max amount of listeners. For `EventEmitter`s this behaves the same as calling `.getMaxListeners` on the emitter. For `EventTarget`s this is the only way to get the max event listeners for the event target. ```APIDOC ## Static getMaxListeners ### Description Returns the currently set max amount of listeners. For `EventEmitter`s this behaves the same as calling `.getMaxListeners` on the emitter. For `EventTarget`s this is the only way to get the max event listeners for the event target. ### Method Static ### Parameters #### Parameters - **emitter**: EventEmitter | _DOMEventTarget - The event emitter or event target. ### Returns number - The maximum number of listeners. ``` -------------------------------- ### Interpreter.run (ctx) Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Interpreter.html Executes code within the provided context. ```APIDOC ## `Static` run(ctx) ### Description Executes code within the provided context. ### Method run ### Parameters #### Path Parameters * **ctx** ([Context](Context.html)) - Description not available #### Returns Promise ``` -------------------------------- ### Get All Raw Event Listeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Retrieves a copy of all listeners for a given event, including any wrappers created by methods like `.once()`. This can be used to inspect or manually invoke listeners. ```typescript import { EventEmitter } from 'node:events'; const emitter = new EventEmitter(); emitter.once('log', () => console.log('log once')); // Returns a new Array with a function `onceWrapper` which has a property // `listener` which contains the original listener bound above const listeners = emitter.rawListeners('log'); const logFnWrapper = listeners[0]; // Logs "log once" to the console and does not unbind the `once` event logFnWrapper.listener(); // Logs "log once" to the console and removes the listener logFnWrapper(); emitter.on('log', () => console.log('log persistently')); // Will return a new Array with a single function bound by `.on()` above const newListeners = emitter.rawListeners('log'); // Logs "log persistently" twice newListeners[0](); emitter.emit('log'); ``` -------------------------------- ### ApplicationCommand Properties Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ApplicationCommand.html Details the properties available on an ApplicationCommand instance. ```APIDOC ## Properties ### compiled - **compiled**: IExtendedCompilationResult - Defined in src/structures/base/ApplicationCommand.ts:12 ### options - **options**: IApplicationCommandData - Defined in src/structures/base/ApplicationCommand.ts:14 ``` -------------------------------- ### Get Username with Specific ID Source: https://github.com/tryforge/forgescript/blob/main/src/__tests__/m.md Specify a user ID to retrieve a specific user's username using the $username[id] syntax. The 'id' field must be of type User. ```ForgeScript $username[id] ``` -------------------------------- ### ForgeExtension Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeExtension.html Initializes a new instance of the ForgeExtension class. ```APIDOC ## constructor ### Description Initializes a new instance of the ForgeExtension class. ### Signature ```typescript new ForgeExtension(): ForgeExtension ``` ### Returns - ForgeExtension: A new instance of the ForgeExtension class. ``` -------------------------------- ### Login with Token Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Logs the client into the Discord gateway using an optional token. Overrides the base Client.login method. ```typescript login(token?: string): Promise ``` -------------------------------- ### getEventListeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Returns a copy of the array of listeners for the event named `name`. For `EventEmitter`s this behaves the same as calling `.listeners` on the emitter. For `EventTarget`s this is the only way to get the event listeners for the event target, useful for debugging. ```APIDOC ## Static getEventListeners ### Description Returns a copy of the array of listeners for the event named `name`. For `EventEmitter`s this behaves the same as calling `.listeners` on the emitter. For `EventTarget`s this is the only way to get the event listeners for the event target, useful for debugging. ### Method Static ### Parameters #### Parameters - **emitter**: EventEmitter | _DOMEventTarget - The event emitter or event target. - **name**: string | symbol - The name of the event. ### Returns Function[] - An array of listener functions. ``` -------------------------------- ### Get Event Listeners for EventEmitter and EventTarget Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Retrieve an array of listeners for a specific event name using getEventListeners. This function works identically to .listeners for EventEmitter and is the primary method for inspecting listeners on EventTarget objects. ```javascript import { getEventListeners, EventEmitter } from 'node:events'; { const ee = new EventEmitter(); const listener = () => console.log('Events are fun'); ee.on('foo', listener); console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ] } { const et = new EventTarget(); const listener = () => console.log('Events are fun'); et.addEventListener('foo', listener); console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ] } ``` -------------------------------- ### ForgeFunction.populate Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunction.html Populates the ForgeFunction, likely preparing it for execution. ```APIDOC ## populate() ### Description Populates the ForgeFunction, likely preparing it for execution. ### Returns * void ### Defined in src/structures/forge/ForgeFunction.ts:37 ``` -------------------------------- ### Listener removal during emit cycle Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Demonstrates that removing a listener within an emit cycle does not affect the current cycle but will prevent future calls. This example shows `callbackB` being removed by `callbackA` but still executing in the current `emit`. ```javascript import { EventEmitter } from 'node:events'; class MyEmitter extends EventEmitter {} const myEmitter = new MyEmitter(); const callbackA = () => { console.log('A'); myEmitter.removeListener('event', callbackB); }; const callbackB = () => { console.log('B'); }; myEmitter.on('event', callbackA); myEmitter.on('event', callbackB); // callbackA removes listener callbackB but it will still be called. // Internal listener array at time of emit [callbackA, callbackB] myEmitter.emit('event'); // Prints: // A // B // callbackB is now removed. // Internal listener array [callbackA] myEmitter.emit('event'); // Prints: // A ``` -------------------------------- ### clone Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Context.html Clones keywords, environment variables, and local functions from the current context. It allows for optional configuration of runnable properties and synchronization of variables. ```APIDOC ## clone ### Description Clones keywords, environment vars, and local functions. ### Method clone ### Parameters #### Path Parameters * `props` (Partial) - Optional - Configuration for runnable properties. * `syncVars` (boolean) - Optional - Defaults to false. Whether to synchronize variables during cloning. ### Returns [Context](Context.html) ``` -------------------------------- ### ApplicationCommandManager.getDisplay Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ApplicationCommandManager.html Generates a display string for an interaction, optionally hiding the command name. ```APIDOC ## getDisplay(input: null | Interaction, hideName: boolean): null | string ### Description Generates a display string for an interaction, optionally hiding the command name. ### Parameters #### Parameters - **input** (null | Interaction) - The interaction to generate the display string for. - **hideName** (boolean) - Whether to hide the command name in the display string. ### Returns - null | string ``` -------------------------------- ### Manage Max Event Listeners with getMaxListeners Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Get the current maximum number of listeners allowed per event with getMaxListeners. This function mirrors the .getMaxListeners method for EventEmitter and is essential for monitoring listener counts on EventTarget objects to avoid potential warnings. ```javascript import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events'; { const ee = new EventEmitter(); console.log(getMaxListeners(ee)); // 10 setMaxListeners(11, ee); console.log(getMaxListeners(ee)); // 11 } { const et = new EventTarget(); console.log(getMaxListeners(et)); // 10 setMaxListeners(11, et); console.log(getMaxListeners(et)); // 11 } ``` -------------------------------- ### rest Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Partial REST options for the client. Inherited from ClientOptions. ```APIDOC ## rest ### Description Partial REST options for the client. ### Type `Partial` ### Optional Yes ### Inherited Yes, from `ClientOptions` ``` -------------------------------- ### stage Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IStates.html Represents a stage instance. ```APIDOC ## stage ### Description Represents a stage instance. ### Type StageInstance ### Source src/core/Interpreter.ts:53 ``` -------------------------------- ### fetchGuildPreview Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeClient.html Fetches a guild preview by its ID. This method is inherited from the Client class. ```APIDOC ## fetchGuildPreview(guild) ### Description Fetches a guild preview by its ID. This method is inherited from the Client class. ### Method N/A (Method signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (Promise) - **guild** (GuildResolvable) - The guild to fetch a preview for. #### Response Example ```json { "example": "GuildPreview object" } ``` ``` -------------------------------- ### FileReader Constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/FileReader.html Initializes a new instance of the FileReader class. It takes the code string and a request object as parameters. ```APIDOC ## new FileReader(code, req) ### Description Initializes a new instance of the FileReader class. ### Parameters #### Parameters - **code** (string) - The code content to be read. - **req** (any) - The request object associated with the file reading operation. ### Returns - [FileReader](FileReader.html) - A new instance of the FileReader class. ``` -------------------------------- ### IRawForgeClientOptions Configuration Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html The IRawForgeClientOptions interface defines a comprehensive set of options for configuring the Forge client. These options control various aspects of the client's behavior, including bot permissions, message handling, command processing, event subscriptions, and more. ```APIDOC ## IRawForgeClientOptions ### Description Interface for raw Forge client options. This interface outlines all possible configuration properties that can be passed to the Forge client constructor. ### Properties - **allowBots** (boolean) - Optional - Whether to allow bots to be invited. - **allowedMentions** (object) - Optional - Configuration for allowed mentions. - **closeTimeout** (number) - Optional - Timeout in milliseconds before closing the WebSocket connection. - **commands** (object) - Optional - Configuration for command handling. - **disableConsoleErrors** (boolean) - Optional - Whether to disable console error logging. - **enforceNonce** (boolean) - Optional - Whether to enforce nonces for requests. - **events** (object) - Optional - Configuration for event handling. - **extensions** (object) - Optional - Configuration for extensions. - **failIfNotExists** (boolean) - Optional - Whether to throw an error if a command or event does not exist. - **functions** (object) - Optional - Configuration for custom functions. - **intents** (number) - Optional - Bitwise integer representing the Gateway intents to subscribe to. - **jsonTransformer** (function) - Optional - A function to transform JSON payloads. - **logLevel** (string) - Optional - The minimum log level to display. - **makeCache** (object) - Optional - Configuration for cache management. - **mobile** (boolean) - Optional - Whether to enable mobile client emulation. - **optionalGuildID** (string) - Optional - A guild ID to use for certain operations when not provided. - **partials** (array) - Optional - An array of partial types to enable. - **prefixCaseInsensitive** (boolean) - Optional - Whether prefix matching should be case-insensitive. - **prefixes** (string|string[]) - Optional - An array of prefixes for commands. - **presence** (object) - Optional - Configuration for the client's presence. - **respondOnEdit** (boolean) - Optional - Whether to respond to message edits. - **rest** (object) - Optional - Configuration for the REST API client. - **restrictions** (object) - Optional - Configuration for command restrictions. - **shardCount** (number) - Optional - The total number of shards to use. - **shards** (number|number[]) - Optional - The shard ID(s) to use. - **sweepers** (object) - Optional - Configuration for sweepers. - **token** (string) - Required - The authentication token for the client. - **trackers** (object) - Optional - Configuration for trackers. - **useInviteSystem** (boolean) - Optional - Whether to use the invite system. - **waitGuildTimeout** (number) - Optional - Timeout in milliseconds for waiting for guild data. - **ws** (object) - Optional - Configuration for the WebSocket connection. ``` -------------------------------- ### optionalSoundboardSound Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/Arg.html Defines an optional soundboard sound argument. It allows specifying a name and description for the sound. ```APIDOC ## optionalSoundboardSound ### Description Defines an optional soundboard sound argument for command parsing, allowing custom names and descriptions. ### Method Static method of the Arg class. ### Parameters * **name** (string) - Optional - Defaults to "sound ID". The name of the soundboard sound argument. * **desc** (string) - Optional - Defaults to "The soundboard sound to use". The description for the argument. ### Returns An IArg object configured for SoundboardSound type. ``` -------------------------------- ### FunctionManager.load(provider, path) Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/FunctionManager.html Loads functions from a specified path using a given provider. This is a static method that can be called with provider and path arguments. ```APIDOC ## Static load(provider, path) ### Description Loads functions from a specified path using a given provider. ### Method static ### Parameters #### Path Parameters - **provider** (string) - Description of the provider parameter - **path** (string) - Description of the path parameter ### Returns void ### Defined in src/managers/FunctionManager.ts:24 ``` -------------------------------- ### presence Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Configuration for the client's presence. Inherited from ClientOptions. ```APIDOC ## presence ### Description Configuration for the client's presence. ### Type `PresenceData` ### Optional Yes ### Inherited Yes, from `ClientOptions` ``` -------------------------------- ### Load Commands from Folder Source: https://github.com/tryforge/forgescript/blob/main/README.md Loads all command files from a specified directory into the ForgeClient. Replace '' with the actual directory name. ```javascript client.commands.load("./") ``` -------------------------------- ### constructor Source: https://github.com/tryforge/forgescript/blob/main/docs/classes/ForgeFunctionManager.html Initializes a new instance of the ForgeFunctionManager class. ```APIDOC ## constructor ### Description Initializes a new instance of the ForgeFunctionManager class. ### Method constructor ### Parameters This method does not take any parameters. ``` -------------------------------- ### respondOnEdit Source: https://github.com/tryforge/forgescript/blob/main/docs/interfaces/IRawForgeClientOptions.html Allows the bot to re-use edited messages for command calls within a specified time. ```APIDOC ## respondOnEdit ### Description Allows the bot to re-use messages that were edited to find possibly command calls. If a number is passed, it's treated as the amount of milliseconds that can pass before the message becomes completely unusable. ### Type `number | boolean` ### Optional Yes ```