Module: DiscordBot::Client::Channels::CreateWebhook

Included in:
DiscordBot::Client
Defined in:
lib/discord_bot/client/channels/create_webhook.rb

Overview

CreateWebhook module

Instance Method Summary collapse

Instance Method Details

#create_channel_webhook(channel_id:, name:) ⇒ Object

Create webhook to channel



8
9
10
11
12
13
14
# File 'lib/discord_bot/client/channels/create_webhook.rb', line 8

def create_channel_webhook(channel_id:, name:)
  # define params for request
  body = { 'name' => name }.to_json
  headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bot #{bot_token}", 'User-Agent' => user_agent }
  # make request
  self.class.post("/channels/#{channel_id}/webhooks", body: body, headers: headers).parsed_response
end