Sha256: cdfce555f1149aa3e9166c9c0598ca14ec4f0fda0012ead3e9e1a4b99c0073ca

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

class Dashboard
  def initialize(channel, bot)
    @channel_id = channel["id"]
    @endpoints = channel["endpoints"]
    @bot = bot
    @messages = {}
  end

  def update
    @endpoints.each do |endpoint|
      qstat_request = QstatRequest.new(endpoint)

      if qstat_request.is_empty?
        next unless @messages[endpoint]

        @messages[endpoint].delete
        @messages.delete(endpoint)
      end

      embed = qstat_request.to_full_embed

      @messages[endpoint] = if @messages[endpoint]
                              @messages[endpoint].edit(nil, embed)
                            else
                              channel.send_embed(nil, embed)
                            end
    end
  end

  private

  def channel
    data = Discordrb::API::Channel.resolve(
      "Bot #{QwtfDiscordBot.config.token}",
      @channel_id
    )

    Discordrb::Channel.new(JSON.parse(data), @bot)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qwtf_discord_bot-5.5.0 lib/dashboard.rb