Class: Discordrb::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ Message

Returns a new instance of Message.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/discordrb/data.rb', line 66

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

#authorObject (readonly) Also known as: user

Returns the value of attribute author.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def author
  @author
end

#channelObject (readonly)

Returns the value of attribute channel.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def channel
  @channel
end

#contentObject (readonly) Also known as: text

Returns the value of attribute content.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def id
  @id
end

#mentionsObject (readonly)

Returns the value of attribute mentions.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def mentions
  @mentions
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



62
63
64
# File 'lib/discordrb/data.rb', line 62

def timestamp
  @timestamp
end