Class: Discordrb::Webhooks::Client
- Inherits:
-
Object
- Object
- Discordrb::Webhooks::Client
- Defined in:
- lib/discordrb/webhooks/client.rb
Overview
A client for a particular webhook added to a Discord channel.
Instance Method Summary collapse
-
#execute(builder = nil, wait = false) {|builder| ... } ⇒ RestClient::Response
Executes the webhook this client points to with the given data.
-
#initialize(url: nil, id: nil, token: nil) ⇒ Client
constructor
Create a new webhook.
Constructor Details
#initialize(url: nil, id: nil, token: nil) ⇒ Client
Create a new webhook
17 18 19 |
# File 'lib/discordrb/webhooks/client.rb', line 17 def initialize(url: nil, id: nil, token: nil) @url = url || generate_url(id, token) end |
Instance Method Details
#execute(builder = nil, wait = false) {|builder| ... } ⇒ RestClient::Response
Executes the webhook this client points to with the given data.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/discordrb/webhooks/client.rb', line 41 def execute(builder = nil, wait = false) raise TypeError, 'builder needs to be nil or like a Discordrb::Webhooks::Builder!' unless builder.respond_to?(:file) && builder.respond_to?(:to_multipart_hash) || builder.respond_to?(:to_json_hash) || builder.nil? builder ||= Builder.new yield builder if block_given? if builder.file post_multipart(builder, wait) else post_json(builder, wait) end end |