module MijDiscord::Core::API::Webhook

Public Class Methods

delete_webhook(auth, webhook_id, reason = nil) click to toggle source

Deletes a webhook discordapp.com/developers/docs/resources/webhook#delete-webhook

# File lib/mij-discord/core/api/webhook.rb, line 59
def delete_webhook(auth, webhook_id, reason = nil)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    webhook_id,
    :delete,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}",
    Authorization: auth,
    'X-Audit-Log-Reason': reason,
  )
end
execute_json(webhook_token, webhook_id, data, wait) click to toggle source

Executes a webhook with JSON body discordapp.com/developers/docs/resources/webhook#execute-webhook

# File lib/mij-discord/core/api/webhook.rb, line 84
def execute_json(webhook_token, webhook_id, data, wait)
  wait = wait ? '?wait=true' : ''
  MijDiscord::Core::API.raw_request(
    :post,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}/#{webhook_token}#{wait}",
    data.to_json,
    content_type: :json,
  )
end
token_delete_webhook(webhook_token, webhook_id, reason = nil) click to toggle source

Deletes a webhook via webhook token discordapp.com/developers/docs/resources/webhook#delete-webhook-with-token

# File lib/mij-discord/core/api/webhook.rb, line 72
def token_delete_webhook(webhook_token, webhook_id, reason = nil)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    webhook_id,
    :delete,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}/#{webhook_token}",
    'X-Audit-Log-Reason': reason,
  )
end
token_update_webhook(webhook_token, webhook_id, data, reason = nil) click to toggle source

Update a webhook via webhook token discordapp.com/developers/docs/resources/webhook#modify-webhook-with-token

# File lib/mij-discord/core/api/webhook.rb, line 45
def token_update_webhook(webhook_token, webhook_id, data, reason = nil)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    webhook_id,
    :patch,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}/#{webhook_token}",
    data.to_json,
    content_type: :json,
    'X-Audit-Log-Reason': reason,
  )
end
token_webhook(webhook_token, webhook_id) click to toggle source

Get a webhook via webhook token discordapp.com/developers/docs/resources/webhook#get-webhook-with-token

# File lib/mij-discord/core/api/webhook.rb, line 19
def token_webhook(webhook_token, webhook_id)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    nil,
    :get,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}/#{webhook_token}",
  )
end
update_webhook(auth, webhook_id, data, reason = nil) click to toggle source

Update a webhook discordapp.com/developers/docs/resources/webhook#modify-webhook

# File lib/mij-discord/core/api/webhook.rb, line 30
def update_webhook(auth, webhook_id, data, reason = nil)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    webhook_id,
    :patch,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}",
    data.to_json,
    Authorization: auth,
    content_type: :json,
    'X-Audit-Log-Reason': reason,
  )
end
webhook(auth, webhook_id) click to toggle source

Get a webhook discordapp.com/developers/docs/resources/webhook#get-webhook

# File lib/mij-discord/core/api/webhook.rb, line 7
def webhook(auth, webhook_id)
  MijDiscord::Core::API.request(
    :webhooks_wid,
    nil,
    :get,
    "#{MijDiscord::Core::API::APIBASE_URL}/webhooks/#{webhook_id}",
    Authorization: auth
  )
end