Class: Rubord::Message
- Inherits:
-
Object
- Object
- Rubord::Message
- Defined in:
- lib/rubord/models/message.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#guild_id ⇒ Object
readonly
Returns the value of attribute guild_id.
-
#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
- #delete ⇒ Object
- #edit(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
- #guild ⇒ Object
-
#initialize(data, client) ⇒ Message
constructor
A new instance of Message.
- #inspect ⇒ Object
- #member ⇒ Object
- #post(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
- #reply(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
Constructor Details
#initialize(data, client) ⇒ Message
Returns a new instance of Message.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubord/models/message.rb', line 12 def initialize(data, client) @client = client @id = data["id"] @content = data["content"] @channel_id = data["channel_id"] @guild_id = data["guild_id"] @timestamp = data["timestamp"] && Time.parse(data["timestamp"]) @author = Rubord::User.new(data["author"]) client.users.set(@author.id, @author) @channel = client.channels.get(@channel_id) || Rubord::Channel.new({ "id" => @channel_id }, client) @mentions = Rubord::Mention.new( data, client, guild ) end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def @author end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def channel @channel end |
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def channel_id @channel_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def content @content end |
#guild_id ⇒ Object (readonly)
Returns the value of attribute guild_id.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def guild_id @guild_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def id @id end |
#mentions ⇒ Object (readonly)
Returns the value of attribute mentions.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def mentions @mentions end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/rubord/models/message.rb', line 3 def @timestamp end |
Instance Method Details
#delete ⇒ Object
79 80 81 82 83 84 |
# File 'lib/rubord/models/message.rb', line 79 def delete @client.rest.( @channel_id, @id ) end |
#edit(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rubord/models/message.rb', line 68 def edit(content = nil, embeds: nil, components: nil, flags: nil) @client.rest.( @channel_id, @id, content: content, embeds: , components: components, flags: flags ) end |
#guild ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/rubord/models/message.rb', line 34 def guild return nil unless @guild_id @guild ||= @client.guilds.get(@guild_id) || Rubord::Guild.new(@client.rest.get_guild(@guild_id), @client) end |
#inspect ⇒ Object
86 87 88 |
# File 'lib/rubord/models/message.rb', line 86 def inspect "#<Rubord::Message id=#{@id} mentions=#{mentions.inspect}>" end |
#member ⇒ Object
42 43 44 45 |
# File 'lib/rubord/models/message.rb', line 42 def member return nil unless guild guild.fetch_member(@author.id) end |
#post(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/rubord/models/message.rb', line 47 def post(content = nil, embeds: nil, components: nil, flags: nil) @client.rest.( @channel_id, content: content, embeds: , components: components, flags: flags ) end |
#reply(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rubord/models/message.rb', line 57 def reply(content = nil, embeds: nil, components: nil, flags: nil) @client.rest.( @channel_id, @id, content: content, embeds: , components: components, flags: flags ) end |