Module: DiscordBot::Client::Channels::CreateMessage

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

Overview

CreateMessage module

Instance Method Summary collapse

Instance Method Details

#create_channel_message(channel_id:, content:) ⇒ Object

Create message to channel



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

def create_channel_message(channel_id:, 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("/channels/#{channel_id}/messages", body: body, headers: headers).parsed_response
end