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 ⇒ User
(also: #user)
readonly
The user that sent this message.
-
#channel ⇒ Channel
readonly
The channel in which this message was sent.
-
#content ⇒ String
(also: #text, #to_s)
readonly
The content of this message.
-
#id ⇒ Integer
(also: #resolve_id)
readonly
The ID used to uniquely identify this message.
-
#mentions ⇒ Array<User>
readonly
The users that were mentioned in this message.
-
#timestamp ⇒ Time
readonly
The timestamp at which this message was sent.
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
Deletes this message.
-
#edit(new_content) ⇒ Object
Edits this message to have the specified content instead.
-
#from_bot? ⇒ true, false
Whether this message was sent by the current Bot.
-
#reply(content) ⇒ Object
Replies to this message with the specified content.
Instance Attribute Details
#author ⇒ User (readonly) Also known as: user
Returns the user that sent this message.
670 671 672 |
# File 'lib/discordrb/data.rb', line 670 def @author end |
#channel ⇒ Channel (readonly)
Returns the channel in which this message was sent.
673 674 675 |
# File 'lib/discordrb/data.rb', line 673 def channel @channel end |
#content ⇒ String (readonly) Also known as: text, to_s
Returns the content of this message.
667 668 669 |
# File 'lib/discordrb/data.rb', line 667 def content @content end |
#id ⇒ Integer (readonly) Also known as: resolve_id
Returns the ID used to uniquely identify this message.
679 680 681 |
# File 'lib/discordrb/data.rb', line 679 def id @id end |
#mentions ⇒ Array<User> (readonly)
Returns the users that were mentioned in this message.
682 683 684 |
# File 'lib/discordrb/data.rb', line 682 def mentions @mentions end |
#timestamp ⇒ Time (readonly)
Returns the timestamp at which this message was sent.
676 677 678 |
# File 'lib/discordrb/data.rb', line 676 def @timestamp end |
Instance Method Details
#==(other) ⇒ Object
ID based comparison
706 707 708 |
# File 'lib/discordrb/data.rb', line 706 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.
729 730 731 |
# File 'lib/discordrb/data.rb', line 729 def await(key, attributes = {}, &block) @bot.add_await(key, Discordrb::Events::MessageEvent, { from: @author.id, in: @channel.id }.merge(attributes), &block) end |
#delete ⇒ Object
Deletes this message.
723 724 725 |
# File 'lib/discordrb/data.rb', line 723 def delete API.(@bot.token, @channel.id, @id) end |
#edit(new_content) ⇒ Object
Edits this message to have the specified content instead.
718 719 720 |
# File 'lib/discordrb/data.rb', line 718 def edit(new_content) API.(@bot.token, @channel.id, @id, new_content) end |
#from_bot? ⇒ true, false
Returns whether this message was sent by the current Bot.
734 735 736 |
# File 'lib/discordrb/data.rb', line 734 def from_bot? @author.bot? end |
#reply(content) ⇒ Object
Replies to this message with the specified content.
712 713 714 |
# File 'lib/discordrb/data.rb', line 712 def reply(content) @channel.(content) end |