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)
1031 1032 1033 |
# File 'lib/discordrb/data.rb', line 1031 def end |
#author ⇒ Member (readonly) Also known as: user
1019 1020 1021 |
# File 'lib/discordrb/data.rb', line 1019 def end |
#channel ⇒ Channel (readonly)
1022 1023 1024 |
# File 'lib/discordrb/data.rb', line 1022 def channel @channel end |
#content ⇒ String (readonly) Also known as: text, to_s
1016 1017 1018 |
# File 'lib/discordrb/data.rb', line 1016 def content @content end |
#mentions ⇒ Array<User> (readonly)
1028 1029 1030 |
# File 'lib/discordrb/data.rb', line 1028 def mentions @mentions end |
#timestamp ⇒ Time (readonly)
1025 1026 1027 |
# File 'lib/discordrb/data.rb', line 1025 def end |
Instance Method Details
#await(key, attributes = {}, &block) ⇒ Object
Add an Await for a message with the same user and channel.
1088 1089 1090 |
# File 'lib/discordrb/data.rb', line 1088 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.
1081 1082 1083 1084 |
# File 'lib/discordrb/data.rb', line 1081 def delete API.(@bot.token, @channel.id, @id) nil end |
#edit(new_content) ⇒ Message
Edits this message to have the specified content instead.
1075 1076 1077 1078 |
# File 'lib/discordrb/data.rb', line 1075 def edit(new_content) response = API.(@bot.token, @channel.id, @id, new_content) Message.new(JSON.parse(response), @bot) end |
#from_bot? ⇒ true, false
1093 1094 1095 |
# File 'lib/discordrb/data.rb', line 1093 def from_bot? && .current_bot? end |
#inspect ⇒ Object
The inspect method is overwritten to give more useful output
1098 1099 1100 |
# File 'lib/discordrb/data.rb', line 1098 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.
1068 1069 1070 |
# File 'lib/discordrb/data.rb', line 1068 def reply(content) @channel.(content) end |