Class: Discordrb::Integration

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/discordrb/data.rb

Overview

Server integration

Instance Attribute Summary collapse

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from IDObject

#==, #creation_time, synthesise

Constructor Details

#initialize(data, bot, server) ⇒ Integration

Returns a new instance of Integration.


2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
# File 'lib/discordrb/data.rb', line 2547

def initialize(data, bot, server)
  @bot = bot

  @name = data['name']
  @server = server
  @id = data['id'].to_i
  @enabled = data['enabled']
  @syncing = data['syncing']
  @type = data['type']
  @account = IntegrationAccount.new(data['account'])
  @synced_at = Time.parse(data['synced_at'])
  @expire_behaviour = %i[remove kick][data['expire_behavior']]
  @expire_grace_period = data['expire_grace_period']
  @user = @bot.ensure_user(data['user'])
  @role = server.role(data['role_id']) || nil
  @emoticon = data['enable_emoticons']
end

Instance Attribute Details

#accountIntegrationAccount (readonly)

Returns the integration account information.

Returns:


2535
2536
2537
# File 'lib/discordrb/data.rb', line 2535

def 
  @account
end

#emoticontrue, false (readonly) Also known as: emoticon?

Returns whether emoticons are enabled.

Returns:

  • (true, false)

    whether emoticons are enabled


2522
2523
2524
# File 'lib/discordrb/data.rb', line 2522

def emoticon
  @emoticon
end

#enabledtrue, false (readonly)

Returns whether the integration is enabled.

Returns:

  • (true, false)

    whether the integration is enabled


2529
2530
2531
# File 'lib/discordrb/data.rb', line 2529

def enabled
  @enabled
end

#expire_behaviourSymbol (readonly) Also known as: expire_behavior

Returns the behaviour of expiring subscribers (:remove = Remove User from role; :kick = Kick User from server).

Returns:

  • (Symbol)

    the behaviour of expiring subscribers (:remove = Remove User from role; :kick = Kick User from server)


2541
2542
2543
# File 'lib/discordrb/data.rb', line 2541

def expire_behaviour
  @expire_behaviour
end

#expire_grace_periodInteger (readonly)

Returns the grace period before subscribers expire (in days).

Returns:

  • (Integer)

    the grace period before subscribers expire (in days)


2545
2546
2547
# File 'lib/discordrb/data.rb', line 2545

def expire_grace_period
  @expire_grace_period
end

#nameString (readonly)

Returns the integration name.

Returns:

  • (String)

    the integration name


2510
2511
2512
# File 'lib/discordrb/data.rb', line 2510

def name
  @name
end

#roleRole? (readonly)

Returns the role that this integration uses for "subscribers".

Returns:

  • (Role, nil)

    the role that this integration uses for "subscribers"


2519
2520
2521
# File 'lib/discordrb/data.rb', line 2519

def role
  @role
end

#serverServer (readonly)

Returns the server the integration is linked to.

Returns:

  • (Server)

    the server the integration is linked to


2513
2514
2515
# File 'lib/discordrb/data.rb', line 2513

def server
  @server
end

#synced_atTime (readonly)

Returns the time the integration was synced at.

Returns:

  • (Time)

    the time the integration was synced at


2538
2539
2540
# File 'lib/discordrb/data.rb', line 2538

def synced_at
  @synced_at
end

#syncingtrue, false (readonly)

Returns whether the integration is syncing.

Returns:

  • (true, false)

    whether the integration is syncing


2532
2533
2534
# File 'lib/discordrb/data.rb', line 2532

def syncing
  @syncing
end

#typeString (readonly)

Returns the integration type (Youtube, Twitch, etc.).

Returns:

  • (String)

    the integration type (Youtube, Twitch, etc.)


2526
2527
2528
# File 'lib/discordrb/data.rb', line 2526

def type
  @type
end

#userUser (readonly)

Returns the user the integration is linked to.

Returns:

  • (User)

    the user the integration is linked to


2516
2517
2518
# File 'lib/discordrb/data.rb', line 2516

def user
  @user
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output


2566
2567
2568
# File 'lib/discordrb/data.rb', line 2566

def inspect
  "<Integration name=#{@name} id=#{@id} type=#{@type} enabled=#{@enabled}>"
end