Class: QwtfDiscordBotDashboard

Inherits:
Object
  • Object
show all
Defined in:
lib/qwtf_discord_bot/qwtf_discord_bot_dashboard.rb

Constant Summary collapse

THIRTY_SECONDS =
30

Instance Method Summary collapse

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/qwtf_discord_bot/qwtf_discord_bot_dashboard.rb', line 4

def run
  bot = Discordrb::Commands::CommandBot.new(
    token: QwtfDiscordBot.config.token,
    client_id: QwtfDiscordBot.config.client_id,
    help_command: false,
    prefix: proc do |message|
      match = /^\!(\w+)(.*)/.match(message.content)
      if match
        first = match[1]
        rest = match[2]
        # Return the modified string with the first word lowercase:
        "#{first.downcase}#{rest}"
      end
    end
  )

  bot.run(true)

  @dashboards ||= QwtfDiscordBot.config.dashboards.map do |dashboard_config|
    Dashboard.new(dashboard_config, bot)
  end

  every(THIRTY_SECONDS) do
    @dashboards.each do |dashboard|
      dashboard.update
    end
  end
end