Skip to content

Interfaces and Types

Lehlogonolo Poole edited this page Aug 18, 2024 · 4 revisions

RunFlags

An interface representing the configuration flags used for running commands in the bot.

This configuration is specifically used to control various runtime aspects of command execution.

Properties

testGuildId: string

Default value: undefined

The ID of the test guild for command testing purposes. If provided, commands will be deployed only to this guild.

devs: string[]

Default value: []

An array of Discord user IDs (snowflakes) that have developer privileges.

Commands or functionalities restricted to developers will be accessible to users with IDs in this array.

onlyDev: string

Default value: "Only developers are allowed to run this command."

The message shown when a command restricted to developers is executed by a non-developer.

userNoPerms: string

Default value: "Not enough permissions."

The message displayed when a user lacks the necessary permissions to execute a command.

botNoPerms: string

Default value: "I don't have enough permissions."

The message displayed when the bot lacks the necessary permissions to execute a command.

Exmaple Use

const obj: RunFlags = {
    testGuildId: "808701451399725116",
    devs: ["671549251024584725"],

    onlyDev: "Text to display when a user runs a developer command.",
    userNoPerms: "Text to display when the user has insufficient permissions",
    botNoPerms: "Text to display when the bot has insufficient permissions",
};

HandlerFlags

An interface that represents anything you can do with the commands when they are run, BUT before YOUR code executes.

Properties

debugger: boolean

Default value: false

Enable debugger mode. Prints(almost) everything that happens behind the scenes of course not with the API itself.

disableLogs: boolean

Default value: false

Disabling Logging of the Command Loader. Not advisable but hey it's your bot.

production: boolean

Default value: false

Whether or not this is the production version of the bot. If set to true, commands labelled isDev will NOT be loaded. (Use the setDev() method in SlashCommandManager)

refreshApplicationCommands?: boolean

Default value: false

Clears ALL application commands on startup. (Slash commands, User commands, and Message commands.)

logToFile: string | false

Default value: false

When debugger mode is enabled, Either log to console or a file.

Example Use

const obj: LoaderOptions = {
    debugger: true,
    production: true,
    disableLogs: true,
};

InteractionHandlerFlags

An interface that represents anything you can do with the interactions when they are run, BUT before YOUR code executes.

Properties

debugger: boolean

Default value: false

Enable Debugger mode. Prints (almost) everything that happens behind the scenes of course not with the API itself.

disableLogs: boolean

Default value: false

Disabling Logging of the Context Menu Loader. Not advised but hey it's your bot. Default is false.

refreshContextMenus: boolean

Default value: false

Clears Context Menus

logToFile: string | false

Default value: false

When debugger mode is enabled, Either log to console or a file.

LoaderOptions

Interface that represents default string values for the loader to log to the console when it encounters a command/context menu.

Make sure you keep NAME in the string or else you will not know what happened to which command. If there is no log in the console for a specific command, then it has been loaded, there are no edits and it has not been deleted.

Properties

Note:

These have multiple default values, as context menus and commands are different.

loaded: string

What to show for context menus/commands that load in

edited: string

What to show for context menus/commands that gets edited.

deleted: string

What to show for context menus/commands that gets deleted.

skipped: string

What to show for context menus/commands that gets skipped. (Deleted and still marked as deleted.)

loadedNoChanges: string

What to show for context menus/commands that gets loaded, but has no changes

Example Use

const obj: LoaderOptions = {
    loadedNoChanges: "NAME was loaded. No changes were made to NAME.",
    loaded: "NAME has been registered successfully.",
    edited: "NAME has been edited.",
    deleted: "NAME has been deleted.",
    skipped: "NAME was skipped. (Command deleted or set to delete.)",
};

InteractionTypeStrings

Type alias for the strings "selectMenu", "modal" and "button"

Yes this did not need documenting, but here it is.

InteractionTypeStringsMap

Here's the exact definition because I genuinely don't know how to explain this.

export type InteractionTypeStringsMap<U extends string> = U extends "modal"
    ? ModalSubmitInteraction
    : U extends "selectMenu"
    ? AnySelectMenuInteraction
    : U extends "button"
    ? ButtonInteraction
    : never;