-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
maintenance.rb
44 lines (37 loc) · 1.15 KB
/
maintenance.rb
1
2
3
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
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
require 'yaml'
require 'discordrb'
# Load Config from YAML
@config = if File.exist?('config/maintenance.yml')
YAML.load_file('config/maintenance.yml')
else
YAML.load_file('config/config.yml')
end
@config.each do |key, value|
if value.nil?
puts "config.yml: #{key} is nil!"
puts 'Corrupt or incorrect Yaml.'
exit
elsif @config['verbose']
puts("config.yml: Found #{key}: #{value}")
end
end
bot = Discordrb::Bot.new token: @config['token']
bot.ready do |event|
event.bot.dnd
event.bot.game = 'Down for maintenance... :('
end
bot.message do |event|
if event.message.content.split.length > 1
@config['prefixes'].each do |x|
next unless event.message.content.start_with? x
username = event.bot.profile.name
owner_tag = event.bot.user(@config['master_owner']).distinct
event.respond("Hi! It seems that #{username} is currently undergoing maintenance.\n" \
"Please try again later, and contact `#{owner_tag}` if problems persist.\n" \
'Sorry for any inconvenience caused!')
break
end
end
end
bot.run