Module: Utils::Discord::Integration
- Defined in:
- lib/bas/utils/discord/integration.rb
Overview
This module is a Discord utility for sending messages to Discord.
Class Method Summary collapse
-
.body(params) ⇒ Object
Request body.
-
.execute(params) ⇒ Object
Implements the sending process logic to Discord.
-
.headers ⇒ Object
Request headers.
Class Method Details
.body(params) ⇒ Object
Request body
29 30 31 32 33 34 |
# File 'lib/bas/utils/discord/integration.rb', line 29 def self.body(params) { username: params[:name], content: params[:notification] }.to_json end |
.execute(params) ⇒ Object
Implements the sending process logic to Discord. It sends a POST request to the Discord webhook with the specified payload.
Params:
-
webhook
Discord webhook integration. -
name
Name of the discord user to send the message. -
notification
Text of the notification to be sent.
returns HTTParty::Response
23 24 25 |
# File 'lib/bas/utils/discord/integration.rb', line 23 def self.execute(params) HTTParty.post(params[:webhook], { body: body(params), headers: }) end |
.headers ⇒ Object
Request headers
38 39 40 |
# File 'lib/bas/utils/discord/integration.rb', line 38 def self.headers { "Content-Type" => "application/json" } end |