Class: Discordify::Client
- Inherits:
-
Object
- Object
- Discordify::Client
- Defined in:
- lib/discordify/client.rb
Class Attribute Summary collapse
-
.webhook_address ⇒ Object
Returns the value of attribute webhook_address.
Instance Attribute Summary collapse
-
#webhook_address ⇒ Object
Returns the value of attribute webhook_address.
Instance Method Summary collapse
-
#initialize(webhook_address = nil) ⇒ Client
constructor
A new instance of Client.
- #post_json(message:, username:, avatar:) ⇒ Object
Constructor Details
#initialize(webhook_address = nil) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/discordify/client.rb', line 14 def initialize(webhook_address = nil) @webhook_address = webhook_address || self.class.webhook_address end |
Class Attribute Details
.webhook_address ⇒ Object
Returns the value of attribute webhook_address.
10 11 12 |
# File 'lib/discordify/client.rb', line 10 def webhook_address @webhook_address end |
Instance Attribute Details
#webhook_address ⇒ Object
Returns the value of attribute webhook_address.
6 7 8 |
# File 'lib/discordify/client.rb', line 6 def webhook_address @webhook_address end |
Instance Method Details
#post_json(message:, username:, avatar:) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/discordify/client.rb', line 18 def post_json(message:, username:, avatar:) avatar ||= default_avatar url = uri(webhook_address) request = Net::HTTP::Post.new(url.path, headers) request.body = { content: , username: username, avatar_url: avatar }.to_json res = https_request(url).request(request) res.code == '204' end |