discorb 0.16.0 → 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/.gitattributes +1 -0
- data/.github/workflows/build_main.yml +2 -2
- data/.github/workflows/build_version.yml +1 -1
- data/.github/workflows/codeql-analysis.yml +1 -1
- data/.github/workflows/lint-push.yml +3 -5
- data/.github/workflows/lint.yml +2 -4
- data/.github/workflows/spec.yml +33 -0
- data/.github/workflows/validate.yml +21 -0
- data/.gitignore +2 -0
- data/.lefthook/commit-msg/validator.rb +5 -0
- data/.rspec +2 -0
- data/.rspec_parallel +2 -0
- data/.rubocop.yml +43 -6
- data/Changelog.md +30 -1
- data/Gemfile +20 -8
- data/Rakefile +226 -98
- data/Steepfile +28 -0
- data/bin/console +3 -3
- data/docs/Examples.md +1 -1
- data/docs/application_command.md +156 -47
- data/docs/cli/irb.md +2 -2
- data/docs/cli/new.md +14 -9
- data/docs/cli/run.md +7 -11
- data/docs/cli.md +17 -10
- data/docs/events.md +247 -213
- data/docs/extension.md +1 -2
- data/docs/faq.md +0 -1
- data/docs/tutorial.md +18 -18
- data/docs/voice_events.md +106 -106
- data/examples/commands/message.rb +68 -0
- data/examples/commands/permission.rb +19 -0
- data/examples/commands/slash.rb +48 -0
- data/examples/commands/user.rb +54 -0
- data/examples/components/authorization_button.rb +4 -3
- data/examples/components/select_menu.rb +6 -3
- data/examples/extension/main.rb +2 -1
- data/examples/extension/message_expander.rb +6 -2
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +3 -2
- data/examples/simple/ping_pong.rb +2 -1
- data/examples/simple/rolepanel.rb +17 -6
- data/examples/simple/shard.rb +3 -2
- data/examples/simple/wait_for_message.rb +4 -1
- data/exe/discorb +33 -18
- data/lefthook.yml +45 -0
- data/lib/discorb/allowed_mentions.rb +2 -1
- data/lib/discorb/app_command/command.rb +130 -72
- data/lib/discorb/app_command/common.rb +25 -0
- data/lib/discorb/app_command/handler.rb +130 -33
- data/lib/discorb/app_command.rb +2 -1
- data/lib/discorb/application.rb +1 -0
- data/lib/discorb/asset.rb +1 -2
- data/lib/discorb/attachment.rb +1 -1
- data/lib/discorb/audit_logs.rb +19 -10
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/base.rb +108 -0
- data/lib/discorb/channel/category.rb +32 -0
- data/lib/discorb/channel/container.rb +44 -0
- data/lib/discorb/channel/dm.rb +28 -0
- data/lib/discorb/channel/guild.rb +246 -0
- data/lib/discorb/channel/stage.rb +140 -0
- data/lib/discorb/channel/text.rb +336 -0
- data/lib/discorb/channel/thread.rb +325 -0
- data/lib/discorb/channel/voice.rb +79 -0
- data/lib/discorb/channel.rb +2 -1165
- data/lib/discorb/client.rb +50 -36
- data/lib/discorb/color.rb +37 -60
- data/lib/discorb/common.rb +2 -1
- data/lib/discorb/components/button.rb +2 -1
- data/lib/discorb/components/select_menu.rb +4 -2
- data/lib/discorb/components/text_input.rb +12 -2
- data/lib/discorb/components.rb +1 -1
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +26 -10
- data/lib/discorb/emoji.rb +31 -4
- data/lib/discorb/emoji_table.rb +4969 -3
- data/lib/discorb/event.rb +29 -4
- data/lib/discorb/exe/about.rb +2 -1
- data/lib/discorb/exe/irb.rb +2 -4
- data/lib/discorb/exe/new.rb +89 -26
- data/lib/discorb/exe/run.rb +8 -22
- data/lib/discorb/exe/setup.rb +25 -12
- data/lib/discorb/exe/show.rb +4 -3
- data/lib/discorb/extend.rb +1 -0
- data/lib/discorb/extension.rb +6 -7
- data/lib/discorb/flag.rb +13 -2
- data/lib/discorb/gateway.rb +79 -589
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +318 -67
- data/lib/discorb/guild_template.rb +11 -5
- data/lib/discorb/http.rb +53 -24
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +28 -19
- data/lib/discorb/interaction/autocomplete.rb +28 -16
- data/lib/discorb/interaction/command.rb +42 -14
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +0 -1
- data/lib/discorb/interaction/response.rb +125 -26
- data/lib/discorb/interaction/root.rb +13 -13
- data/lib/discorb/interaction.rb +1 -0
- data/lib/discorb/invite.rb +5 -2
- data/lib/discorb/member.rb +28 -8
- data/lib/discorb/message.rb +60 -25
- data/lib/discorb/message_meta.rb +3 -3
- data/lib/discorb/modules.rb +59 -16
- data/lib/discorb/presence.rb +2 -0
- data/lib/discorb/rate_limit.rb +7 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +20 -5
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +9 -8
- data/lib/discorb/user.rb +4 -3
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +6 -2
- data/lib/discorb/webhook.rb +64 -31
- data/lib/discorb.rb +7 -5
- data/po/yard.pot +20 -20
- data/rbs_collection.lock.yaml +88 -0
- data/rbs_collection.yaml +21 -0
- data/sig/async.rbs +11 -0
- 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 +6 -7230
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- data/template-replace/files/css/common.css +4 -0
- metadata +102 -6
- data/examples/commands/bookmarker.rb +0 -42
- data/examples/commands/hello.rb +0 -10
- data/examples/commands/inspect.rb +0 -25
@@ -0,0 +1,140 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a message component interaction.
|
4
|
+
# @abstract
|
5
|
+
class MessageComponentInteraction < Discorb::Interaction
|
6
|
+
include Discorb::Interaction::SourceResponder
|
7
|
+
include Discorb::Interaction::UpdateResponder
|
8
|
+
include Discorb::Interaction::ModalResponder
|
9
|
+
|
10
|
+
#
|
11
|
+
# Initialize a new message component interaction.
|
12
|
+
# @private
|
13
|
+
#
|
14
|
+
# @param [Discorb::Client] client The client.
|
15
|
+
# @param [Hash] data The data.
|
16
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
17
|
+
|
18
|
+
#
|
19
|
+
# Create a MessageComponentInteraction instance for the given data.
|
20
|
+
# @private
|
21
|
+
def self.make_interaction: (untyped client, untyped data) -> untyped
|
22
|
+
|
23
|
+
#
|
24
|
+
# Returns the classes under this class.
|
25
|
+
# @private
|
26
|
+
def self.nested_classes: -> untyped
|
27
|
+
|
28
|
+
#
|
29
|
+
# Response with `MODAL`(`9`).
|
30
|
+
#
|
31
|
+
# @param [String] title The title of the modal.
|
32
|
+
# @param [String] custom_id The custom id of the modal.
|
33
|
+
# @param [Array<Discorb::TextInput>] components The text inputs to send.
|
34
|
+
#
|
35
|
+
# @return [Async::Task<void>] The task.
|
36
|
+
def show_modal: (
|
37
|
+
String title,
|
38
|
+
String custom_id,
|
39
|
+
::Array[Discorb::TextInput] components
|
40
|
+
) -> Async::Task[void]
|
41
|
+
|
42
|
+
#
|
43
|
+
# Response with `DEFERRED_UPDATE_MESSAGE`(`6`).
|
44
|
+
# @async
|
45
|
+
#
|
46
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
47
|
+
#
|
48
|
+
# @return [Async::Task<void>] The task.
|
49
|
+
def defer_update: (?ephemeral: bool) -> Async::Task[void]
|
50
|
+
|
51
|
+
#
|
52
|
+
# Response with `UPDATE_MESSAGE`(`7`).
|
53
|
+
#
|
54
|
+
# @async
|
55
|
+
#
|
56
|
+
# @param [String] content The content of the response.
|
57
|
+
# @param [Boolean] tts Whether to send the message as text-to-speech.
|
58
|
+
# @param [Discorb::Embed] embed The embed to send.
|
59
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send. (max: 10)
|
60
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
61
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
62
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
63
|
+
#
|
64
|
+
# @return [Async::Task<void>] The task.
|
65
|
+
def edit: (
|
66
|
+
String content,
|
67
|
+
?tts: bool,
|
68
|
+
?embed: Discorb::Embed?,
|
69
|
+
?embeds: ::Array[Discorb::Embed]?,
|
70
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
71
|
+
?components: (::Array[Discorb::Component]
|
72
|
+
| ::Array[::Array[Discorb::Component]])?,
|
73
|
+
?ephemeral: bool
|
74
|
+
) -> Async::Task[void]
|
75
|
+
|
76
|
+
#
|
77
|
+
# Response with `DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE`(`5`).
|
78
|
+
#
|
79
|
+
# @async
|
80
|
+
#
|
81
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
82
|
+
#
|
83
|
+
# @return [Async::Task<void>] The task.
|
84
|
+
def defer_source: (?ephemeral: bool) -> Async::Task[void]
|
85
|
+
|
86
|
+
#
|
87
|
+
# Response with `CHANNEL_MESSAGE_WITH_SOURCE`(`4`).
|
88
|
+
#
|
89
|
+
# @async
|
90
|
+
#
|
91
|
+
# @param [String] content The content of the response.
|
92
|
+
# @param [Boolean] tts Whether to send the message as text-to-speech.
|
93
|
+
# @param [Discorb::Embed] embed The embed to send.
|
94
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send. (max: 10)
|
95
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
96
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
97
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
98
|
+
#
|
99
|
+
# @return [Discorb::Interaction::SourceResponder::CallbackMessage, Discorb::Webhook::Message]
|
100
|
+
# The callback message.
|
101
|
+
def post: (
|
102
|
+
?String? content,
|
103
|
+
?tts: bool,
|
104
|
+
?embed: Discorb::Embed?,
|
105
|
+
?embeds: ::Array[Discorb::Embed]?,
|
106
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
107
|
+
?components: (::Array[Discorb::Component]
|
108
|
+
| ::Array[::Array[Discorb::Component]])?,
|
109
|
+
?ephemeral: bool
|
110
|
+
) -> (Discorb::Interaction::SourceResponder::CallbackMessage
|
111
|
+
| Discorb::Webhook::Message)
|
112
|
+
|
113
|
+
# @return [String] The content of the response.
|
114
|
+
attr_reader custom_id: String
|
115
|
+
|
116
|
+
# @return [Discorb::Message] The target message.
|
117
|
+
attr_reader message: Discorb::Message
|
118
|
+
|
119
|
+
#
|
120
|
+
# Represents a button interaction.
|
121
|
+
class Button < Discorb::MessageComponentInteraction
|
122
|
+
# @return [String] The custom id of the button.
|
123
|
+
attr_reader custom_id: String
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Represents a select menu interaction.
|
128
|
+
class SelectMenu < Discorb::MessageComponentInteraction
|
129
|
+
# @return [String] The custom id of the select menu.
|
130
|
+
attr_reader custom_id: String
|
131
|
+
|
132
|
+
# @return [Array<String>] The selected options.
|
133
|
+
attr_reader values: ::Array[String]
|
134
|
+
|
135
|
+
# @!attribute [r] value
|
136
|
+
# @return [String] The first selected value.
|
137
|
+
attr_reader value: untyped
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a modal interaction.
|
4
|
+
class ModalInteraction < Discorb::Interaction
|
5
|
+
include Discorb::Interaction::SourceResponder
|
6
|
+
|
7
|
+
#
|
8
|
+
# Response with `DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE`(`5`).
|
9
|
+
#
|
10
|
+
# @async
|
11
|
+
#
|
12
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
13
|
+
#
|
14
|
+
# @return [Async::Task<void>] The task.
|
15
|
+
def defer_source: (?ephemeral: bool) -> Async::Task[void]
|
16
|
+
|
17
|
+
#
|
18
|
+
# Response with `CHANNEL_MESSAGE_WITH_SOURCE`(`4`).
|
19
|
+
#
|
20
|
+
# @async
|
21
|
+
#
|
22
|
+
# @param [String] content The content of the response.
|
23
|
+
# @param [Boolean] tts Whether to send the message as text-to-speech.
|
24
|
+
# @param [Discorb::Embed] embed The embed to send.
|
25
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send. (max: 10)
|
26
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
27
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
28
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
29
|
+
#
|
30
|
+
# @return [Discorb::Interaction::SourceResponder::CallbackMessage, Discorb::Webhook::Message]
|
31
|
+
# The callback message.
|
32
|
+
def post: (
|
33
|
+
?String? content,
|
34
|
+
?tts: bool,
|
35
|
+
?embed: Discorb::Embed?,
|
36
|
+
?embeds: ::Array[Discorb::Embed]?,
|
37
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
38
|
+
?components: (::Array[Discorb::Component]
|
39
|
+
| ::Array[::Array[Discorb::Component]])?,
|
40
|
+
?ephemeral: bool
|
41
|
+
) -> (Discorb::Interaction::SourceResponder::CallbackMessage
|
42
|
+
| Discorb::Webhook::Message)
|
43
|
+
|
44
|
+
# @return [String] The custom id of the modal.
|
45
|
+
attr_reader custom_id: String
|
46
|
+
|
47
|
+
# @return [{String => String}] The contents of the modal.
|
48
|
+
attr_reader contents: ::Hash[String, String]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
module Discorb
|
2
|
+
class Interaction < Discorb::DiscordModel
|
3
|
+
#
|
4
|
+
# A module for response with source.
|
5
|
+
module SourceResponder
|
6
|
+
#
|
7
|
+
# Response with `DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE`(`5`).
|
8
|
+
#
|
9
|
+
# @async
|
10
|
+
#
|
11
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
12
|
+
#
|
13
|
+
# @return [Async::Task<void>] The task.
|
14
|
+
def defer_source: (?ephemeral: bool) -> Async::Task[void]
|
15
|
+
|
16
|
+
#
|
17
|
+
# Response with `CHANNEL_MESSAGE_WITH_SOURCE`(`4`).
|
18
|
+
#
|
19
|
+
# @async
|
20
|
+
#
|
21
|
+
# @param [String] content The content of the response.
|
22
|
+
# @param [Boolean] tts Whether to send the message as text-to-speech.
|
23
|
+
# @param [Discorb::Embed] embed The embed to send.
|
24
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send. (max: 10)
|
25
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
26
|
+
# @param [Discorb::Attachment] attachment The attachment to send.
|
27
|
+
# @param [Array<Discorb::Attachment>] attachments The attachments to send. (max: 10)
|
28
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
29
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
30
|
+
#
|
31
|
+
# @return [Discorb::Interaction::SourceResponder::CallbackMessage, Discorb::Webhook::Message]
|
32
|
+
# The callback message.
|
33
|
+
def post: (
|
34
|
+
?String? content,
|
35
|
+
?tts: bool,
|
36
|
+
?embed: Discorb::Embed?,
|
37
|
+
?embeds: ::Array[Discorb::Embed]?,
|
38
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
39
|
+
?attachment: Discorb::Attachment?,
|
40
|
+
?attachments: ::Array[Discorb::Attachment]?,
|
41
|
+
?components: (::Array[Discorb::Component]
|
42
|
+
| ::Array[::Array[Discorb::Component]])?,
|
43
|
+
?ephemeral: bool
|
44
|
+
) -> (Discorb::Interaction::SourceResponder::CallbackMessage
|
45
|
+
| Discorb::Webhook::Message)
|
46
|
+
|
47
|
+
#
|
48
|
+
# Represents of a callback message of interaction.
|
49
|
+
class CallbackMessage
|
50
|
+
#
|
51
|
+
# Initializes a new instance of CallbackMessage.
|
52
|
+
# @private
|
53
|
+
#
|
54
|
+
# @param [Client] client The client.
|
55
|
+
# @param [Hash] data The payload.
|
56
|
+
# @param [String] application_id The application ID.
|
57
|
+
# @param [String] token The token.
|
58
|
+
def initialize: (
|
59
|
+
Client client,
|
60
|
+
Discorb::json data,
|
61
|
+
String application_id,
|
62
|
+
String token
|
63
|
+
) -> void
|
64
|
+
|
65
|
+
#
|
66
|
+
# Edits the callback message.
|
67
|
+
# @async
|
68
|
+
# @macro edit
|
69
|
+
#
|
70
|
+
# @param [String] content The new content of the message.
|
71
|
+
# @param [Discorb::Embed] embed The new embed of the message.
|
72
|
+
# @param [Array<Discorb::Embed>] embeds The new embeds of the message.
|
73
|
+
# @param [Array<Discorb::Attachment>] attachments The attachments to remain.
|
74
|
+
# @param [Discorb::Attachment] file The file to send.
|
75
|
+
# @param [Array<Discorb::Attachment>] files The files to send.
|
76
|
+
#
|
77
|
+
# @return [Async::Task<void>] The task.
|
78
|
+
def edit: (
|
79
|
+
?String content,
|
80
|
+
?embed: Discorb::Embed,
|
81
|
+
?embeds: ::Array[Discorb::Embed],
|
82
|
+
?file: Discorb::Attachment,
|
83
|
+
?files: ::Array[Discorb::Attachment],
|
84
|
+
?attachments: ::Array[Discorb::Attachment]
|
85
|
+
) -> Async::Task[void]
|
86
|
+
|
87
|
+
#
|
88
|
+
# Deletes the callback message.
|
89
|
+
# @async
|
90
|
+
# @note This will fail if the message is ephemeral.
|
91
|
+
#
|
92
|
+
# @return [Async::Task<void>] The task.
|
93
|
+
def delete!: -> Async::Task[void]
|
94
|
+
|
95
|
+
def inspect: -> String
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# A module for response with update.
|
101
|
+
module UpdateResponder
|
102
|
+
#
|
103
|
+
# Response with `DEFERRED_UPDATE_MESSAGE`(`6`).
|
104
|
+
# @async
|
105
|
+
#
|
106
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
107
|
+
#
|
108
|
+
# @return [Async::Task<void>] The task.
|
109
|
+
def defer_update: (?ephemeral: bool) -> Async::Task[void]
|
110
|
+
|
111
|
+
#
|
112
|
+
# Response with `UPDATE_MESSAGE`(`7`).
|
113
|
+
#
|
114
|
+
# @async
|
115
|
+
#
|
116
|
+
# @param [String] content The content of the response.
|
117
|
+
# @param [Boolean] tts Whether to send the message as text-to-speech.
|
118
|
+
# @param [Discorb::Embed] embed The embed to send.
|
119
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send. (max: 10)
|
120
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions to send.
|
121
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
122
|
+
# @param [Boolean] ephemeral Whether to make the response ephemeral.
|
123
|
+
#
|
124
|
+
# @return [Async::Task<void>] The task.
|
125
|
+
def edit: (
|
126
|
+
String content,
|
127
|
+
?tts: bool,
|
128
|
+
?embed: Discorb::Embed?,
|
129
|
+
?embeds: ::Array[Discorb::Embed]?,
|
130
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
131
|
+
?attachment: Discorb::Attachment?,
|
132
|
+
?attachments: ::Array[Discorb::Attachment]?,
|
133
|
+
?components: (::Array[Discorb::Component]
|
134
|
+
| ::Array[::Array[Discorb::Component]])?,
|
135
|
+
?ephemeral: bool
|
136
|
+
) -> Async::Task[void]
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# A module for response with modal.
|
141
|
+
module ModalResponder
|
142
|
+
#
|
143
|
+
# Response with `MODAL`(`9`).
|
144
|
+
#
|
145
|
+
# @param [String] title The title of the modal.
|
146
|
+
# @param [String] custom_id The custom id of the modal.
|
147
|
+
# @param [Array<Discorb::TextInput>] components The text inputs to send.
|
148
|
+
#
|
149
|
+
# @return [Async::Task<void>] The task.
|
150
|
+
def show_modal: (
|
151
|
+
String title,
|
152
|
+
String custom_id,
|
153
|
+
::Array[Discorb::TextInput] components
|
154
|
+
) -> Async::Task[void]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents invite of discord.
|
4
|
+
class Invite < Discorb::DiscordModel
|
5
|
+
TARGET_TYPES: Hash[Integer?, Symbol]
|
6
|
+
|
7
|
+
#
|
8
|
+
# Initialize a new invite.
|
9
|
+
# @private
|
10
|
+
#
|
11
|
+
# @param [Discorb::Client] client The client.
|
12
|
+
# @param [Hash] data The data of invite.
|
13
|
+
# @param [Boolean] gateway Whether the data is from gateway.
|
14
|
+
def initialize: (
|
15
|
+
Discorb::Client client,
|
16
|
+
Discorb::json data,
|
17
|
+
bool gateway
|
18
|
+
) -> void
|
19
|
+
|
20
|
+
# Delete the invite.
|
21
|
+
# @async
|
22
|
+
# @return [Async::Task<void>] The task.
|
23
|
+
def delete!: (?reason: String) -> Async::Task[void]
|
24
|
+
|
25
|
+
# @return [String] The code of invite.
|
26
|
+
attr_reader code: String
|
27
|
+
|
28
|
+
# @return [:voice, :stream, :guild] The type of invite.
|
29
|
+
attr_reader target_type: Symbol
|
30
|
+
|
31
|
+
# @return [User] The user of invite.
|
32
|
+
attr_reader target_user: User
|
33
|
+
|
34
|
+
# @return [Integer] The approximate number of online users of invite.
|
35
|
+
attr_reader approximate_presence_count: Integer
|
36
|
+
|
37
|
+
# @return [Integer] The approximate number of members of invite.
|
38
|
+
attr_reader approximate_member_count: Integer
|
39
|
+
|
40
|
+
# @return [Time] The time when invite expires.
|
41
|
+
# @return [nil] The invite never expires.
|
42
|
+
# @macro [new] nometa
|
43
|
+
# @return [nil] The invite doesn't have metadata.
|
44
|
+
attr_reader expires_at: Time?
|
45
|
+
|
46
|
+
# @return [Integer] The number of uses of invite.
|
47
|
+
# @macro nometa
|
48
|
+
attr_reader uses: Integer?
|
49
|
+
|
50
|
+
# @return [Integer] The maximum number of uses of invite.
|
51
|
+
# @macro nometa
|
52
|
+
attr_reader max_uses: Integer?
|
53
|
+
|
54
|
+
# @return [Integer] Duration of invite in seconds.
|
55
|
+
# @macro nometa
|
56
|
+
attr_reader max_age: Integer?
|
57
|
+
|
58
|
+
# @return [Time] The time when invite was created.
|
59
|
+
# @macro nometa
|
60
|
+
attr_reader created_at: Time?
|
61
|
+
|
62
|
+
# Channel of the invite.
|
63
|
+
#
|
64
|
+
# @return [Discorb::Channel] Channel of invite.
|
65
|
+
# @macro client_cache
|
66
|
+
attr_reader channel: Discorb::Channel?
|
67
|
+
|
68
|
+
# Guild of the invite.
|
69
|
+
#
|
70
|
+
# @return [Discorb::Guild] Guild of invite.
|
71
|
+
# @macro client_cache
|
72
|
+
attr_reader guild: Discorb::Guild?
|
73
|
+
|
74
|
+
# Number of remaining uses of invite.
|
75
|
+
# @return [Integer] Number of remaining uses of invite.
|
76
|
+
attr_reader remain_uses: Integer
|
77
|
+
|
78
|
+
# Full url of invite.
|
79
|
+
# @return [String] Full url of invite.
|
80
|
+
attr_reader url: String
|
81
|
+
|
82
|
+
# Whether the invite is temporary.
|
83
|
+
# @return [Boolean]
|
84
|
+
attr_reader temporary?: bool
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a member of a guild.
|
4
|
+
class Member < Discorb::User
|
5
|
+
#
|
6
|
+
# Initialize a new instance of the member.
|
7
|
+
# @private
|
8
|
+
#
|
9
|
+
# @param [Discorb::Client] client The client.
|
10
|
+
# @param [Discorb::Snowflake] guild_id The ID of the guild.
|
11
|
+
# @param [Hash] user_data The data of the user.
|
12
|
+
# @param [Hash] member_data The data of the member.
|
13
|
+
def initialize: (
|
14
|
+
Discorb::Client client,
|
15
|
+
Discorb::Snowflake guild_id,
|
16
|
+
Discorb::json user_data,
|
17
|
+
Discorb::json member_data
|
18
|
+
) -> void
|
19
|
+
|
20
|
+
#
|
21
|
+
# Format the member to `Username#Discriminator` style.
|
22
|
+
#
|
23
|
+
# @return [String] The formatted member.
|
24
|
+
def to_s: -> String
|
25
|
+
|
26
|
+
def inspect: -> String
|
27
|
+
|
28
|
+
#
|
29
|
+
# Add a role to the member.
|
30
|
+
# @async
|
31
|
+
#
|
32
|
+
# @param [Discorb::Role] role The role to add.
|
33
|
+
# @param [String] reason The reason for the action.
|
34
|
+
#
|
35
|
+
# @return [Async::Task<void>] The task.
|
36
|
+
def add_role: (Discorb::Role role, ?reason: String?) -> Async::Task[void]
|
37
|
+
|
38
|
+
#
|
39
|
+
# Remove a role to the member.
|
40
|
+
# @async
|
41
|
+
#
|
42
|
+
# @param [Discorb::Role] role The role to add.
|
43
|
+
# @param [String] reason The reason for the action.
|
44
|
+
#
|
45
|
+
# @return [Async::Task<void>] The task.
|
46
|
+
def remove_role: (Discorb::Role role, ?reason: String?) -> Async::Task[void]
|
47
|
+
|
48
|
+
#
|
49
|
+
# Edit the member.
|
50
|
+
# @async
|
51
|
+
# @macro edit
|
52
|
+
#
|
53
|
+
# @param [String] nick The nickname of the member.
|
54
|
+
# @param [Discorb::Role] role The roles of the member.
|
55
|
+
# @param [Boolean] mute Whether the member is muted.
|
56
|
+
# @param [Boolean] deaf Whether the member is deafened.
|
57
|
+
# @param [Discorb::StageChannel] channel The channel the member is moved to.
|
58
|
+
# @param [Time, nil] communication_disabled_until The time the member is timed out. Set to `nil` to end the timeout.
|
59
|
+
# @param [Time, nil] timeout_until Alias of `communication_disabled_until`.
|
60
|
+
# @param [String] reason The reason for the action.
|
61
|
+
#
|
62
|
+
# @return [Async::Task<void>] The task.
|
63
|
+
def edit: (
|
64
|
+
?nick: String,
|
65
|
+
?role: Discorb::Role,
|
66
|
+
?mute: bool,
|
67
|
+
?deaf: bool,
|
68
|
+
?channel: Discorb::StageChannel,
|
69
|
+
?communication_disabled_until: Time?,
|
70
|
+
?timeout_until: Time?,
|
71
|
+
?reason: String?
|
72
|
+
) -> Async::Task[void]
|
73
|
+
|
74
|
+
#
|
75
|
+
# Timeout the member.
|
76
|
+
# @async
|
77
|
+
#
|
78
|
+
# @param [Time] time The time until the member is timeout.
|
79
|
+
# @param [String] reason The reason for the action.
|
80
|
+
#
|
81
|
+
# @return [Async::Task<void>] The task.
|
82
|
+
def timeout: (Time time, ?reason: String?) -> Async::Task[void]
|
83
|
+
|
84
|
+
#
|
85
|
+
# Kick the member.
|
86
|
+
# @async
|
87
|
+
#
|
88
|
+
# @param [String] reason The reason for the action.
|
89
|
+
#
|
90
|
+
# @return [Async::Task<void>] The task.
|
91
|
+
def kick: (?reason: String?) -> Async::Task[void]
|
92
|
+
|
93
|
+
#
|
94
|
+
# Ban the member.
|
95
|
+
# @async
|
96
|
+
#
|
97
|
+
# @param [Integer] delete_message_days The number of days to delete messages.
|
98
|
+
# @param [String] reason The reason for the action.
|
99
|
+
#
|
100
|
+
# @return [Async::Task<Discorb::Guild::Ban>] The ban.
|
101
|
+
def ban: (
|
102
|
+
?delete_message_days: Integer,
|
103
|
+
?reason: String?
|
104
|
+
) -> Async::Task[Discorb::Guild::Ban]
|
105
|
+
|
106
|
+
#
|
107
|
+
# Checks if the member can manage the given role.
|
108
|
+
#
|
109
|
+
# @param [Discorb::Role] role The role.
|
110
|
+
#
|
111
|
+
# @return [Boolean] `true` if the member can manage the role.
|
112
|
+
def can_manage?: (Discorb::Role role) -> bool
|
113
|
+
|
114
|
+
# @return [Time] The time the member boosted the guild.
|
115
|
+
attr_reader premium_since: Time
|
116
|
+
|
117
|
+
# @return [String] The nickname of the member.
|
118
|
+
# @return [nil] If the member has no nickname.
|
119
|
+
attr_reader nick: String?
|
120
|
+
|
121
|
+
# @return [Time] The time the member joined the guild.
|
122
|
+
attr_reader joined_at: Time
|
123
|
+
|
124
|
+
# @return [Discorb::Asset] The custom avatar of the member.
|
125
|
+
# @return [nil] If the member has no custom avatar.
|
126
|
+
attr_reader custom_avatar: Discorb::Asset?
|
127
|
+
|
128
|
+
# @return [Discorb::Asset] The display avatar of the member.
|
129
|
+
attr_reader display_avatar: Discorb::Asset | Discorb::DefaultAvatar
|
130
|
+
|
131
|
+
# @return [Boolean] Whether the member is muted.
|
132
|
+
attr_reader mute: bool
|
133
|
+
|
134
|
+
# @return [Boolean] Whether the member is deafened.
|
135
|
+
attr_reader deaf: bool
|
136
|
+
|
137
|
+
# @return [Boolean] Whether the member is pending (Not passed member screening).
|
138
|
+
attr_reader pending: bool
|
139
|
+
|
140
|
+
# @return [String] The display name of the member.
|
141
|
+
attr_reader name: String
|
142
|
+
|
143
|
+
# @return [String] The mention of the member.
|
144
|
+
attr_reader mention: String
|
145
|
+
|
146
|
+
# @return [Discorb::VoiceState] The voice state of the member.
|
147
|
+
attr_reader voice_state: Discorb::VoiceState
|
148
|
+
|
149
|
+
# @macro client_cache
|
150
|
+
# @return [Array<Discorb::Role>] The roles of the member.
|
151
|
+
attr_reader roles: ::Array[Discorb::Role]?
|
152
|
+
|
153
|
+
# @macro client_cache
|
154
|
+
# @return [Discorb::Guild] The guild the member is in.
|
155
|
+
attr_reader guild: Discorb::Guild?
|
156
|
+
|
157
|
+
# @macro client_cache
|
158
|
+
# @return [Discorb::Role] The hoisted role of the member.
|
159
|
+
# @return [nil] If the member has no hoisted role.
|
160
|
+
attr_reader hoisted_role: Discorb::Role?
|
161
|
+
|
162
|
+
# @return [Boolean] Whether the member has a hoisted role.
|
163
|
+
attr_reader hoisted?: bool
|
164
|
+
|
165
|
+
# @return [Discorb::Permission] The permissions of the member.
|
166
|
+
attr_reader permissions: Discorb::Permission
|
167
|
+
|
168
|
+
# @macro client_cache
|
169
|
+
# @return [Discorb::Presence] The presence of the member.
|
170
|
+
attr_reader presence: Discorb::Presence?
|
171
|
+
|
172
|
+
# @macro client_cache
|
173
|
+
# @return [Discorb::Presence::Activity] The activity of the member. It's from the {#presence}.
|
174
|
+
attr_reader activity: Discorb::Presence::Activity?
|
175
|
+
|
176
|
+
# @macro client_cache
|
177
|
+
# @return [Array<Discorb::Presence::Activity>] The activities of the member. It's from the {#presence}.
|
178
|
+
attr_reader activities: ::Array[Discorb::Presence::Activity]?
|
179
|
+
|
180
|
+
# @macro client_cache
|
181
|
+
# @return [Symbol] The status of the member. It's from the {#presence}.
|
182
|
+
attr_reader status: Symbol?
|
183
|
+
|
184
|
+
# @return [Boolean] Whether the member is the owner of the guild.
|
185
|
+
attr_reader owner?: bool
|
186
|
+
end
|
187
|
+
end
|