Class: Discorb::Application::Team::Member

Inherits:
DiscordModel show all
Defined in:
lib/discorb/application.rb

Overview

Represents a member of team.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiscordModel

#eql?

Constructor Details

#initialize(client, team, data) -> Member

Returns a new instance of Member.



165
166
167
168
169
170
171
172
173
# File 'lib/discorb/application.rb', line 165

def initialize(client, team, data)
  @client = client
  @data = data
  @team = team
  @user = client.users[data[:user][:id]] || User.new(client, data[:user])
  @team_id = Snowflake.new(data[:team_id])
  @membership_state = MEMBERSHIP_STATE[data[:membership_state]]
  @permissions = data[:permissions].map(&:to_sym)
end

Instance Attribute Details

#accepted? -> Boolean (readonly)

Returns Whether the member accepted joining the team.

Returns:

  • (Boolean)

    Whether the member accepted joining the team.



# File 'lib/discorb/application.rb', line 151

#membership_state -> :invited, :accepted (readonly) Also known as: state

Returns The member's membership state.

Returns:

  • (:invited, :accepted)

    The member's membership state.



145
146
147
# File 'lib/discorb/application.rb', line 145

def membership_state
  @membership_state
end

#owner? -> Boolean (readonly)

Returns Whether the member is the team's owner.

Returns:

  • (Boolean)

    Whether the member is the team's owner.



# File 'lib/discorb/application.rb', line 151

#pending? -> Boolean (readonly)

Returns Whether the member is not joined to the team.

Returns:

  • (Boolean)

    Whether the member is not joined to the team.



# File 'lib/discorb/application.rb', line 151

#permissions -> Array<Symbol> (readonly)

Note:

This always return :*.

Returns The permissions of the member.

Returns:

  • (Array<Symbol>)

    The permissions of the member.



149
150
151
# File 'lib/discorb/application.rb', line 149

def permissions
  @permissions
end

#team_id -> Snowflake (readonly)

Returns The ID of member's team.

Returns:



143
144
145
# File 'lib/discorb/application.rb', line 143

def team_id
  @team_id
end

#user -> Discorb::User (readonly)

Returns The user.

Returns:



141
142
143
# File 'lib/discorb/application.rb', line 141

def user
  @user
end

Instance Method Details

#==(other) -> Object



191
192
193
# File 'lib/discorb/application.rb', line 191

def ==(other)
  super || @user == other
end

#inspect -> Object



183
184
185
# File 'lib/discorb/application.rb', line 183

def inspect
  "#<#{self.class} id=#{@user.id}>"
end