Added "time" command

This commit is contained in:
takumi091111
2017-09-27 00:53:53 +09:00
parent 4cdf5bedb5
commit 4b2ea611fb

30
lib/commands/basic.rb Normal file
View File

@ -0,0 +1,30 @@
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
end
end
end