Class: Discordrb::Channel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, bot) ⇒ Channel

Returns a new instance of Channel.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/discordrb/data.rb', line 37

def initialize(data, bot)
  @bot = bot

  @id = data['id']
  @type = data['type'] || 'text'

  @is_private = data['is_private']
  if @is_private
    @recipient = User.new(data['recipient'], bot)
    @name = @recipient.username
  else
    @name = data['name']
    @server = bot.server(data['guild_id'].to_i)
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def id
  @id
end

#is_privateObject (readonly)

Returns the value of attribute is_private.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def is_private
  @is_private
end

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def name
  @name
end

#recipientObject (readonly)

Returns the value of attribute recipient.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def recipient
  @recipient
end

#serverObject (readonly)

Returns the value of attribute server.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def server
  @server
end

#typeObject (readonly)

Returns the value of attribute type.



35
36
37
# File 'lib/discordrb/data.rb', line 35

def type
  @type
end

Instance Method Details

#send_message(content) ⇒ Object Also known as: send, message



53
54
55
# File 'lib/discordrb/data.rb', line 53

def send_message(content)
  @bot.send_message(@id, content)
end