Sha256: 2d6cccac0b7826dee163c7b709308224b4bde44f8e472a3c8aa9935829b90181

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

module DiscordBot
  class Client
    # Webhooks module
    module Webhooks
      # Execute module
      module Execute
        # Create webhook to channel
        def execute_webhook(webhook_id:, webhook_token:, content:)
          # define params for request
          body = { 'content' => content }.to_json
          headers = { 'Content-Type' => 'application/json', 'Authorization' => "Bot #{bot_token}", 'User-Agent' => user_agent }
          # make request
          self.class.post("/webhooks/#{webhook_id}/#{webhook_token}", body: body, headers: headers).parsed_response
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discord_bot-0.2.1 lib/discord_bot/client/webhooks/execute.rb
discord_bot-0.2.0 lib/discord_bot/client/webhooks/execute.rb