discorb 0.17.1 → 0.19.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 +25 -0
- data/Gemfile +6 -0
- data/README.md +2 -1
- data/Rakefile +205 -98
- data/Steepfile +30 -0
- data/docs/application_command.md +1 -0
- data/docs/events.md +44 -8
- data/docs/tutorial.md +7 -7
- data/docs/voice_events.md +8 -8
- 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 +16 -13
- data/lib/discorb/app_command/handler.rb +21 -6
- data/lib/discorb/audit_logs.rb +6 -2
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/guild.rb +5 -4
- data/lib/discorb/channel/stage.rb +1 -1
- data/lib/discorb/channel/text.rb +14 -23
- data/lib/discorb/channel/thread.rb +15 -11
- data/lib/discorb/client.rb +15 -15
- 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 +5 -4
- data/lib/discorb/emoji.rb +4 -4
- data/lib/discorb/event.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 +38 -589
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +138 -19
- data/lib/discorb/guild_template.rb +3 -3
- data/lib/discorb/http.rb +47 -25
- data/lib/discorb/integration.rb +2 -2
- data/lib/discorb/intents.rb +27 -18
- data/lib/discorb/interaction/command.rb +14 -10
- data/lib/discorb/interaction/response.rb +150 -84
- data/lib/discorb/interaction/root.rb +139 -0
- data/lib/discorb/invite.rb +1 -1
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +17 -15
- data/lib/discorb/message_meta.rb +2 -3
- data/lib/discorb/modules.rb +5 -4
- data/lib/discorb/permission.rb +3 -1
- data/lib/discorb/presence.rb +4 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +3 -3
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +5 -5
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +8 -8
- data/lib/discorb/webhook.rb +20 -11
- 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 +24 -0
- data/sig/discorb/allowed_mentions.rbs +45 -0
- data/sig/discorb/app_command/base.rbs +288 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +146 -0
- data/sig/discorb/asset.rbs +34 -0
- data/sig/discorb/attachment.rbs +99 -0
- data/sig/discorb/audit_log.rbs +238 -0
- data/sig/discorb/automod.rbs +145 -0
- data/sig/discorb/avatar.rbs +27 -0
- data/sig/discorb/channel/base.rbs +186 -0
- data/sig/discorb/channel/category.rbs +57 -0
- data/sig/discorb/channel/container.rbs +33 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +81 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +196 -0
- data/sig/discorb/channel/voice.rbs +43 -0
- data/sig/discorb/client.rbs +2496 -0
- data/sig/discorb/color.rbs +148 -0
- data/sig/discorb/component/base.rbs +29 -0
- data/sig/discorb/component/button.rbs +67 -0
- data/sig/discorb/component/select_menu.rbs +111 -0
- data/sig/discorb/component/text_input.rbs +70 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +94 -0
- data/sig/discorb/dictionary.rbs +87 -0
- data/sig/discorb/discord_model.rbs +17 -0
- data/sig/discorb/embed.rbs +286 -0
- data/sig/discorb/emoji.rbs +14 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +28 -0
- data/sig/discorb/extension.rbs +1735 -0
- data/sig/discorb/flag.rbs +74 -0
- data/sig/discorb/gateway.rbs +486 -0
- data/sig/discorb/guild.rbs +872 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +150 -0
- data/sig/discorb/image.rbs +22 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +98 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +102 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +139 -0
- data/sig/discorb/interaction/modal.rbs +49 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +189 -0
- data/sig/discorb/message.rbs +474 -0
- data/sig/discorb/messageable.rbs +150 -0
- data/sig/discorb/partial_emoji.rbs +38 -0
- data/sig/discorb/permissions.rbs +156 -0
- data/sig/discorb/presence.rbs +239 -0
- data/sig/discorb/reaction.rbs +37 -0
- data/sig/discorb/role.rbs +151 -0
- data/sig/discorb/scheduled_event.rbs +149 -0
- data/sig/discorb/shard.rbs +63 -0
- data/sig/discorb/snowflake.rbs +58 -0
- data/sig/discorb/stage_instance.rbs +69 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +53 -0
- data/sig/discorb/user.rbs +95 -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 +338 -0
- data/sig/discorb/welcome_screen.rbs +79 -0
- data/sig/discorb.rbs +5 -8661
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +21 -0
- metadata +80 -3
@@ -0,0 +1,66 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a command interaction.
|
4
|
+
class CommandInteraction < Discorb::Interaction
|
5
|
+
include Discorb::Interaction::SourceResponder
|
6
|
+
include Discorb::Interaction::ModalResponder
|
7
|
+
|
8
|
+
#
|
9
|
+
# Creates a new CommandInteraction instance for the given data.
|
10
|
+
# @private
|
11
|
+
#
|
12
|
+
# @param [Discorb::Client] client The client.
|
13
|
+
# @param [Hash] data The data for the command.
|
14
|
+
def self.make_interaction: (
|
15
|
+
Discorb::Client client,
|
16
|
+
Discorb::json data
|
17
|
+
) -> untyped
|
18
|
+
|
19
|
+
#
|
20
|
+
# Returns the classes under this class.
|
21
|
+
# @private
|
22
|
+
def self.nested_classes: -> untyped
|
23
|
+
|
24
|
+
#
|
25
|
+
# Represents a slash command interaction.
|
26
|
+
class ChatInputCommand < Discorb::CommandInteraction
|
27
|
+
#
|
28
|
+
# Get command data from the given data.
|
29
|
+
# @private
|
30
|
+
#
|
31
|
+
# @param [Hash] data The data of the command.
|
32
|
+
def self.get_command_data: (Discorb::json data) -> untyped
|
33
|
+
|
34
|
+
#
|
35
|
+
# Modify the option map with the given options.
|
36
|
+
# @private
|
37
|
+
#
|
38
|
+
# @param [Hash] option_map The option map to modify.
|
39
|
+
# @param [Array<Hash>] options The options for modifying.
|
40
|
+
# @param [Discorb::Guild] guild The guild where the command is executed.
|
41
|
+
# @param [{Discorb::Snowflake => Discorb::Member}] members The cached members of the guild.
|
42
|
+
# @param [{Integer => Discorb::Attachment}] attachments The cached attachments of the message.
|
43
|
+
def self.modify_option_map: (
|
44
|
+
::Hash[untyped, untyped] option_map,
|
45
|
+
::Array[::Hash[untyped, untyped]] options,
|
46
|
+
Discorb::Guild? guild,
|
47
|
+
::Hash[Discorb::Snowflake, Discorb::Member] members,
|
48
|
+
::Hash[Integer, Discorb::Attachment] attachments
|
49
|
+
) -> untyped
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Represents a user context menu interaction.
|
54
|
+
class UserMenuCommand < Discorb::CommandInteraction
|
55
|
+
# @return [Discorb::Member, Discorb::User] The target user.
|
56
|
+
attr_reader target: Discorb::Member | Discorb::User
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Represents a message context menu interaction.
|
61
|
+
class MessageMenuCommand < Discorb::CommandInteraction
|
62
|
+
# @return [Discorb::Message] The target message.
|
63
|
+
attr_reader target: Discorb::Message
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,139 @@
|
|
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::CallbackMessage | Discorb::Webhook::Message)
|
111
|
+
|
112
|
+
# @return [String] The content of the response.
|
113
|
+
attr_reader custom_id: String
|
114
|
+
|
115
|
+
# @return [Discorb::Message] The target message.
|
116
|
+
attr_reader message: Discorb::Message
|
117
|
+
|
118
|
+
#
|
119
|
+
# Represents a button interaction.
|
120
|
+
class Button < Discorb::MessageComponentInteraction
|
121
|
+
# @return [String] The custom id of the button.
|
122
|
+
attr_reader custom_id: String
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# Represents a select menu interaction.
|
127
|
+
class SelectMenu < Discorb::MessageComponentInteraction
|
128
|
+
# @return [String] The custom id of the select menu.
|
129
|
+
attr_reader custom_id: String
|
130
|
+
|
131
|
+
# @return [Array<String>] The selected options.
|
132
|
+
attr_reader values: ::Array[String]
|
133
|
+
|
134
|
+
# @!attribute [r] value
|
135
|
+
# @return [String] The first selected value.
|
136
|
+
attr_reader value: untyped
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,49 @@
|
|
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::CallbackMessage | Discorb::Webhook::Message)
|
42
|
+
|
43
|
+
# @return [String] The custom id of the modal.
|
44
|
+
attr_reader custom_id: String
|
45
|
+
|
46
|
+
# @return [{String => String}] The contents of the modal.
|
47
|
+
attr_reader contents: ::Hash[String, String]
|
48
|
+
end
|
49
|
+
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::CallbackMessage | Discorb::Webhook::Message)
|
45
|
+
end
|
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
|
+
%a{pure}
|
96
|
+
def inspect: -> String
|
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,189 @@
|
|
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
|
+
%a{pure}
|
25
|
+
def to_s: -> String
|
26
|
+
|
27
|
+
%a{pure}
|
28
|
+
def inspect: -> String
|
29
|
+
|
30
|
+
#
|
31
|
+
# Add a role to the member.
|
32
|
+
# @async
|
33
|
+
#
|
34
|
+
# @param [Discorb::Role] role The role to add.
|
35
|
+
# @param [String] reason The reason for the action.
|
36
|
+
#
|
37
|
+
# @return [Async::Task<void>] The task.
|
38
|
+
def add_role: (Discorb::Role role, ?reason: String?) -> Async::Task[void]
|
39
|
+
|
40
|
+
#
|
41
|
+
# Remove a role to the member.
|
42
|
+
# @async
|
43
|
+
#
|
44
|
+
# @param [Discorb::Role] role The role to add.
|
45
|
+
# @param [String] reason The reason for the action.
|
46
|
+
#
|
47
|
+
# @return [Async::Task<void>] The task.
|
48
|
+
def remove_role: (Discorb::Role role, ?reason: String?) -> Async::Task[void]
|
49
|
+
|
50
|
+
#
|
51
|
+
# Edit the member.
|
52
|
+
# @async
|
53
|
+
# @macro edit
|
54
|
+
#
|
55
|
+
# @param [String] nick The nickname of the member.
|
56
|
+
# @param [Discorb::Role] role The roles of the member.
|
57
|
+
# @param [Boolean] mute Whether the member is muted.
|
58
|
+
# @param [Boolean] deaf Whether the member is deafened.
|
59
|
+
# @param [Discorb::StageChannel] channel The channel the member is moved to.
|
60
|
+
# @param [Time, nil] communication_disabled_until The time the member is timed out. Set to `nil` to end the timeout.
|
61
|
+
# @param [Time, nil] timeout_until Alias of `communication_disabled_until`.
|
62
|
+
# @param [String] reason The reason for the action.
|
63
|
+
#
|
64
|
+
# @return [Async::Task<void>] The task.
|
65
|
+
def edit: (
|
66
|
+
?nick: String,
|
67
|
+
?role: Discorb::Role,
|
68
|
+
?mute: bool,
|
69
|
+
?deaf: bool,
|
70
|
+
?channel: Discorb::StageChannel,
|
71
|
+
?communication_disabled_until: Time?,
|
72
|
+
?timeout_until: Time?,
|
73
|
+
?reason: String?
|
74
|
+
) -> Async::Task[void]
|
75
|
+
|
76
|
+
#
|
77
|
+
# Timeout the member.
|
78
|
+
# @async
|
79
|
+
#
|
80
|
+
# @param [Time] time The time until the member is timeout.
|
81
|
+
# @param [String] reason The reason for the action.
|
82
|
+
#
|
83
|
+
# @return [Async::Task<void>] The task.
|
84
|
+
def timeout: (Time time, ?reason: String?) -> Async::Task[void]
|
85
|
+
|
86
|
+
#
|
87
|
+
# Kick the member.
|
88
|
+
# @async
|
89
|
+
#
|
90
|
+
# @param [String] reason The reason for the action.
|
91
|
+
#
|
92
|
+
# @return [Async::Task<void>] The task.
|
93
|
+
def kick: (?reason: String?) -> Async::Task[void]
|
94
|
+
|
95
|
+
#
|
96
|
+
# Ban the member.
|
97
|
+
# @async
|
98
|
+
#
|
99
|
+
# @param [Integer] delete_message_days The number of days to delete messages.
|
100
|
+
# @param [String] reason The reason for the action.
|
101
|
+
#
|
102
|
+
# @return [Async::Task<Discorb::Guild::Ban>] The ban.
|
103
|
+
def ban: (
|
104
|
+
?delete_message_days: Integer,
|
105
|
+
?reason: String?
|
106
|
+
) -> Async::Task[Discorb::Guild::Ban]
|
107
|
+
|
108
|
+
#
|
109
|
+
# Checks if the member can manage the given role.
|
110
|
+
#
|
111
|
+
# @param [Discorb::Role] role The role.
|
112
|
+
#
|
113
|
+
# @return [Boolean] `true` if the member can manage the role.
|
114
|
+
def can_manage?: (Discorb::Role role) -> bool
|
115
|
+
|
116
|
+
# @return [Time] The time the member boosted the guild.
|
117
|
+
attr_reader premium_since: Time
|
118
|
+
|
119
|
+
# @return [String] The nickname of the member.
|
120
|
+
# @return [nil] If the member has no nickname.
|
121
|
+
attr_reader nick: String?
|
122
|
+
|
123
|
+
# @return [Time] The time the member joined the guild.
|
124
|
+
attr_reader joined_at: Time
|
125
|
+
|
126
|
+
# @return [Discorb::Asset] The custom avatar of the member.
|
127
|
+
# @return [nil] If the member has no custom avatar.
|
128
|
+
attr_reader custom_avatar: Discorb::Asset?
|
129
|
+
|
130
|
+
# @return [Discorb::Asset] The display avatar of the member.
|
131
|
+
attr_reader display_avatar: Discorb::Asset | Discorb::DefaultAvatar
|
132
|
+
|
133
|
+
# @return [Boolean] Whether the member is muted.
|
134
|
+
attr_reader mute: bool
|
135
|
+
|
136
|
+
# @return [Boolean] Whether the member is deafened.
|
137
|
+
attr_reader deaf: bool
|
138
|
+
|
139
|
+
# @return [Boolean] Whether the member is pending (Not passed member screening).
|
140
|
+
attr_reader pending: bool
|
141
|
+
|
142
|
+
# @return [String] The display name of the member.
|
143
|
+
attr_reader name: String
|
144
|
+
|
145
|
+
# @return [String] The mention of the member.
|
146
|
+
attr_reader mention: String
|
147
|
+
|
148
|
+
# @return [Discorb::VoiceState] The voice state of the member.
|
149
|
+
attr_reader voice_state: Discorb::VoiceState
|
150
|
+
|
151
|
+
# @macro client_cache
|
152
|
+
# @return [Array<Discorb::Role>] The roles of the member.
|
153
|
+
attr_reader roles: ::Array[Discorb::Role]?
|
154
|
+
|
155
|
+
# @macro client_cache
|
156
|
+
# @return [Discorb::Guild] The guild the member is in.
|
157
|
+
attr_reader guild: Discorb::Guild?
|
158
|
+
|
159
|
+
# @macro client_cache
|
160
|
+
# @return [Discorb::Role] The hoisted role of the member.
|
161
|
+
# @return [nil] If the member has no hoisted role.
|
162
|
+
attr_reader hoisted_role: Discorb::Role?
|
163
|
+
|
164
|
+
# @return [Boolean] Whether the member has a hoisted role.
|
165
|
+
attr_reader hoisted?: bool
|
166
|
+
|
167
|
+
# @return [Discorb::Permission] The permissions of the member.
|
168
|
+
attr_reader permissions: Discorb::Permission
|
169
|
+
|
170
|
+
# @macro client_cache
|
171
|
+
# @return [Discorb::Presence] The presence of the member.
|
172
|
+
attr_reader presence: Discorb::Presence?
|
173
|
+
|
174
|
+
# @macro client_cache
|
175
|
+
# @return [Discorb::Presence::Activity] The activity of the member. It's from the {#presence}.
|
176
|
+
attr_reader activity: Discorb::Presence::Activity?
|
177
|
+
|
178
|
+
# @macro client_cache
|
179
|
+
# @return [Array<Discorb::Presence::Activity>] The activities of the member. It's from the {#presence}.
|
180
|
+
attr_reader activities: ::Array[Discorb::Presence::Activity]?
|
181
|
+
|
182
|
+
# @macro client_cache
|
183
|
+
# @return [Symbol] The status of the member. It's from the {#presence}.
|
184
|
+
attr_reader status: Symbol?
|
185
|
+
|
186
|
+
# @return [Boolean] Whether the member is the owner of the guild.
|
187
|
+
attr_reader owner?: bool
|
188
|
+
end
|
189
|
+
end
|