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



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

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



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

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



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

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



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



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

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



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

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