-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-commands.rb
More file actions
executable file
·77 lines (74 loc) · 3.28 KB
/
user-commands.rb
File metadata and controls
executable file
·77 lines (74 loc) · 3.28 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# frozen_string_literal: true
require_relative './index.rb'
class UnoModule
def message(event); end
def userCommand(command, args, event)
commandLanguage = @language.get_json(event.server.id)['commands']
if commandLanguage['uno']['aliases'].include? command
if args.empty?
output = commandLanguage['uno']['output']
event << format(output, v: module_version)
else
if event.user.permission? :administrator
case args[0]
when *commandLanguage['help']['aliases']
event << format(commandLanguage['help']['output'], u: event.author.username)
when *commandLanguage['category']['get']['aliases']
if args.length == 1
@client.query("SELECT * FROM `uno` WHERE SERVERID=#{event.server.id}").each do |row|
if row['CATEGORY'].nil?
event << format(commandLanguage['category']['get']['no'])
else
channel = event.bot.channel(row['CATEGORY'].to_i)
if channel.nil?
event << format(commandLanguage['category']['get']['no'])
else
event << format(commandLanguage['category']['get']['output'], c: channel.name, i: channel.id)
end
end
end
else
event << format(commandLanguage['category']['get']['usage'])
end
when *commandLanguage['category']['set']['aliases']
if args.length == 2
if args[1].numeric?
channel = event.bot.channel(args[1].to_i, event.server)
if channel.server.id == event.server.id
if channel.nil?
event << format(commandLanguage['category']['set']['notexist'], c: channel.name, i: channel.id)
else
if channel.category?
@client.query("UPDATE `uno` SET CATEGORY=#{channel.id} WHERE SERVERID=#{channel.server.id};")
event.send_message format(commandLanguage['category']['set']['output'], c: channel.name, i: channel.id)
reload(event.server)
else
event << format(commandLanguage['category']['set']['notexist'], c: args[1])
end
end
else
event << format(commandLanguage['category']['set']['notexist'], c: args[1])
end
else
event << format(commandLanguage['category']['set']['notexist'], c: args[1])
end
elsif args.length == 1
@client.query("UPDATE `uno` SET CATEGORY=NULL WHERE SERVERID=#{event.server.id};")
event.send_message commandLanguage['category']['set']['remove']
reload(event.server)
else
event << format(commandLanguage['category']['set']['usage'], u: event.author.username)
end
else
event << format(commandLanguage['notexist'], u: event.author.username)
end
else
event << format(commandLanguage['nopermission'], u: event.author.username)
end
end
end
end
def help(_user, channel)
channel.send_message format(@language.get_json(channel.server.id)['help'])
end
end