aoi.js Documentation

website·Indexed 31 days ago

https://aoi.js.org/

Documentation for aoi.js, a framework for creating Discord bots. Includes a comprehensive library of functions such as $setVar, $setUserVar, and $timeoutMember, as well as guides on interaction commands, slash commands, client intents, and variable management.

Tokens
163K
Snippets
1.3K
Records
1.8K
Agent score
61%

What's inside aoi.js

  1. Retrieve reaction properties using $getReactions

    The $getReactions function returns properties about a specific reaction on a specific message. To use this function, the bot must have the GuildMessageReactions intent enabled. It can return the users who reacted based on the specified option (username, mention, or ID).
    $getReactions[channelID;messageID;reaction;force?;option?]
  2. Reference Direct Message Client Intents

    Use these intents to access data and events related to direct messages (DMs) sent to the bot:

    • DirectMessages: Access data about direct messages.
    • DirectMessageReactions: Access data about reactions in direct messages.
    • DirectMessageTyping: Access typing indicators in direct messages.
  3. Retrieve error details using $handleError

    $handleError is used to return specific information about an error that has occurred. To use this function, you must include events: ["onFunctionError"] in your main file configuration. The function accepts a required string option to determine which piece of error data to return: function for the function name, command for the command name, or error for the specific error message.
    // Example usage within a functionErrorCommand
    client.functionErrorCommand({
        channel: "channelID (optional)",
        code: `Something went wrong in your "$handleError[command]" command! The function "$handleError[function]" returned the error "$handleError[error]"!`
    });
  4. Retrieve timeout information using $getTimeout

    The $getTimeout function returns information about a specific timeout based on its ID. You can optionally specify a key to retrieve a specific property of the timeout: key (default), duration, or id.
    $getTimeout[timeoutId;key?]
  5. Understand aoi.js command execution order

    aoi.js processes code from bottom to top. This means the last line of the code string is executed first, and the first line is executed last.
    client.command({
        name: "example",
        code: `
      $sendMessage[Bye!]
      $sendMessage[Hello!]
      `
    });
    // Result: Sends 'Hello!' first, then 'Bye!'
  6. Retrieve error information using $error

    The $error function returns detailed information about an error. It is specifically designed to be used within onFunctionError commands to handle or log errors that occur during function execution.
    $error
  7. Retrieve inviter information using $inviterInfo

    The $inviterInfo function retrieves information about the user who invited a specific member. It can be called without arguments for default behavior or with specific parameters to target a user and guild, and specify which data fields to return.
    $inviterInfo[userId;guildId;options]
  8. Retrieve guild template data using $getGuildTemplate

    The $getGuildTemplate function returns specific data about a given guild template based on the provided template ID and the desired property name.
    client.command({
        name: "getGuildTemplate",
        code: `$getGuildTemplate[guild-template-code;name]`
    });
  9. Retrieve leaderboard information using $getLeaderboardInfo

    $getLeaderboardInfo retrieves specific information about a variable sorted in a leaderboard for a given entity (user, guild, channel, or message). It allows you to fetch the rank (top), the actual value, the user tag, or the username of the entity at a specific position or for a specific ID.
    $getLeaderboardInfo[variable;id;type;option;table?]
  10. Retrieve slash command metadata using $newApplicationCmd

    The $newApplicationCmd[option] function is used within application callbacks (specifically when a slash command is created or updated) to retrieve specific data fields about the command. It requires a single string parameter specifying the option to retrieve.
    // Example usage within a command update callback
    client.applicationCmdUpdateCommand({
        channel: "channelid",
        code: `Slash command was updated!
    - Name: $newApplicationCmd[name]
    - ID: $newApplicationCmd[id]
    - Application ID: $newApplicationCmd[applicationID]`
    });
  11. Reference Guild-related Client Intents

    Use these intents to access data and events related to the guilds (servers) the bot is a member of:

    • Guilds: Access general data about guilds.
    • GuildMembers: Access member data (Privileged).
    • GuildPresences: Access online status and activities of members (Privileged).
    • GuildMessages: Access messages sent in guilds.
    • GuildVoiceStates: Access voice state information (Privileged).
    • GuildIntegrations: Access third-party integration data.
    • GuildWebhooks: Access webhook data.
    • GuildInvites: Access invite data.
    • GuildVoiceDiscovery: Access Voice Discovery data.
    • GuildEmojisAndStickers: Access emoji and sticker data.
    • GuildMessageReactions: Access message reaction data.
    • GuildChannelMessages: Access messages sent in guild channels (requires additional configuration).
    • GuildTyping: Access typing indicators in guild channels.
    • GuildScheduledEvents: Access scheduled event data.
  12. Retrieve specific properties from $oldEmoji

    Use the following options with $oldEmoji to retrieve specific metadata about the emoji before it was changed or removed:

    • string: Returns the text required to form the emoji.
    • guild: Returns the ID of the guild where the emoji is located (number).
    • url: Returns the URL of the emoji (only applicable if it is a custom emoji).
    // Example: Get the old emoji URL
    $oldEmoji[url]
    
    // Example: Get the old emoji string
    $oldEmoji[string]