Class: ESM::Event::DiscordMessageChannelV1
- Inherits:
-
Object
- Object
- ESM::Event::DiscordMessageChannelV1
- Defined in:
- lib/esm/event/discord_message_channel_v1.rb
Instance Method Summary collapse
-
#initialize(connection:, server:, parameters:) ⇒ DiscordMessageChannelV1
constructor
Unfortunately, this class is bound by the code I wrote 2 years ago.
- #run! ⇒ Object
Constructor Details
#initialize(connection:, server:, parameters:) ⇒ DiscordMessageChannelV1
Unfortunately, this class is bound by the code I wrote 2 years ago. It's very implicit.
7 8 9 10 11 |
# File 'lib/esm/event/discord_message_channel_v1.rb', line 7 def initialize(connection:, server:, parameters:) @server = server @message = parameters. @channel_id = parameters.channelID end |
Instance Method Details
#run! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/esm/event/discord_message_channel_v1.rb', line 13 def run! check_for_access! # [String, JSON] If array, [title, description, fields(Array)[name, value, inline], color[name, hex]] # Attempt to parse the JSON. to_h will return nil if it fails data = @message.to_h = if data.nil? "**Message from #{@server.server_id}**\n#{@message}" else (data) end ESM.bot.deliver(, to: @channel_id) rescue ESM::Exception::CheckFailure => e @server.community.log_event(:discord_log, e.data) rescue @server.community.log_event(:discord_log, I18n.t("exceptions.malformed_message", message: @message)) end |