Class: Rubord::Mention
- Inherits:
-
Object
- Object
- Rubord::Mention
- Defined in:
- lib/rubord/models/mention.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#everyone ⇒ Object
readonly
Returns the value of attribute everyone.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(data, client, guild) ⇒ Mention
constructor
A new instance of Mention.
- #inspect ⇒ Object
- #mention_everyone? ⇒ Boolean
Constructor Details
#initialize(data, client, guild) ⇒ Mention
Returns a new instance of Mention.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubord/models/mention.rb', line 8 def initialize(data, client, guild) @everyone = data["mention_everyone"] || false @users = (data["mentions"] || []).map do |user_data| user = Rubord::User.new(user_data) client.users.set(user.id, user) user end @roles = (data["mention_roles"] || []).map do |role_id| guild&.roles&.get(role_id) end @channels = if data["mention_channels"] data["mention_channels"].map do |channel_data| channel = Rubord::Channel.new(channel_data, client) client.channels.set(channel.id, channel) channel end else Rubord.Parser.channel_mentions(data["content"] || "").map do |channel_id| client.channels.get(channel_id) || Rubord::Channel.new({ "id" => channel_id }, client) end end end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
3 4 5 |
# File 'lib/rubord/models/mention.rb', line 3 def channels @channels end |
#everyone ⇒ Object (readonly)
Returns the value of attribute everyone.
3 4 5 |
# File 'lib/rubord/models/mention.rb', line 3 def everyone @everyone end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
3 4 5 |
# File 'lib/rubord/models/mention.rb', line 3 def roles @roles end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
3 4 5 |
# File 'lib/rubord/models/mention.rb', line 3 def users @users end |
Instance Method Details
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/rubord/models/mention.rb', line 39 def empty? users.empty? && roles.empty? && channels.empty? && !everyone end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/rubord/models/mention.rb', line 43 def inspect "#<Rubord::Mention users=#{users.size} roles=#{roles.size} channels=#{channels.size} everyone=#{everyone}>" end |
#mention_everyone? ⇒ Boolean
35 36 37 |
# File 'lib/rubord/models/mention.rb', line 35 def mention_everyone? @everyone end |