Class: Rubord::Channel
- Inherits:
-
Object
- Object
- Rubord::Channel
- Defined in:
- lib/rubord/models/channel.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #fetch_message(message_id) ⇒ Object
- #guild ⇒ Object
-
#initialize(data, client) ⇒ Channel
constructor
A new instance of Channel.
- #inspect ⇒ Object
- #post(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
- #text? ⇒ Boolean
- #voice? ⇒ Boolean
Constructor Details
#initialize(data, client) ⇒ Channel
Returns a new instance of Channel.
7 8 9 10 11 12 13 14 |
# File 'lib/rubord/models/channel.rb', line 7 def initialize(data, client) @id = data["id"] @name = data["name"] @type = data["type"] @client = client client&.channels&.set(@id, self) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rubord/models/channel.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rubord/models/channel.rb', line 3 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/rubord/models/channel.rb', line 3 def type @type end |
Instance Method Details
#fetch_message(message_id) ⇒ Object
26 27 28 |
# File 'lib/rubord/models/channel.rb', line 26 def () @client.rest.(@id, ) end |
#guild ⇒ Object
30 31 32 33 |
# File 'lib/rubord/models/channel.rb', line 30 def guild return nil unless @client && @client.respond_to?(:guilds) @client.guilds.get(guild_id) end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/rubord/models/channel.rb', line 43 def inspect "#<Rubord::Channel id=#{id} name=#{name.inspect} type=#{type}>" end |
#post(content = nil, embeds: nil, components: nil, flags: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/rubord/models/channel.rb', line 16 def post(content = nil, embeds: nil, components: nil, flags: nil) @client.rest.( @id, content: content, embeds: , components: components, flags: flags ) end |
#text? ⇒ Boolean
35 36 37 |
# File 'lib/rubord/models/channel.rb', line 35 def text? type == 0 end |
#voice? ⇒ Boolean
39 40 41 |
# File 'lib/rubord/models/channel.rb', line 39 def voice? type == 2 end |