Class: Rubycord::Integration

Inherits:
Object
  • Object
show all
Includes:
IDObject
Defined in:
lib/rubycord/data/integration.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.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/rubycord/data/integration.rb', line 94

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_id = data["role_id"]&.to_i
  @emoticon = data["enable_emoticons"]
  @subscriber_count = data["subscriber_count"]&.to_i
  @revoked = data["revoked"]
  @application = IntegrationApplication.new(data["application"], bot) if data["application"]
end

Instance Attribute Details

#accountIntegrationAccount (readonly)

Returns the integration account information.

Returns:



76
77
78
# File 'lib/rubycord/data/integration.rb', line 76

def 
  @account
end

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

Returns whether emoticons are enabled.

Returns:

  • (true, false)

    whether emoticons are enabled



63
64
65
# File 'lib/rubycord/data/integration.rb', line 63

def emoticon
  @emoticon
end

#enabledtrue, false (readonly)

Returns whether the integration is enabled.

Returns:

  • (true, false)

    whether the integration is enabled



70
71
72
# File 'lib/rubycord/data/integration.rb', line 70

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)



82
83
84
# File 'lib/rubycord/data/integration.rb', line 82

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)



86
87
88
# File 'lib/rubycord/data/integration.rb', line 86

def expire_grace_period
  @expire_grace_period
end

#nameString (readonly)

Returns the integration name.

Returns:

  • (String)

    the integration name



51
52
53
# File 'lib/rubycord/data/integration.rb', line 51

def name
  @name
end

#revokedtrue, false (readonly)

Returns has this integration been revoked.

Returns:

  • (true, false)

    has this integration been revoked.



92
93
94
# File 'lib/rubycord/data/integration.rb', line 92

def revoked
  @revoked
end

#role_idInteger? (readonly)

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

Returns:

  • (Integer, nil)

    the role that this integration uses for "subscribers"



60
61
62
# File 'lib/rubycord/data/integration.rb', line 60

def role_id
  @role_id
end

#serverServer (readonly)

Returns the server the integration is linked to.

Returns:

  • (Server)

    the server the integration is linked to



54
55
56
# File 'lib/rubycord/data/integration.rb', line 54

def server
  @server
end

#subscriber_countInteger? (readonly)

Returns how many subscribers this integration has.

Returns:

  • (Integer, nil)

    how many subscribers this integration has.



89
90
91
# File 'lib/rubycord/data/integration.rb', line 89

def subscriber_count
  @subscriber_count
end

#synced_atTime (readonly)

Returns the time the integration was synced at.

Returns:

  • (Time)

    the time the integration was synced at



79
80
81
# File 'lib/rubycord/data/integration.rb', line 79

def synced_at
  @synced_at
end

#syncingtrue, false (readonly)

Returns whether the integration is syncing.

Returns:

  • (true, false)

    whether the integration is syncing



73
74
75
# File 'lib/rubycord/data/integration.rb', line 73

def syncing
  @syncing
end

#typeString (readonly)

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

Returns:

  • (String)

    the integration type (YouTube, Twitch, etc.)



67
68
69
# File 'lib/rubycord/data/integration.rb', line 67

def type
  @type
end

#userUser (readonly)

Returns the user the integration is linked to.

Returns:

  • (User)

    the user the integration is linked to



57
58
59
# File 'lib/rubycord/data/integration.rb', line 57

def user
  @user
end

Instance Method Details

#inspectObject

The inspect method is overwritten to give more useful output



116
117
118
# File 'lib/rubycord/data/integration.rb', line 116

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