discorb 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build_version.yml +2 -2
- data/.rubocop.yml +12 -75
- data/Changelog.md +10 -0
- data/Rakefile +482 -454
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -398
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -266
- data/lib/discorb/app_command.rb +5 -5
- data/lib/discorb/application.rb +198 -197
- data/lib/discorb/asset.rb +101 -101
- data/lib/discorb/attachment.rb +134 -119
- data/lib/discorb/audit_logs.rb +412 -385
- data/lib/discorb/automod.rb +279 -269
- data/lib/discorb/channel/base.rb +107 -108
- data/lib/discorb/channel/category.rb +32 -32
- data/lib/discorb/channel/container.rb +44 -44
- data/lib/discorb/channel/dm.rb +26 -28
- data/lib/discorb/channel/guild.rb +311 -246
- data/lib/discorb/channel/stage.rb +156 -140
- data/lib/discorb/channel/text.rb +430 -336
- data/lib/discorb/channel/thread.rb +374 -325
- data/lib/discorb/channel/voice.rb +85 -79
- data/lib/discorb/channel.rb +5 -5
- data/lib/discorb/client.rb +635 -621
- data/lib/discorb/color.rb +178 -182
- data/lib/discorb/common.rb +168 -164
- data/lib/discorb/components/button.rb +107 -106
- data/lib/discorb/components/select_menu.rb +157 -145
- data/lib/discorb/components/text_input.rb +103 -106
- data/lib/discorb/components.rb +68 -66
- data/lib/discorb/dictionary.rb +135 -135
- data/lib/discorb/embed.rb +404 -398
- data/lib/discorb/emoji.rb +309 -302
- data/lib/discorb/emoji_table.rb +16099 -8857
- data/lib/discorb/error.rb +131 -131
- data/lib/discorb/event.rb +360 -314
- data/lib/discorb/event_handler.rb +39 -39
- data/lib/discorb/exe/about.rb +17 -17
- data/lib/discorb/exe/irb.rb +72 -67
- data/lib/discorb/exe/new.rb +323 -315
- data/lib/discorb/exe/run.rb +69 -68
- data/lib/discorb/exe/setup.rb +57 -55
- data/lib/discorb/exe/show.rb +12 -12
- data/lib/discorb/extend.rb +25 -45
- data/lib/discorb/extension.rb +89 -83
- data/lib/discorb/flag.rb +126 -128
- data/lib/discorb/gateway.rb +984 -804
- data/lib/discorb/gateway_events.rb +670 -638
- data/lib/discorb/gateway_requests.rb +45 -48
- data/lib/discorb/guild.rb +2115 -1626
- data/lib/discorb/guild_template.rb +280 -241
- data/lib/discorb/http.rb +247 -232
- data/lib/discorb/image.rb +42 -42
- data/lib/discorb/integration.rb +169 -161
- data/lib/discorb/intents.rb +161 -163
- data/lib/discorb/interaction/autocomplete.rb +76 -62
- data/lib/discorb/interaction/command.rb +279 -224
- data/lib/discorb/interaction/components.rb +114 -104
- data/lib/discorb/interaction/modal.rb +36 -32
- data/lib/discorb/interaction/response.rb +379 -336
- data/lib/discorb/interaction/root.rb +271 -257
- data/lib/discorb/interaction.rb +5 -5
- data/lib/discorb/invite.rb +154 -153
- data/lib/discorb/member.rb +344 -311
- data/lib/discorb/message.rb +615 -544
- data/lib/discorb/message_meta.rb +197 -186
- data/lib/discorb/modules.rb +371 -290
- data/lib/discorb/permission.rb +305 -291
- data/lib/discorb/presence.rb +352 -346
- data/lib/discorb/rate_limit.rb +81 -76
- data/lib/discorb/reaction.rb +55 -54
- data/lib/discorb/role.rb +272 -240
- data/lib/discorb/shard.rb +76 -74
- data/lib/discorb/sticker.rb +193 -171
- data/lib/discorb/user.rb +205 -188
- data/lib/discorb/utils/colored_puts.rb +16 -16
- data/lib/discorb/utils.rb +12 -16
- data/lib/discorb/voice_state.rb +305 -281
- data/lib/discorb/webhook.rb +537 -507
- data/lib/discorb.rb +62 -56
- data/sig/discorb/application.rbs +2 -0
- data/sig/discorb/automod.rbs +10 -1
- data/sig/discorb/guild.rbs +2 -0
- data/sig/discorb/message.rbs +2 -0
- data/sig/discorb/user.rbs +22 -20
- metadata +2 -2
@@ -1,39 +1,39 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents a event handler.
|
6
|
-
# This class shouldn't be instantiated directly.
|
7
|
-
# Use {Client#on} instead.
|
8
|
-
#
|
9
|
-
class EventHandler
|
10
|
-
# @return [Proc] the block to be called.
|
11
|
-
attr_reader :block
|
12
|
-
# @return [Symbol] the event id.
|
13
|
-
attr_reader :id
|
14
|
-
# @return [Hash] the event metadata.
|
15
|
-
attr_reader :metadata
|
16
|
-
# @return [Boolean] whether the event is once or not.
|
17
|
-
attr_reader :once
|
18
|
-
alias once? once
|
19
|
-
|
20
|
-
def initialize(block, id, metadata)
|
21
|
-
@block = block
|
22
|
-
@id = id
|
23
|
-
@once = metadata.fetch(:once, false)
|
24
|
-
@metadata = metadata
|
25
|
-
@rescue = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def inspect
|
29
|
-
"#<#{self.class} @id=#{@id}"
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Calls the block associated with the event.
|
34
|
-
#
|
35
|
-
def call(...)
|
36
|
-
@block.call(...)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a event handler.
|
6
|
+
# This class shouldn't be instantiated directly.
|
7
|
+
# Use {Client#on} instead.
|
8
|
+
#
|
9
|
+
class EventHandler
|
10
|
+
# @return [Proc] the block to be called.
|
11
|
+
attr_reader :block
|
12
|
+
# @return [Symbol] the event id.
|
13
|
+
attr_reader :id
|
14
|
+
# @return [Hash] the event metadata.
|
15
|
+
attr_reader :metadata
|
16
|
+
# @return [Boolean] whether the event is once or not.
|
17
|
+
attr_reader :once
|
18
|
+
alias once? once
|
19
|
+
|
20
|
+
def initialize(block, id, metadata)
|
21
|
+
@block = block
|
22
|
+
@id = id
|
23
|
+
@once = metadata.fetch(:once, false)
|
24
|
+
@metadata = metadata
|
25
|
+
@rescue = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def inspect
|
29
|
+
"#<#{self.class} @id=#{@id}"
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Calls the block associated with the event.
|
34
|
+
#
|
35
|
+
def call(...)
|
36
|
+
@block.call(...)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/discorb/exe/about.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# description: Show information of discorb.
|
4
|
-
|
5
|
-
puts " disco\e[31mrb\e[m - A new Discord API wrapper in Ruby. \n\n"
|
6
|
-
|
7
|
-
informations = {
|
8
|
-
"GitHub" => "https://github.com/discorb-lib/discorb",
|
9
|
-
"Documentation" => "https://discorb-lib.github.io",
|
10
|
-
"RubyGems" => "https://rubygems.org/gems/discorb",
|
11
|
-
"Changelog" => "https://discorb-lib.github.io/file.Changelog.html",
|
12
|
-
"License" => "MIT License"
|
13
|
-
}
|
14
|
-
|
15
|
-
informations.each do |key, value|
|
16
|
-
puts "\e[90m#{key.rjust(informations.keys.map(&:length).max)}:\e[m #{value}"
|
17
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# description: Show information of discorb.
|
4
|
+
|
5
|
+
puts " disco\e[31mrb\e[m - A new Discord API wrapper in Ruby. \n\n"
|
6
|
+
|
7
|
+
informations = {
|
8
|
+
"GitHub" => "https://github.com/discorb-lib/discorb",
|
9
|
+
"Documentation" => "https://discorb-lib.github.io",
|
10
|
+
"RubyGems" => "https://rubygems.org/gems/discorb",
|
11
|
+
"Changelog" => "https://discorb-lib.github.io/file.Changelog.html",
|
12
|
+
"License" => "MIT License"
|
13
|
+
}
|
14
|
+
|
15
|
+
informations.each do |key, value|
|
16
|
+
puts "\e[90m#{key.rjust(informations.keys.map(&:length).max)}:\e[m #{value}"
|
17
|
+
end
|
data/lib/discorb/exe/irb.rb
CHANGED
@@ -1,67 +1,72 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# description: Connect to discord and start IRB.
|
5
|
-
|
6
|
-
require "io/console"
|
7
|
-
require "discorb"
|
8
|
-
require "optparse"
|
9
|
-
|
10
|
-
intents_value = Discorb::Intents.all.value
|
11
|
-
token_file = "token"
|
12
|
-
|
13
|
-
opt = OptionParser.new <<~BANNER
|
14
|
-
This command will start an interactive Ruby shell with connected client.
|
15
|
-
|
16
|
-
Usage: discorb irb [options]
|
17
|
-
BANNER
|
18
|
-
opt.on("-i", "--intents", "intents to use, default to all")
|
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
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# description: Connect to discord and start IRB.
|
5
|
+
|
6
|
+
require "io/console"
|
7
|
+
require "discorb"
|
8
|
+
require "optparse"
|
9
|
+
|
10
|
+
intents_value = Discorb::Intents.all.value
|
11
|
+
token_file = "token"
|
12
|
+
|
13
|
+
opt = OptionParser.new <<~BANNER
|
14
|
+
This command will start an interactive Ruby shell with connected client.
|
15
|
+
|
16
|
+
Usage: discorb irb [options]
|
17
|
+
BANNER
|
18
|
+
opt.on("-i", "--intents", "intents to use, default to all") do |v|
|
19
|
+
intents_value = v
|
20
|
+
end
|
21
|
+
opt.on("-t", "--token-file", "token file to load, default to \"token\"") do |v|
|
22
|
+
token_file = v
|
23
|
+
end
|
24
|
+
opt.parse!(ARGV)
|
25
|
+
|
26
|
+
client =
|
27
|
+
Discorb::Client.new(intents: Discorb::Intents.from_value(intents_value))
|
28
|
+
$messages = []
|
29
|
+
|
30
|
+
client.on :standby do
|
31
|
+
puts "\e[96mLogged in as #{client.user}\e[m"
|
32
|
+
|
33
|
+
def message
|
34
|
+
$messages.last
|
35
|
+
end
|
36
|
+
|
37
|
+
def dirb_help
|
38
|
+
puts <<~MESSAGE
|
39
|
+
\e[96mDiscord-IRB\e[m
|
40
|
+
This is a debug client for Discord.
|
41
|
+
\e[90mmessage\e[m to get latest message.
|
42
|
+
|
43
|
+
\e[36mhttps://discorb-lib.github.io/#{Discorb::VERSION}/file.irb.html\e[m for more information.
|
44
|
+
MESSAGE
|
45
|
+
end
|
46
|
+
|
47
|
+
puts <<~FIRST_MESSAGE
|
48
|
+
Running on \e[31mRuby #{RUBY_VERSION}\e[m, disco\e[31mrb #{Discorb::VERSION}\e[m
|
49
|
+
Type \e[90mdirb_help\e[m to help.
|
50
|
+
FIRST_MESSAGE
|
51
|
+
|
52
|
+
binding.irb # rubocop:disable Lint/Debugger
|
53
|
+
|
54
|
+
client.close!
|
55
|
+
end
|
56
|
+
|
57
|
+
client.on :message do |message|
|
58
|
+
$messages << message
|
59
|
+
end
|
60
|
+
|
61
|
+
token = ENV.fetch("DISCORD_BOT_TOKEN", nil) || ENV.fetch("DISCORD_TOKEN", nil)
|
62
|
+
if token.nil?
|
63
|
+
if File.exist?(token_file)
|
64
|
+
token = File.read(token_file)
|
65
|
+
else
|
66
|
+
print "\e[90mToken?\e[m : "
|
67
|
+
token = $stdin.noecho(&:gets).chomp
|
68
|
+
puts
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
client.run token
|