Module: Discordrb::API::Webhook
- Defined in:
- lib/discordrb/api/webhook.rb
Overview
API calls for Webhook object
Class Method Summary collapse
-
.delete_webhook(token, webhook_id, reason = nil) ⇒ Object
Deletes a webhook https://discord.com/developers/docs/resources/webhook#delete-webhook.
-
.token_delete_message(webhook_token, webhook_id, message_id) ⇒ Object
Delete a webhook message via webhook token.
-
.token_delete_webhook(webhook_token, webhook_id, reason = nil) ⇒ Object
Deletes a webhook via webhook token https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token.
-
.token_edit_message(webhook_token, webhook_id, message_id, content = nil, embeds = nil, allowed_mentions = nil, components = nil) ⇒ Object
Edit a webhook message via webhook token https://discord.com/developers/docs/resources/webhook#edit-webhook-message.
-
.token_execute_webhook(webhook_token, webhook_id, wait = false, content = nil, username = nil, avatar_url = nil, tts = nil, file = nil, embeds = nil, allowed_mentions = nil, flags = nil, components = nil) ⇒ Object
Execute a webhook via token.
-
.token_get_message(webhook_token, webhook_id, message_id) ⇒ Object
Get a message that was created by the webhook corresponding to the provided token.
-
.token_update_webhook(webhook_token, webhook_id, data, reason = nil) ⇒ Object
Update a webhook via webhook token https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token.
-
.token_webhook(webhook_token, webhook_id) ⇒ Object
Get a webhook via webhook token https://discord.com/developers/docs/resources/webhook#get-webhook-with-token.
-
.update_webhook(token, webhook_id, data, reason = nil) ⇒ Object
Update a webhook https://discord.com/developers/docs/resources/webhook#modify-webhook.
- .webhook(token, webhook_id) ⇒ Object
Class Method Details
.delete_webhook(token, webhook_id, reason = nil) ⇒ Object
Deletes a webhook https://discord.com/developers/docs/resources/webhook#delete-webhook
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/discordrb/api/webhook.rb', line 83 def delete_webhook(token, webhook_id, reason = nil) Discordrb::API.request( :webhooks_wid, webhook_id, :delete, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.token_delete_message(webhook_token, webhook_id, message_id) ⇒ Object
Delete a webhook message via webhook token. https://discord.com/developers/docs/resources/webhook#delete-webhook-message
132 133 134 135 136 137 138 139 |
# File 'lib/discordrb/api/webhook.rb', line 132 def (webhook_token, webhook_id, ) Discordrb::API.request( :webhooks_wid_messages, webhook_id, :delete, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{}" ) end |
.token_delete_webhook(webhook_token, webhook_id, reason = nil) ⇒ Object
Deletes a webhook via webhook token https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
96 97 98 99 100 101 102 103 104 |
# File 'lib/discordrb/api/webhook.rb', line 96 def token_delete_webhook(webhook_token, webhook_id, reason = nil) Discordrb::API.request( :webhooks_wid, webhook_id, :delete, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}", 'X-Audit-Log-Reason': reason ) end |
.token_edit_message(webhook_token, webhook_id, message_id, content = nil, embeds = nil, allowed_mentions = nil, components = nil) ⇒ Object
Edit a webhook message via webhook token https://discord.com/developers/docs/resources/webhook#edit-webhook-message
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/discordrb/api/webhook.rb', line 119 def (webhook_token, webhook_id, , content = nil, = nil, allowed_mentions = nil, components = nil) Discordrb::API.request( :webhooks_wid_messages, webhook_id, :patch, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{}", { content: content, embeds: , allowed_mentions: allowed_mentions, components: components }.to_json, content_type: :json ) end |
.token_execute_webhook(webhook_token, webhook_id, wait = false, content = nil, username = nil, avatar_url = nil, tts = nil, file = nil, embeds = nil, allowed_mentions = nil, flags = nil, components = nil) ⇒ Object
Execute a webhook via token. https://discord.com/developers/docs/resources/webhook#execute-webhook
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/discordrb/api/webhook.rb', line 32 def token_execute_webhook(webhook_token, webhook_id, wait = false, content = nil, username = nil, avatar_url = nil, tts = nil, file = nil, = nil, allowed_mentions = nil, flags = nil, components = nil) body = { content: content, username: username, avatar_url: avatar_url, tts: tts, embeds: &.map(&:to_hash), allowed_mentions: allowed_mentions, flags: flags, components: components } body = if file { file: file, payload_json: body.to_json } else body.to_json end headers = { content_type: :json } unless file Discordrb::API.request( :webhooks_wid, webhook_id, :post, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}?wait=#{wait}", body, headers ) end |
.token_get_message(webhook_token, webhook_id, message_id) ⇒ Object
Get a message that was created by the webhook corresponding to the provided token. https://discord.com/developers/docs/resources/webhook#get-webhook-message
108 109 110 111 112 113 114 115 |
# File 'lib/discordrb/api/webhook.rb', line 108 def (webhook_token, webhook_id, ) Discordrb::API.request( :webhooks_wid_messages_mid, webhook_id, :get, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}/messages/#{}" ) end |
.token_update_webhook(webhook_token, webhook_id, data, reason = nil) ⇒ Object
Update a webhook via webhook token https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/discordrb/api/webhook.rb', line 69 def token_update_webhook(webhook_token, webhook_id, data, reason = nil) Discordrb::API.request( :webhooks_wid, webhook_id, :patch, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}", data.to_json, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.token_webhook(webhook_token, webhook_id) ⇒ Object
Get a webhook via webhook token https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
21 22 23 24 25 26 27 28 |
# File 'lib/discordrb/api/webhook.rb', line 21 def token_webhook(webhook_token, webhook_id) Discordrb::API.request( :webhooks_wid, nil, :get, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}/#{webhook_token}" ) end |
.update_webhook(token, webhook_id, data, reason = nil) ⇒ Object
Update a webhook https://discord.com/developers/docs/resources/webhook#modify-webhook
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/discordrb/api/webhook.rb', line 54 def update_webhook(token, webhook_id, data, reason = nil) Discordrb::API.request( :webhooks_wid, webhook_id, :patch, "#{Discordrb::API.api_base}/webhooks/#{webhook_id}", data.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |