Class: Discordrb::Message
- Inherits:
-
Object
- Object
- Discordrb::Message
- Includes:
- IDObject
- Defined in:
- lib/discordrb/data.rb
Overview
A message on Discord that was sent to a text channel
Instance Attribute Summary collapse
-
#attachments ⇒ Array<Attachment>
readonly
The files attached to this message.
-
#author ⇒ Member
(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.
-
#mentions ⇒ Array<User>
readonly
The users that were mentioned in this message.
-
#timestamp ⇒ Time
readonly
The timestamp at which this message was sent.
Attributes included from IDObject
Instance Method Summary collapse
-
#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) ⇒ Message
Edits this message to have the specified content instead.
-
#from_bot? ⇒ true, false
Whether this message was sent by the current Bot.
-
#inspect ⇒ Object
The inspect method is overwritten to give more useful output.
-
#reply(content) ⇒ Object
Replies to this message with the specified content.
Methods included from IDObject
Instance Attribute Details
#attachments ⇒ Array<Attachment> (readonly)
1000 1001 1002 |
# File 'lib/discordrb/data.rb', line 1000 def end |
#author ⇒ Member (readonly) Also known as: user
988 989 990 |
# File 'lib/discordrb/data.rb', line 988 def end |
#channel ⇒ Channel (readonly)
991 992 993 |
# File 'lib/discordrb/data.rb', line 991 def channel @channel end |
#content ⇒ String (readonly) Also known as: text, to_s
985 986 987 |
# File 'lib/discordrb/data.rb', line 985 def content @content end |
#mentions ⇒ Array<User> (readonly)
997 998 999 |
# File 'lib/discordrb/data.rb', line 997 def mentions @mentions end |
#timestamp ⇒ Time (readonly)
994 995 996 |
# File 'lib/discordrb/data.rb', line 994 def end |
Instance Method Details
#await(key, attributes = {}, &block) ⇒ Object
Add an Await for a message with the same user and channel.
1057 1058 1059 |
# File 'lib/discordrb/data.rb', line 1057 def await(key, attributes = {}, &block) @bot.add_await(key, Discordrb::Events::MessageEvent, { from: .id, in: @channel.id }.merge(attributes), &block) end |
#delete ⇒ Object
Deletes this message.
1050 1051 1052 1053 |
# File 'lib/discordrb/data.rb', line 1050 def delete API.(@bot.token, @channel.id, @id) nil end |
#edit(new_content) ⇒ Message
Edits this message to have the specified content instead.
1044 1045 1046 1047 |
# File 'lib/discordrb/data.rb', line 1044 def edit(new_content) response = API.(@bot.token, @channel.id, @id, new_content) Message.new(JSON.parse(response), @bot) end |
#from_bot? ⇒ true, false
1062 1063 1064 |
# File 'lib/discordrb/data.rb', line 1062 def from_bot? && .current_bot? end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
1067 1068 1069 |
# File 'lib/discordrb/data.rb', line 1067 def inspect "<Message content=\"#{@content}\" id=#{@id} timestamp=#{@timestamp} author=#{@author} channel=#{@channel}>" end |
#reply(content) ⇒ Object
Replies to this message with the specified content.
1037 1038 1039 |
# File 'lib/discordrb/data.rb', line 1037 def reply(content) @channel.(content) end |