class Discorb::Integration

Represents a integration.

Attributes

expire_behavior[R]

@!visibility private

account[R]

@return [Discorb::Integration::Account] The account for the integration.

application[R]

@return [Discorb::Application] The application for the integration.

enable_emoticons[R]

@return [Boolean] Whether the integration is enabled emoticons.

enable_emoticons?[R]

@return [Boolean] Whether the integration is enabled emoticons.

enabled[R]

@return [Boolean] Whether the integration is enabled.

enabled?[R]

@return [Boolean] Whether the integration is enabled.

expire_behavior[R]

@return [:remove_role, :kick] The behavior of the integration when it expires.

expire_grace_period[R]

@return [Integer] The grace period of the integration.

id[R]

@return [Discorb::Snowflake] The ID of the integration.

revoked[R]

@return [Boolean] Whether the integration is revoked.

revoked?[R]

@return [Boolean] Whether the integration is revoked.

subscriber_count[R]

@return [Integer] The number of subscribers for the integration.

syncing[R]

@return [Boolean] Whether the integration is syncing.

syncing?[R]

@return [Boolean] Whether the integration is syncing.

type[R]

@return [Symbol] The type of integration.

user[R]

@return [Discorb::User] The user for the integration.

Public Class Methods

new(client, data, guild_id, no_cache: false) click to toggle source

@!visibility private

# File lib/discorb/integration.rb, line 47
def initialize(client, data, guild_id, no_cache: false)
  @client = client
  @data = data
  @guild_id = guild_id
  _set_data(data)
  guild.integrations[@id] = self unless no_cache
end

Public Instance Methods

delete!(reason: nil) click to toggle source

Delete the integration.

@param [String] reason The reason for deleting the integration.

# File lib/discorb/integration.rb, line 64
def delete!(reason: nil)
  Async do
    @client.http.delete("/guilds/#{@guild}/integrations/#{@id}", reason: reason).wait
  end
end
Also aliased as: destroy!
destroy!(reason: nil)
Alias for: delete!
guild() click to toggle source
# File lib/discorb/integration.rb, line 55
def guild
  @client.guilds[@guild_id]
end

Private Instance Methods

_set_data(data) click to toggle source
# File lib/discorb/integration.rb, line 74
def _set_data(data)
  @id = Snowflake.new(data[:id])
  @type = data[:type].to_sym
  @enabled = data[:enabled]
  @syncing = data[:syncing]
  @role_id = Snowflake.new(data[:role_id])
  @enable_emoticons = data[:enable_emoticons]
  @expire_behavior = self.class.expire_behavior[data[:expire_behavior]]
  @expire_grace_period = data[:expire_grace_period]
  @user = client.users[data[:user].to_i]
  @account = Account.new(data[:account])
  @subscriber_count = data[:subscriber_count]
  @revoked = data[:revoked]
  @application = Application.new(@client, data[:application])
end