discordrb 1.8.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of discordrb might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.overcommit.yml +7 -0
- data/.rubocop.yml +5 -4
- data/CHANGELOG.md +77 -0
- data/README.md +25 -15
- data/discordrb.gemspec +2 -3
- data/examples/commands.rb +14 -2
- data/examples/ping.rb +1 -1
- data/examples/pm_send.rb +1 -1
- data/lib/discordrb.rb +9 -0
- data/lib/discordrb/api.rb +176 -50
- data/lib/discordrb/await.rb +3 -0
- data/lib/discordrb/bot.rb +607 -372
- data/lib/discordrb/cache.rb +208 -0
- data/lib/discordrb/commands/command_bot.rb +50 -18
- data/lib/discordrb/commands/container.rb +11 -2
- data/lib/discordrb/commands/events.rb +2 -0
- data/lib/discordrb/commands/parser.rb +10 -8
- data/lib/discordrb/commands/rate_limiter.rb +2 -0
- data/lib/discordrb/container.rb +24 -25
- data/lib/discordrb/data.rb +521 -219
- data/lib/discordrb/errors.rb +6 -7
- data/lib/discordrb/events/await.rb +2 -0
- data/lib/discordrb/events/bans.rb +3 -1
- data/lib/discordrb/events/channels.rb +124 -0
- data/lib/discordrb/events/generic.rb +2 -0
- data/lib/discordrb/events/guilds.rb +16 -13
- data/lib/discordrb/events/lifetime.rb +12 -2
- data/lib/discordrb/events/members.rb +26 -15
- data/lib/discordrb/events/message.rb +20 -7
- data/lib/discordrb/events/presence.rb +18 -2
- data/lib/discordrb/events/roles.rb +83 -0
- data/lib/discordrb/events/typing.rb +15 -2
- data/lib/discordrb/events/voice_state_update.rb +2 -0
- data/lib/discordrb/light.rb +8 -0
- data/lib/discordrb/light/data.rb +62 -0
- data/lib/discordrb/light/integrations.rb +73 -0
- data/lib/discordrb/light/light_bot.rb +56 -0
- data/lib/discordrb/logger.rb +4 -0
- data/lib/discordrb/permissions.rb +16 -12
- data/lib/discordrb/token_cache.rb +3 -0
- data/lib/discordrb/version.rb +3 -1
- data/lib/discordrb/voice/encoder.rb +2 -0
- data/lib/discordrb/voice/network.rb +21 -14
- data/lib/discordrb/voice/voice_bot.rb +26 -3
- data/lib/discordrb/websocket.rb +69 -0
- metadata +15 -26
- data/lib/discordrb/events/channel_create.rb +0 -44
- data/lib/discordrb/events/channel_delete.rb +0 -44
- data/lib/discordrb/events/channel_update.rb +0 -46
- data/lib/discordrb/events/guild_role_create.rb +0 -35
- data/lib/discordrb/events/guild_role_delete.rb +0 -36
- data/lib/discordrb/events/guild_role_update.rb +0 -35
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'discordrb/events/generic'
|
2
|
-
require 'discordrb/data'
|
3
|
-
|
4
|
-
module Discordrb::Events
|
5
|
-
# Event raised when a role updates on a server
|
6
|
-
class GuildRoleUpdateEvent < Event
|
7
|
-
attr_reader :role, :server
|
8
|
-
|
9
|
-
def initialize(data, bot)
|
10
|
-
@server = bot.server(data['guild_id'].to_i)
|
11
|
-
return unless @server
|
12
|
-
|
13
|
-
role_id = data['role']['id'].to_i
|
14
|
-
@role = @server.roles.find { |r| r.id == role_id }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Event handler for GuildRoleUpdateEvent
|
19
|
-
class GuildRoleUpdateEventHandler < EventHandler
|
20
|
-
def matches?(event)
|
21
|
-
# Check for the proper event type
|
22
|
-
return false unless event.is_a? GuildRoleUpdateEvent
|
23
|
-
|
24
|
-
[
|
25
|
-
matches_all(@attributes[:name], event.name) do |a, e|
|
26
|
-
a == if a.is_a? String
|
27
|
-
e.to_s
|
28
|
-
else
|
29
|
-
e
|
30
|
-
end
|
31
|
-
end
|
32
|
-
].reduce(true, &:&)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|