discorb 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +1 -3
- data/.github/workflows/validate.yml +21 -0
- data/Changelog.md +10 -0
- data/Gemfile +6 -0
- data/Rakefile +210 -98
- data/Steepfile +28 -0
- data/docs/events.md +42 -6
- data/docs/tutorial.md +7 -7
- data/docs/voice_events.md +2 -2
- data/examples/commands/message.rb +12 -7
- data/examples/commands/permission.rb +2 -1
- data/examples/commands/slash.rb +23 -19
- data/examples/commands/user.rb +15 -12
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +4 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +1 -0
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +16 -5
- data/examples/simple/shard.rb +2 -1
- data/examples/simple/wait_for_message.rb +3 -0
- data/exe/discorb +3 -3
- data/lib/discorb/allowed_mentions.rb +1 -1
- data/lib/discorb/app_command/command.rb +12 -13
- data/lib/discorb/app_command/handler.rb +20 -6
- data/lib/discorb/audit_logs.rb +6 -2
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/guild.rb +2 -1
- data/lib/discorb/channel/stage.rb +1 -1
- data/lib/discorb/channel/text.rb +11 -20
- data/lib/discorb/channel/thread.rb +15 -11
- data/lib/discorb/client.rb +12 -10
- data/lib/discorb/color.rb +37 -60
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -3
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/exe/about.rb +1 -1
- data/lib/discorb/exe/new.rb +1 -5
- data/lib/discorb/extension.rb +0 -4
- data/lib/discorb/flag.rb +2 -2
- data/lib/discorb/gateway.rb +21 -582
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +136 -17
- data/lib/discorb/guild_template.rb +1 -1
- data/lib/discorb/http.rb +47 -25
- data/lib/discorb/intents.rb +27 -18
- data/lib/discorb/interaction/command.rb +14 -10
- data/lib/discorb/interaction/response.rb +74 -14
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +13 -11
- data/lib/discorb/message_meta.rb +2 -3
- data/lib/discorb/modules.rb +3 -2
- data/lib/discorb/presence.rb +4 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +1 -1
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +5 -5
- data/lib/discorb/webhook.rb +15 -6
- data/lib/discorb.rb +2 -2
- data/rbs_collection.lock.yaml +88 -96
- data/rbs_collection.yaml +21 -17
- data/sig/async.rbs +11 -5
- data/sig/discorb/activity.rbs +23 -0
- data/sig/discorb/allowed_mentions.rbs +44 -0
- data/sig/discorb/app_command/base.rbs +282 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +142 -0
- data/sig/discorb/asset.rbs +32 -0
- data/sig/discorb/attachment.rbs +91 -0
- data/sig/discorb/audit_log.rbs +231 -0
- data/sig/discorb/automod.rbs +128 -0
- data/sig/discorb/avatar.rbs +26 -0
- data/sig/discorb/channel/base.rbs +179 -0
- data/sig/discorb/channel/category.rbs +56 -0
- data/sig/discorb/channel/container.rbs +29 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +77 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +185 -0
- data/sig/discorb/channel/voice.rbs +41 -0
- data/sig/discorb/client.rbs +2495 -0
- data/sig/discorb/color.rbs +142 -0
- data/sig/discorb/component/base.rbs +28 -0
- data/sig/discorb/component/button.rbs +65 -0
- data/sig/discorb/component/select_menu.rbs +107 -0
- data/sig/discorb/component/text_input.rbs +69 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +90 -0
- data/sig/discorb/dictionary.rbs +85 -0
- data/sig/discorb/discord_model.rbs +15 -0
- data/sig/discorb/embed.rbs +279 -0
- data/sig/discorb/emoji.rbs +13 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +27 -0
- data/sig/discorb/extension.rbs +1734 -0
- data/sig/discorb/flag.rbs +72 -0
- data/sig/discorb/gateway.rbs +481 -0
- data/sig/discorb/guild.rbs +870 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +147 -0
- data/sig/discorb/image.rbs +20 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +97 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +66 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +140 -0
- data/sig/discorb/interaction/modal.rbs +50 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +187 -0
- data/sig/discorb/message.rbs +469 -0
- data/sig/discorb/messageable.rbs +153 -0
- data/sig/discorb/partial_emoji.rbs +35 -0
- data/sig/discorb/permissions.rbs +149 -0
- data/sig/discorb/presence.rbs +237 -0
- data/sig/discorb/reaction.rbs +33 -0
- data/sig/discorb/role.rbs +145 -0
- data/sig/discorb/scheduled_event.rbs +148 -0
- data/sig/discorb/shard.rbs +62 -0
- data/sig/discorb/snowflake.rbs +56 -0
- data/sig/discorb/stage_instance.rbs +63 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +49 -0
- data/sig/discorb/user.rbs +93 -0
- data/sig/discorb/utils.rbs +8 -0
- data/sig/discorb/voice_region.rbs +30 -0
- data/sig/discorb/voice_state.rbs +71 -0
- data/sig/discorb/webhook.rbs +327 -0
- data/sig/discorb/welcome_screen.rbs +78 -0
- data/sig/discorb.rbs +5 -8661
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- metadata +80 -3
data/examples/commands/slash.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
|
|
4
5
|
client = Discorb::Client.new
|
|
@@ -16,27 +17,30 @@ client.once :standby do
|
|
|
16
17
|
puts "Logged in as #{client.user}"
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
client.slash(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
client.slash(
|
|
21
|
+
{
|
|
22
|
+
default: "greet",
|
|
23
|
+
ja: "挨拶",
|
|
24
|
+
}, {
|
|
25
|
+
default: "Bot greets. Cute OwO",
|
|
26
|
+
ja: "Botが挨拶します。かわいいね",
|
|
27
|
+
}, {
|
|
28
|
+
"name" => {
|
|
29
|
+
name_localizations: {
|
|
30
|
+
ja: "名前",
|
|
31
|
+
},
|
|
32
|
+
description: {
|
|
33
|
+
default: "The name to greet.",
|
|
34
|
+
ja: "挨拶する人の名前。",
|
|
35
|
+
},
|
|
36
|
+
type: :string,
|
|
37
|
+
optional: true,
|
|
33
38
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
}) do |interaction, name|
|
|
39
|
+
}
|
|
40
|
+
) do |interaction, name|
|
|
38
41
|
interaction.post(
|
|
39
|
-
format((localizations[:localized][:text][interaction.locale] || localizations[:localized][:text][:en]),
|
|
42
|
+
format((localizations[:localized][:text][interaction.locale] || localizations[:localized][:text][:en]),
|
|
43
|
+
name || interaction.user.to_s),
|
|
40
44
|
ephemeral: true,
|
|
41
45
|
)
|
|
42
46
|
end
|
data/examples/commands/user.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
|
|
4
5
|
localizations = {
|
|
@@ -24,26 +25,28 @@ client.once :standby do
|
|
|
24
25
|
puts "Logged in as #{client.user}"
|
|
25
26
|
end
|
|
26
27
|
|
|
27
|
-
client.user_command(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
client.user_command(
|
|
29
|
+
{
|
|
30
|
+
default: "info",
|
|
31
|
+
ja: "詳細",
|
|
32
|
+
}
|
|
33
|
+
) do |interaction, user|
|
|
31
34
|
field_name = localizations[:info][:fields][interaction.locale] || localizations[:info][:fields][:en]
|
|
32
35
|
interaction.post(
|
|
33
36
|
embed: Discorb::Embed.new(
|
|
34
|
-
format((localizations[:info][:title][interaction.locale] || localizations[:info][:title][:en]),
|
|
37
|
+
format((localizations[:info][:title][interaction.locale] || localizations[:info][:title][:en]),
|
|
38
|
+
user.to_s),
|
|
35
39
|
fields: [
|
|
36
|
-
Discorb::Embed::Field.new(field_name[0],
|
|
37
|
-
Discorb::Embed::Field.new(field_name[1],
|
|
40
|
+
Discorb::Embed::Field.new(field_name[0], user.to_s),
|
|
41
|
+
Discorb::Embed::Field.new(field_name[1], user.id),
|
|
38
42
|
Discorb::Embed::Field.new(
|
|
39
43
|
field_name[2],
|
|
40
|
-
(localizations[:info][:yn][
|
|
44
|
+
(localizations[:info][:yn][locale] || localizations[:info][:yn][:en])[user.bot? ? 0 : 1]
|
|
41
45
|
),
|
|
42
|
-
Discorb::Embed::Field.new(field_name[3],
|
|
43
|
-
Discorb::Embed::Field.new(field_name[4],
|
|
46
|
+
Discorb::Embed::Field.new(field_name[3], user.joined_at.to_df("F")),
|
|
47
|
+
Discorb::Embed::Field.new(field_name[4], user.created_at.to_df("F")),
|
|
44
48
|
],
|
|
45
|
-
thumbnail:
|
|
46
|
-
|
|
49
|
+
thumbnail: user.avatar&.url,
|
|
47
50
|
), ephemeral: true,
|
|
48
51
|
)
|
|
49
52
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
|
|
4
5
|
client = Discorb::Client.new
|
|
@@ -36,7 +37,7 @@ end
|
|
|
36
37
|
client.on :button_click do |response|
|
|
37
38
|
if response.custom_id.start_with?("auth:")
|
|
38
39
|
id = response.custom_id.delete_prefix("auth:")
|
|
39
|
-
response.
|
|
40
|
+
response.user.add_role(id).wait
|
|
40
41
|
response.post("You got your role!\nHere's your role: <@&#{id}>", ephemeral: true)
|
|
41
42
|
end
|
|
42
43
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
|
|
4
5
|
client = Discorb::Client.new
|
|
@@ -41,7 +42,9 @@ client.on :message do |message|
|
|
|
41
42
|
next if message.author.bot?
|
|
42
43
|
next unless message.content == "!ruby"
|
|
43
44
|
|
|
44
|
-
options = SECTIONS.map.with_index
|
|
45
|
+
options = SECTIONS.map.with_index do |section, i|
|
|
46
|
+
Discorb::SelectMenu::Option.new("Page #{i + 1}", "sections:#{i}", description: section[0])
|
|
47
|
+
end
|
|
45
48
|
message.channel.post(
|
|
46
49
|
"Select a section", components: [Discorb::SelectMenu.new("sections", options)],
|
|
47
50
|
)
|
data/examples/extension/main.rb
CHANGED
data/examples/simple/eval.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
intents = Discorb::Intents.new
|
|
4
5
|
intents.members = true
|
|
6
|
+
|
|
5
7
|
client = Discorb::Client.new(intents: intents)
|
|
6
8
|
|
|
7
9
|
def convert_role(guild, string)
|
|
@@ -15,6 +17,8 @@ client.once :standby do
|
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
client.on :reaction_add do |event|
|
|
20
|
+
next unless event.guild
|
|
21
|
+
next unless event.member
|
|
18
22
|
next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
|
|
19
23
|
next if event.member.bot?
|
|
20
24
|
|
|
@@ -31,6 +35,7 @@ end
|
|
|
31
35
|
|
|
32
36
|
client.on :reaction_remove do |event|
|
|
33
37
|
next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
|
|
38
|
+
next unless event.member
|
|
34
39
|
next if event.member.bot?
|
|
35
40
|
|
|
36
41
|
msg = event.fetch_message.wait
|
|
@@ -49,15 +54,21 @@ client.on :message do |message|
|
|
|
49
54
|
next if message.author.bot?
|
|
50
55
|
|
|
51
56
|
message.reply("Too many roles.") if message.content.split.length > 10
|
|
52
|
-
roles = message.content.delete_prefix("/rp ").split.map.with_index
|
|
57
|
+
roles = message.content.delete_prefix("/rp ").split.map.with_index do |raw_role, index|
|
|
58
|
+
[index, convert_role(message.guild, raw_role), raw_role]
|
|
59
|
+
end
|
|
53
60
|
if (convert_fails = roles.filter { |r| r[1].nil? }).length.positive?
|
|
54
61
|
message.reply("#{convert_fails.map { |r| r[2] }.join(", ")} is not a role.")
|
|
55
62
|
next
|
|
56
63
|
end
|
|
57
|
-
rp_msg = message.channel.post(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
rp_msg = message.channel.post(
|
|
65
|
+
embed: Discorb::Embed.new(
|
|
66
|
+
"Role panel",
|
|
67
|
+
roles.map.with_index(1) do |r, index|
|
|
68
|
+
"#{index}\ufe0f\u20e3#{r[1].mention}"
|
|
69
|
+
end.join("\n")
|
|
70
|
+
),
|
|
71
|
+
).wait
|
|
61
72
|
1.upto(roles.length).each do |i|
|
|
62
73
|
rp_msg.add_reaction(Discorb::UnicodeEmoji["#{i}\ufe0f\u20e3"]).wait
|
|
63
74
|
end
|
data/examples/simple/shard.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require "discorb"
|
|
3
4
|
|
|
4
5
|
client = Discorb::Client.new
|
|
@@ -12,6 +13,8 @@ client.on :message do |message|
|
|
|
12
13
|
next unless message.content == "!quiz"
|
|
13
14
|
|
|
14
15
|
operator = %i[+ - *].sample
|
|
16
|
+
next unless operator
|
|
17
|
+
|
|
15
18
|
num1 = rand(1..10)
|
|
16
19
|
num2 = rand(1..10)
|
|
17
20
|
|
data/exe/discorb
CHANGED
|
@@ -40,8 +40,8 @@ require "bundler/setup" if options[:bundler]
|
|
|
40
40
|
|
|
41
41
|
command = ARGV.shift
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
require "discorb/exe/#{command}"
|
|
45
|
-
rescue LoadError
|
|
43
|
+
unless $LOAD_PATH.resolve_feature_path("discorb/exe/#{command}.rb")
|
|
46
44
|
warn "Unknown subcommand: #{command}"
|
|
45
|
+
abort
|
|
47
46
|
end
|
|
47
|
+
require "discorb/exe/#{command}"
|
|
@@ -23,7 +23,7 @@ module Discorb
|
|
|
23
23
|
# @param [Boolean] replied_user Whether to ping the user that sent the message to reply.
|
|
24
24
|
#
|
|
25
25
|
def initialize(everyone: nil, roles: nil, users: nil, replied_user: nil)
|
|
26
|
-
@everyone = everyone
|
|
26
|
+
@everyone = !everyone.nil?
|
|
27
27
|
@roles = roles
|
|
28
28
|
@users = users
|
|
29
29
|
@replied_user = replied_user
|
|
@@ -7,7 +7,7 @@ module Discorb
|
|
|
7
7
|
# @abstract
|
|
8
8
|
#
|
|
9
9
|
class Command < DiscordModel
|
|
10
|
-
# @return [Hash{
|
|
10
|
+
# @return [Hash{String => String}] The name of the command.
|
|
11
11
|
attr_reader :name
|
|
12
12
|
# @return [Array<#to_s>] The guild ids that the command is enabled in.
|
|
13
13
|
attr_reader :guild_ids
|
|
@@ -35,13 +35,13 @@ module Discorb
|
|
|
35
35
|
# @private
|
|
36
36
|
#
|
|
37
37
|
# @param [String, Hash{Symbol => String}] name The name of the command.
|
|
38
|
-
# @param [Array<#to_s
|
|
38
|
+
# @param [Array<#to_s>, false, nil] guild_ids The guild ids that the command is enabled in.
|
|
39
39
|
# @param [Proc] block The block of the command.
|
|
40
|
-
# @param [
|
|
40
|
+
# @param [Integer] type The type of the command.
|
|
41
41
|
# @param [Boolean] dm_permission Whether the command is enabled in DMs.
|
|
42
42
|
# @param [Discorb::Permission] default_permission The default permission of the command.
|
|
43
43
|
#
|
|
44
|
-
def initialize(name, guild_ids, block, type, dm_permission =
|
|
44
|
+
def initialize(name, guild_ids, block, type, dm_permission = true, default_permission = nil) # rubocop:disable Style/OptionalBooleanParameter
|
|
45
45
|
@name = name.is_a?(String) ? { "default" => name } : ApplicationCommand.modify_localization_hash(name)
|
|
46
46
|
@guild_ids = guild_ids&.map(&:to_s)
|
|
47
47
|
@block = block
|
|
@@ -100,7 +100,7 @@ module Discorb
|
|
|
100
100
|
# @param [Hash{String => Hash}] options The options of the command.
|
|
101
101
|
# @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
|
|
102
102
|
# @param [Proc] block The block of the command.
|
|
103
|
-
# @param [
|
|
103
|
+
# @param [Integer] type The type of the command.
|
|
104
104
|
# @param [Discorb::ApplicationCommand::Command, nil] parent The parent command.
|
|
105
105
|
# @param [Boolean] dm_permission Whether the command is enabled in DMs.
|
|
106
106
|
# @param [Discorb::Permission] default_permission The default permission of the command.
|
|
@@ -215,7 +215,7 @@ module Discorb
|
|
|
215
215
|
class GroupCommand < Command
|
|
216
216
|
# @return [Array<Discorb::ApplicationCommand::Command>] The subcommands of the command.
|
|
217
217
|
attr_reader :commands
|
|
218
|
-
# @return [String] The description of the command.
|
|
218
|
+
# @return [Hash{String => String}] The description of the command.
|
|
219
219
|
attr_reader :description
|
|
220
220
|
|
|
221
221
|
#
|
|
@@ -225,13 +225,12 @@ module Discorb
|
|
|
225
225
|
# @param [String, Hash{Symbol => String}] name The name of the command.
|
|
226
226
|
# @param [String, Hash{Symbol => String}] description The description of the command.
|
|
227
227
|
# @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
|
|
228
|
-
# @param [:chat_input, :user, :message] type The type of the command.
|
|
229
228
|
# @param [Discorb::Client] client The client of the command.
|
|
230
229
|
# @param [Boolean] dm_permission Whether the command is enabled in DMs.
|
|
231
230
|
# @param [Discorb::Permission] default_permission The default permission of the command.
|
|
232
231
|
#
|
|
233
|
-
def initialize(name, description, guild_ids,
|
|
234
|
-
super(name, guild_ids, block,
|
|
232
|
+
def initialize(name, description, guild_ids, client, dm_permission, default_permission)
|
|
233
|
+
super(name, guild_ids, block, 1, dm_permission, default_permission)
|
|
235
234
|
@description = if description.is_a?(String)
|
|
236
235
|
{
|
|
237
236
|
"default" => description,
|
|
@@ -279,9 +278,9 @@ module Discorb
|
|
|
279
278
|
#
|
|
280
279
|
# @see file:docs/application_command.md Application Commands
|
|
281
280
|
#
|
|
282
|
-
def group(command_name, description
|
|
283
|
-
command = Discorb::ApplicationCommand::Command::SubcommandGroup.new(command_name, description,
|
|
284
|
-
command
|
|
281
|
+
def group(command_name, description)
|
|
282
|
+
command = Discorb::ApplicationCommand::Command::SubcommandGroup.new(command_name, description, self, @client)
|
|
283
|
+
yield command if block_given?
|
|
285
284
|
@commands << command
|
|
286
285
|
command
|
|
287
286
|
end
|
|
@@ -365,7 +364,7 @@ module Discorb
|
|
|
365
364
|
# @param [Discorb::ApplicationCommand::Command::GroupCommand] parent The parent command.
|
|
366
365
|
# @param [Discorb::Client] client The client.
|
|
367
366
|
def initialize(name, description, parent, client)
|
|
368
|
-
super(name, description, [],
|
|
367
|
+
super(name, description, [], client, nil, nil)
|
|
369
368
|
|
|
370
369
|
@commands = []
|
|
371
370
|
@parent = parent
|
|
@@ -6,6 +6,8 @@ module Discorb
|
|
|
6
6
|
# Module to handle application commands.
|
|
7
7
|
#
|
|
8
8
|
module Handler
|
|
9
|
+
# @type instance: Discorb::Client
|
|
10
|
+
|
|
9
11
|
#
|
|
10
12
|
# Add new top-level command.
|
|
11
13
|
#
|
|
@@ -96,14 +98,20 @@ module Discorb
|
|
|
96
98
|
# @see file:docs/application_command.md Application Commands
|
|
97
99
|
# @see file:docs/cli/setup.md CLI: setup
|
|
98
100
|
#
|
|
99
|
-
def slash_group(command_name, description, guild_ids: nil, dm_permission: true, default_permission: nil
|
|
101
|
+
def slash_group(command_name, description, guild_ids: nil, dm_permission: true, default_permission: nil)
|
|
100
102
|
command_name = { default: command_name } if command_name.is_a?(String)
|
|
101
103
|
description = { default: description } if description.is_a?(String)
|
|
102
104
|
command_name = ApplicationCommand.modify_localization_hash(command_name)
|
|
103
105
|
description = ApplicationCommand.modify_localization_hash(description)
|
|
104
|
-
command = Discorb::ApplicationCommand::Command::GroupCommand.new(
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
command = Discorb::ApplicationCommand::Command::GroupCommand.new(
|
|
107
|
+
command_name,
|
|
108
|
+
description,
|
|
109
|
+
guild_ids,
|
|
110
|
+
self,
|
|
111
|
+
dm_permission,
|
|
112
|
+
default_permission
|
|
113
|
+
)
|
|
114
|
+
yield command if block_given?
|
|
107
115
|
@commands << command
|
|
108
116
|
command
|
|
109
117
|
end
|
|
@@ -126,8 +134,14 @@ module Discorb
|
|
|
126
134
|
def message_command(command_name, guild_ids: nil, dm_permission: true, default_permission: nil, &block)
|
|
127
135
|
command_name = { default: command_name } if command_name.is_a?(String)
|
|
128
136
|
command_name = ApplicationCommand.modify_localization_hash(command_name)
|
|
129
|
-
command = Discorb::ApplicationCommand::Command.new(
|
|
130
|
-
|
|
137
|
+
command = Discorb::ApplicationCommand::Command.new(
|
|
138
|
+
command_name,
|
|
139
|
+
guild_ids,
|
|
140
|
+
block,
|
|
141
|
+
3,
|
|
142
|
+
dm_permission,
|
|
143
|
+
default_permission
|
|
144
|
+
)
|
|
131
145
|
@commands << command
|
|
132
146
|
command
|
|
133
147
|
end
|
data/lib/discorb/audit_logs.rb
CHANGED
|
@@ -109,7 +109,7 @@ module Discorb
|
|
|
109
109
|
attr_reader :type
|
|
110
110
|
# @return [Discorb::AuditLog::Entry::Changes] The changes in this entry.
|
|
111
111
|
attr_reader :changes
|
|
112
|
-
# @return [Discorb::Channel, Discorb::Role, Discorb::Member, Discorb::Guild, Discorb::Message]
|
|
112
|
+
# @return [Discorb::Channel, Discorb::Role, Discorb::Member, Discorb::Guild, Discorb::Message, Discorb::Snowflake]
|
|
113
113
|
# The target of the entry.
|
|
114
114
|
attr_reader :target
|
|
115
115
|
# @return [Hash{Symbol => Object}] The optional data for this entry.
|
|
@@ -172,6 +172,10 @@ module Discorb
|
|
|
172
172
|
111 => :thread_update,
|
|
173
173
|
112 => :thread_delete,
|
|
174
174
|
121 => :application_command_permission_update,
|
|
175
|
+
140 => :automod_rule_create,
|
|
176
|
+
141 => :automod_rule_update,
|
|
177
|
+
142 => :automod_rule_delete,
|
|
178
|
+
143 => :automod_block_message,
|
|
175
179
|
}.freeze
|
|
176
180
|
|
|
177
181
|
#
|
|
@@ -197,7 +201,7 @@ module Discorb
|
|
|
197
201
|
@id = Snowflake.new(data[:id])
|
|
198
202
|
@user_id = Snowflake.new(data[:user_id])
|
|
199
203
|
@target_id = Snowflake.new(data[:target_id])
|
|
200
|
-
@type = EVENTS[data[:action_type]]
|
|
204
|
+
@type = EVENTS[data[:action_type]] || :unknown
|
|
201
205
|
@target = CONVERTERS[@type.to_s.split("_")[0].to_sym]&.call(client, @target_id, @gui)
|
|
202
206
|
@target ||= Snowflake.new(data[:target_id])
|
|
203
207
|
@changes = data[:changes] && Changes.new(data[:changes])
|