This repository has been archived by the owner on Mar 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.rb
58 lines (52 loc) · 1.77 KB
/
bot.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'discordrb'
bot = Discordrb::Commands::CommandBot.new token: 'insert_token_here', client_id: 269834753035862016, prefix: '^', help_command: false
bot.set_user_permission(116013677060161545, 1)
bot.set_user_permission(228290433057292288, 1)
bot.command([:subscribe, :sub]) do |event|
if event.channel.pm? == true
event.respond "I can not give you a role in PMs! That would be silly (and impossible)!"
break
end
to_add = event.server.roles.find {|role| role.name == 'Sub'}
if event.user.role?(to_add) == false
event.user.add_role(to_add)
event.message.delete
m = event.respond "Nice, subscribed successfully!"
sleep 3
m.delete
else
event.message.delete
m = event.respond "You already have the role!"
sleep 3
m.delete
end
end
bot.command([:unsubscribe, :unsub]) do |event|
if event.channel.pm? == true
event.respond "I can not take a role in PMs! That would be silly (and impossible)!"
break
end
to_add = event.server.roles.find {|role| role.name == 'Sub'}
if event.user.role?(to_add) == true
event.user.remove_role(to_add)
event.message.delete
m = event.respond "You've unsubscribed from updates!"
sleep 3
m.delete
else
event.message.delete
m = event.respond "You don't have the role!"
m.delete
end
end
bot.command(:accept, in: 269981476135632896) do |event|
event.message.delete
to_add = event.server.roles.find {|role| role.name == 'Members'}
if event.user.role?(to_add) == false
event.user.add_role(to_add)
event.user.pm("Thank you for reading the rules and information, enjoy your stay!")
else
event.respond "You must already have the member role, or an error has occured. Please notify cah or chew."
end
end
bot.run