Class: ESM::Event::SendToChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/esm/event/send_to_channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, message) ⇒ SendToChannel

Returns a new instance of SendToChannel.



6
7
8
9
# File 'lib/esm/event/send_to_channel.rb', line 6

def initialize(server, message)
  @server = server
  @message = message
end

Instance Method Details

#run!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/esm/event/send_to_channel.rb', line 11

def run!
  check_for_access!

  # If the content is a hashmap, the data is for an embed
  content = @message.data.content
  message =
    if (embed = ESM::Arma::HashMap.from(content)) && embed.present?
      build_embed(embed)
    else
      "*Sent from `#{@server.server_id}`*\n#{content}"
    end

  ESM.bot.deliver(message, to: @channel)
rescue ESM::Exception::CheckFailure => e
  @server.log_error(e.message)
end