Class: Discordrb::RoleSubscriptionData

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

Overview

Metadata about a purchase or renewal for a role subscription.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#listing_idInteger (readonly)

Returns the ID of the SKU and listing the user is subscribed to.

Returns:

  • (Integer)

    the ID of the SKU and listing the user is subscribed to.



10
11
12
# File 'lib/discordrb/data/role_subscription.rb', line 10

def listing_id
  @listing_id
end

#renewaltrue, false (readonly) Also known as: renewal?

Returns whether the subscription notification is for a renewal.

Returns:

  • (true, false)

    whether the subscription notification is for a renewal.



13
14
15
# File 'lib/discordrb/data/role_subscription.rb', line 13

def renewal
  @renewal
end

#tier_nameString (readonly)

Returns the name of the tier the user is subscribed to.

Returns:

  • (String)

    the name of the tier the user is subscribed to.



7
8
9
# File 'lib/discordrb/data/role_subscription.rb', line 7

def tier_name
  @tier_name
end

#total_months_subscribedInteger (readonly)

Returns the total number of months the user has been subscribed for.

Returns:

  • (Integer)

    the total number of months the user has been subscribed for.



17
18
19
# File 'lib/discordrb/data/role_subscription.rb', line 17

def total_months_subscribed
  @total_months_subscribed
end

Instance Method Details

#new?true, false

Check if this role subscription is a new purchase.

Returns:

  • (true, false)

    if this role subscription is a new purchase.



31
32
33
# File 'lib/discordrb/data/role_subscription.rb', line 31

def new?
  @renewal == false
end

#roleRole?

Get the role associated with the notification for this subscription.

Returns:

  • (Role, nil)

    the role that's associated with this subscription.



37
38
39
# File 'lib/discordrb/data/role_subscription.rb', line 37

def role
  @message.server.roles.find { |role| role.tags&.subscription_listing_id == @listing_id }
end