Method: Vox::HTTP::Routes::Webhook#execute_webhook
- Defined in:
- lib/vox/http/routes/webhook.rb
#execute_webhook(webhook_id, webhook_token, wait: :undef, content: :undef, username: :undef, avatar_url: :undef, tts: :undef, file: :undef, embeds: :undef, allowed_mentions: :undef, attachments: :undef) ⇒ Object
Post content to a webhook.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/vox/http/routes/webhook.rb', line 153 def execute_webhook(webhook_id, webhook_token, wait: :undef, content: :undef, username: :undef, avatar_url: :undef, tts: :undef, file: :undef, embeds: :undef, allowed_mentions: :undef, attachments: :undef) params = filter_undef({ wait: wait }) json = filter_undef({ content: content, username: username, avatar_url: avatar_url, tts: tts, embeds: , allowed_mentions: allowed_mentions }) route = Route.new(:POST, '/webhooks/%{webhook_id}/%{webhook_token}', webhook_id: webhook_id, webhook_token: webhook_token) if file != :undef data = { file: file, payload_json: MultiJson.dump(json) } request(route, data: data, query: params) elsif != :undef = .collect { |k, v| UploadIO.new(v.io, v.content_type, k) } if .is_a? Hash attach_hash = Array(0....size).zip().to_h data = attach_hash.merge(payload_json: MultiJson.dump(json)) request(route, data: data, query: params) else request(route, json: json, query: params) end end |