Module: Discordrb::API::Webhook

Defined in:
lib/discordrb/api/webhook.rb

Overview

API calls for Webhook object

Class Method Summary collapse

Class Method Details

.delete_webhook(token, webhook_id, reason = nil) ⇒ Object


59
60
61
62
63
64
65
66
67
68
# File 'lib/discordrb/api/webhook.rb', line 59

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_webhook(webhook_token, webhook_id, reason = nil) ⇒ Object


72
73
74
75
76
77
78
79
80
# File 'lib/discordrb/api/webhook.rb', line 72

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_update_webhook(webhook_token, webhook_id, data, reason = nil) ⇒ Object


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/discordrb/api/webhook.rb', line 45

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


19
20
21
22
23
24
25
26
# File 'lib/discordrb/api/webhook.rb', line 19

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


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/discordrb/api/webhook.rb', line 30

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

.webhook(token, webhook_id) ⇒ Object


7
8
9
10
11
12
13
14
15
# File 'lib/discordrb/api/webhook.rb', line 7

def webhook(token, webhook_id)
  Discordrb::API.request(
    :webhooks_wid,
    nil,
    :get,
    "#{Discordrb::API.api_base}/webhooks/#{webhook_id}",
    Authorization: token
  )
end