Class: Discordrb::Message
- Inherits:
-
Object
- Object
- Discordrb::Message
- Defined in:
- lib/discordrb/data.rb
Overview
A message on Discord that was sent to a text channel
Instance Attribute Summary collapse
-
#author ⇒ Object
(also: #user)
readonly
Returns the value of attribute author.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#content ⇒ Object
(also: #text, #to_s)
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mentions ⇒ Object
readonly
Returns the value of attribute mentions.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#==(other) ⇒ Object
ID based comparison.
-
#await(key, attributes = {}, &block) ⇒ Object
Add an await for a message with the same user and channel.
- #delete ⇒ Object
- #edit(new_content) ⇒ Object
- #from_bot? ⇒ Boolean
-
#initialize(data, bot) ⇒ Message
constructor
A new instance of Message.
- #reply(content) ⇒ Object
Constructor Details
#initialize(data, bot) ⇒ Message
Returns a new instance of Message.
461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/discordrb/data.rb', line 461 def initialize(data, bot) @bot = bot @content = data['content'] = bot.user(data['author']['id'].to_i) @channel = bot.channel(data['channel_id'].to_i) = Time.parse(data['timestamp']) @id = data['id'].to_i @mentions = [] data['mentions'].each do |element| @mentions << User.new(element, bot) end end |
Instance Attribute Details
#author ⇒ Object (readonly) Also known as: user
Returns the value of attribute author.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def channel @channel end |
#content ⇒ Object (readonly) Also known as: text, to_s
Returns the value of attribute content.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def id @id end |
#mentions ⇒ Object (readonly)
Returns the value of attribute mentions.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def mentions @mentions end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
456 457 458 |
# File 'lib/discordrb/data.rb', line 456 def end |
Instance Method Details
#==(other) ⇒ Object
ID based comparison
477 478 479 |
# File 'lib/discordrb/data.rb', line 477 def ==(other) Discordrb.id_compare(@id, other) end |
#await(key, attributes = {}, &block) ⇒ Object
Add an await for a message with the same user and channel
494 495 496 |
# File 'lib/discordrb/data.rb', line 494 def await(key, attributes = {}, &block) @bot.add_await(key, Discordrb::Events::MessageEvent, { from: .id, in: @channel.id }.merge(attributes), &block) end |
#delete ⇒ Object
489 490 491 |
# File 'lib/discordrb/data.rb', line 489 def delete API.(@bot.token, @channel.id, @id) end |
#edit(new_content) ⇒ Object
485 486 487 |
# File 'lib/discordrb/data.rb', line 485 def edit(new_content) API.(@bot.token, @channel.id, @id, new_content) end |
#from_bot? ⇒ Boolean
498 499 500 |
# File 'lib/discordrb/data.rb', line 498 def from_bot? .bot? end |
#reply(content) ⇒ Object
481 482 483 |
# File 'lib/discordrb/data.rb', line 481 def reply(content) @channel.(content) end |