discorb-lib/discorb

View on GitHub
sig/discorb/interaction/base.rbs

Summary

Maintainability
Test Coverage
module Discorb
  #
  # Represents an interaction of Discord.
  class Interaction < Discorb::DiscordModel
    @client: Discorb::Client

    #
    # Initialize a new interaction.
    # @private
    #
    # @param [Discorb::Client] client The client this interaction belongs to.
    # @param [Hash] data The data of the interaction.
    def initialize: (Discorb::Client client, Discorb::json data) -> void

    %a{pure}
    def guild: -> Discorb::Guild?

    %a{pure}
    def channel: -> Discorb::Channel

    %a{pure}
    def inspect: -> String

    #
    # Edit the original response message.
    # @async
    # @macro edit
    #
    # @param [String] content The new content of the message.
    # @param [Discorb::Embed] embed The new embed of the message.
    # @param [Array<Discorb::Embed>] embeds The new embeds of the message.
    # @param [Array<Discorb::Attachment>] attachments The attachments to remain.
    # @param [Discorb::Attachment] file The file to send.
    # @param [Array<Discorb::Attachment>] files The files to send.
    #
    # @return [Async::Task<void>] The task.
    def edit_original_message: (
      ?String? content,
      ?embed: Discorb::Embed?,
      ?embeds: ::Array[Discorb::Embed]?,
      ?attachment: Discorb::Attachment?,
      ?attachments: ::Array[Discorb::Attachment]?,
      ?components: (::Array[Discorb::Component]
      | ::Array[::Array[Discorb::Component]])?
    ) -> Async::Task[void]

    #
    # Delete the original response message.
    # @async
    #
    # @return [Async::Task<void>] The task.
    def delete_original_message: -> Async::Task[void]

    #
    # Create a new Interaction instance from the data.
    # @private
    #
    # @param [Discorb::Client] client The client this interaction belongs to.
    # @param [Hash] data The data of the interaction.
    def self.make_interaction: (
      Discorb::Client client,
      Discorb::json data
    ) -> untyped

    #
    # Returns the descendants of the class.
    # @private
    def self.descendants: -> Array[Class]

    def _set_data: (untyped) -> untyped

    # @return [Discorb::Snowflake] The ID of the interaction.
    attr_reader id: Discorb::Snowflake

    # @return [Discorb::Snowflake] The ID of the application that created the interaction.
    attr_reader application_id: Discorb::Snowflake

    # @return [Symbol] The type of interaction.
    attr_reader type: Symbol

    # @return [Discorb::User, Discorb::Member] The user or member that created the interaction.
    attr_reader user: Discorb::User | Discorb::Member

    # @return [Integer] The type of interaction.
    # @note This is always `1` for now.
    attr_reader version: Integer

    # @return [String] The token for the interaction.
    attr_reader token: String

    # @return [Symbol] The locale of the user that created the interaction.
    # @note This modifies the language code, `-` will be replaced with `_`.
    attr_reader locale: Symbol

    # @return [Symbol] The locale of the guild that created the interaction.
    # @note This modifies the language code, `-` will be replaced with `_`.
    attr_reader guild_locale: Symbol

    # @return [Discorb::Permission] The permissions of the bot.
    attr_reader app_permissions: Discorb::Permission
  end
end