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)
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
-
#await(key, attributes = {}, &block) ⇒ Object
Add an await for a message with the same user and channel.
- #delete ⇒ Object
- #edit(new_content) ⇒ Object
-
#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.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/discordrb/data.rb', line 254 def initialize(data, bot) @bot = bot @content = data['content'] @author = User.new(data['author'], bot) @channel = bot.channel(data['channel_id'].to_i) @timestamp = Time.at(data['timestamp'].to_i) @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.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def @author end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def channel @channel end |
#content ⇒ Object (readonly) Also known as: text
Returns the value of attribute content.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def id @id end |
#mentions ⇒ Object (readonly)
Returns the value of attribute mentions.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def mentions @mentions end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
250 251 252 |
# File 'lib/discordrb/data.rb', line 250 def @timestamp end |
Instance Method Details
#await(key, attributes = {}, &block) ⇒ Object
Add an await for a message with the same user and channel
282 283 284 |
# File 'lib/discordrb/data.rb', line 282 def await(key, attributes = {}, &block) @bot.add_await(key, MessageEvent, { from: @author.id, in: @channel.id }.merge(attributes), &block) end |
#delete ⇒ Object
277 278 279 |
# File 'lib/discordrb/data.rb', line 277 def delete API.(@bot.token, @channel.id, @id) end |
#edit(new_content) ⇒ Object
273 274 275 |
# File 'lib/discordrb/data.rb', line 273 def edit(new_content) API.(@bot.token, @channel.id, @id, new_content) end |
#reply(content) ⇒ Object
269 270 271 |
# File 'lib/discordrb/data.rb', line 269 def reply(content) @channel.(content) end |