Files
rbot/lib/commands/basic.rb
2017-10-23 20:17:12 +09:00

47 lines
1.6 KiB
Ruby

module Bot
module DiscordCommands
module BasicCommands
extend Discordrb::Commands::CommandContainer
require 'time'
command(:time, usage: 'time <オプション>', description: '現在時刻を表示') do |event, option|
now = DateTime.now
dow = ['日', '月', '火', '水', '木', '金', '土']
date = "#{now.year}#{now.month}#{now.day}日(#{dow[now.wday]})"
time = "#{now.hour}#{now.minute}#{now.second}"
# オプションのチェック
if option == nil
event.respond "#{date}\n#{time}"
else
if option == '-time'
event.respond time
else
if option == '-date'
event.respond date
end
end
end
end
command(:setGame, usage: 'setGame <ゲーム名>', description: 'プレイ中のゲームを設定', min_args: 1) do |event, game|
BOT.game = game
nil
end
command(:reboot, usage: 'reboot', description: 'Botを再起動') do |event|
next unless event.author == '153106386585255936'
exec 'ruby main.rb'
nil
end
command(:shutdown, usage: 'shutdown', description: 'Botを終了') do |event|
next unless event.author == '153106386585255936'
exit(0)
nil
end
end
end
end