discorb 0.17.1 → 0.18.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/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/lib/discorb/embed.rb
CHANGED
@@ -35,7 +35,7 @@ module Discorb
|
|
35
35
|
#
|
36
36
|
# @param [String] title The title of embed.
|
37
37
|
# @param [String] description The description of embed.
|
38
|
-
# @param [Discorb::Color] color The color of embed.
|
38
|
+
# @param [Discorb::Color, Integer] color The color of embed.
|
39
39
|
# @param [String] url The url of embed.
|
40
40
|
# @param [Time] timestamp The timestamp of embed.
|
41
41
|
# @param [Discorb::Embed::Author] author The author field of embed.
|
@@ -60,13 +60,13 @@ module Discorb
|
|
60
60
|
@description = description
|
61
61
|
@url = url
|
62
62
|
@timestamp = timestamp
|
63
|
-
@color = color
|
63
|
+
@color = color && (color.is_a?(Color) ? color : Color.new(color))
|
64
64
|
@author = author
|
65
65
|
@fields = fields || []
|
66
66
|
@footer = footer
|
67
67
|
@image = image && (image.is_a?(String) ? Image.new(image) : image)
|
68
68
|
@thumbnail = thumbnail && (thumbnail.is_a?(String) ? Thumbnail.new(thumbnail) : thumbnail)
|
69
|
-
@type =
|
69
|
+
@type = :rich
|
70
70
|
end
|
71
71
|
|
72
72
|
#
|
@@ -113,6 +113,7 @@ module Discorb
|
|
113
113
|
# @return [Hash] Converted embed.
|
114
114
|
#
|
115
115
|
def to_hash
|
116
|
+
# @type var ret: Hash[untyped, untyped]
|
116
117
|
ret = { type: "rich" }
|
117
118
|
ret[:title] = @title if @title
|
118
119
|
ret[:description] = @description if @description
|
data/lib/discorb/emoji.rb
CHANGED
@@ -29,7 +29,7 @@ module Discorb
|
|
29
29
|
attr_reader :roles
|
30
30
|
# @return [Discorb::User] The user that created this emoji.
|
31
31
|
attr_reader :user
|
32
|
-
# @return [
|
32
|
+
# @return [Discorb::Guild] The guild that owns this emoji.
|
33
33
|
attr_reader :guild
|
34
34
|
# @return [Boolean] whether the emoji is managed by integration (ex: Twitch).
|
35
35
|
attr_reader :managed
|
@@ -247,7 +247,7 @@ module Discorb
|
|
247
247
|
end
|
248
248
|
raise ArgumentError, "Invalid skin tone: #{tone}" unless @skin_tone
|
249
249
|
|
250
|
-
@name = EmojiTable::UNICODE_TO_DISCORD[name2]
|
250
|
+
@name = EmojiTable::UNICODE_TO_DISCORD[name2].first
|
251
251
|
@value = name
|
252
252
|
else
|
253
253
|
raise ArgumentError, "No such emoji: #{name}"
|
data/lib/discorb/exe/about.rb
CHANGED
data/lib/discorb/exe/new.rb
CHANGED
@@ -220,11 +220,7 @@ def git_init
|
|
220
220
|
create_file(".gitignore")
|
221
221
|
iputs "Initializing git repository..."
|
222
222
|
system "git init", chdir: $path
|
223
|
-
|
224
|
-
system "git commit -m \"Initial commit\"", chdir: $path
|
225
|
-
sputs "Initialized repository, use " \
|
226
|
-
"\e[32mgit commit --amend -m '...'\e[92m" \
|
227
|
-
" to change commit message of initial commit.\n"
|
223
|
+
sputs "Initialized repository.\n"
|
228
224
|
end
|
229
225
|
|
230
226
|
# @private
|
data/lib/discorb/extension.rb
CHANGED
@@ -45,8 +45,6 @@ module Discorb
|
|
45
45
|
# @param [Symbol] id The id of the event. Used to delete the event.
|
46
46
|
# @param [Hash] metadata Other metadata.
|
47
47
|
#
|
48
|
-
# @return [Discorb::EventHandler] The event.
|
49
|
-
#
|
50
48
|
def event(event_name, id: nil, **metadata, &block)
|
51
49
|
raise ArgumentError, "Event name must be a symbol" unless event_name.is_a?(Symbol)
|
52
50
|
raise ArgumentError, "block must be given" unless block_given?
|
@@ -64,8 +62,6 @@ module Discorb
|
|
64
62
|
# @param [Hash] metadata Other metadata.
|
65
63
|
# @param [Proc] block The block to execute when the event is triggered.
|
66
64
|
#
|
67
|
-
# @return [Discorb::EventHandler] The event.
|
68
|
-
#
|
69
65
|
def once_event(event_name, id: nil, **metadata, &block)
|
70
66
|
event(event_name, id: id, once: true, **metadata, &block)
|
71
67
|
end
|
data/lib/discorb/flag.rb
CHANGED
@@ -21,7 +21,7 @@ module Discorb
|
|
21
21
|
def initialize(value)
|
22
22
|
@value = value
|
23
23
|
@values = {}
|
24
|
-
self.class.bits.
|
24
|
+
self.class.bits.each do |bn, bv|
|
25
25
|
@values[bn] = value & (1 << bv) != 0
|
26
26
|
end
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module Discorb
|
|
29
29
|
#
|
30
30
|
# Returns the value of the flag.
|
31
31
|
#
|
32
|
-
def method_missing(name,
|
32
|
+
def method_missing(name, *_args, **_kwargs)
|
33
33
|
if @values.key?(name.to_s.delete_suffix("?").to_sym)
|
34
34
|
@values[name.to_s.delete_suffix("?").to_sym]
|
35
35
|
else
|