discorb 0.17.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint.yml +1 -3
  3. data/.github/workflows/validate.yml +21 -0
  4. data/Changelog.md +25 -0
  5. data/Gemfile +6 -0
  6. data/README.md +2 -1
  7. data/Rakefile +205 -98
  8. data/Steepfile +30 -0
  9. data/docs/application_command.md +1 -0
  10. data/docs/events.md +44 -8
  11. data/docs/tutorial.md +7 -7
  12. data/docs/voice_events.md +8 -8
  13. data/examples/commands/message.rb +12 -7
  14. data/examples/commands/permission.rb +2 -1
  15. data/examples/commands/slash.rb +23 -19
  16. data/examples/commands/user.rb +15 -12
  17. data/examples/components/authorization_button.rb +2 -1
  18. data/examples/components/select_menu.rb +4 -1
  19. data/examples/extension/main.rb +1 -0
  20. data/examples/extension/message_expander.rb +1 -0
  21. data/examples/sig/commands/message.rbs +5 -0
  22. data/examples/simple/eval.rb +1 -0
  23. data/examples/simple/ping_pong.rb +1 -0
  24. data/examples/simple/rolepanel.rb +16 -5
  25. data/examples/simple/shard.rb +2 -1
  26. data/examples/simple/wait_for_message.rb +3 -0
  27. data/exe/discorb +3 -3
  28. data/lib/discorb/allowed_mentions.rb +1 -1
  29. data/lib/discorb/app_command/command.rb +16 -13
  30. data/lib/discorb/app_command/handler.rb +21 -6
  31. data/lib/discorb/audit_logs.rb +6 -2
  32. data/lib/discorb/automod.rb +269 -0
  33. data/lib/discorb/channel/guild.rb +5 -4
  34. data/lib/discorb/channel/stage.rb +1 -1
  35. data/lib/discorb/channel/text.rb +14 -23
  36. data/lib/discorb/channel/thread.rb +15 -11
  37. data/lib/discorb/client.rb +15 -15
  38. data/lib/discorb/color.rb +37 -60
  39. data/lib/discorb/common.rb +1 -1
  40. data/lib/discorb/dictionary.rb +1 -1
  41. data/lib/discorb/embed.rb +5 -4
  42. data/lib/discorb/emoji.rb +4 -4
  43. data/lib/discorb/event.rb +2 -2
  44. data/lib/discorb/exe/about.rb +1 -1
  45. data/lib/discorb/exe/new.rb +1 -5
  46. data/lib/discorb/extension.rb +0 -4
  47. data/lib/discorb/flag.rb +2 -2
  48. data/lib/discorb/gateway.rb +38 -589
  49. data/lib/discorb/gateway_events.rb +638 -0
  50. data/lib/discorb/guild.rb +138 -19
  51. data/lib/discorb/guild_template.rb +3 -3
  52. data/lib/discorb/http.rb +47 -25
  53. data/lib/discorb/integration.rb +2 -2
  54. data/lib/discorb/intents.rb +27 -18
  55. data/lib/discorb/interaction/command.rb +14 -10
  56. data/lib/discorb/interaction/response.rb +150 -84
  57. data/lib/discorb/interaction/root.rb +139 -0
  58. data/lib/discorb/invite.rb +1 -1
  59. data/lib/discorb/member.rb +3 -3
  60. data/lib/discorb/message.rb +17 -15
  61. data/lib/discorb/message_meta.rb +2 -3
  62. data/lib/discorb/modules.rb +5 -4
  63. data/lib/discorb/permission.rb +3 -1
  64. data/lib/discorb/presence.rb +4 -2
  65. data/lib/discorb/reaction.rb +2 -2
  66. data/lib/discorb/role.rb +3 -3
  67. data/lib/discorb/shard.rb +1 -1
  68. data/lib/discorb/sticker.rb +5 -5
  69. data/lib/discorb/user.rb +2 -2
  70. data/lib/discorb/voice_state.rb +8 -8
  71. data/lib/discorb/webhook.rb +20 -11
  72. data/lib/discorb.rb +2 -2
  73. data/rbs_collection.lock.yaml +88 -96
  74. data/rbs_collection.yaml +21 -17
  75. data/sig/async.rbs +11 -5
  76. data/sig/discorb/activity.rbs +24 -0
  77. data/sig/discorb/allowed_mentions.rbs +45 -0
  78. data/sig/discorb/app_command/base.rbs +288 -0
  79. data/sig/discorb/app_command/handler.rbs +171 -0
  80. data/sig/discorb/application.rbs +146 -0
  81. data/sig/discorb/asset.rbs +34 -0
  82. data/sig/discorb/attachment.rbs +99 -0
  83. data/sig/discorb/audit_log.rbs +238 -0
  84. data/sig/discorb/automod.rbs +145 -0
  85. data/sig/discorb/avatar.rbs +27 -0
  86. data/sig/discorb/channel/base.rbs +186 -0
  87. data/sig/discorb/channel/category.rbs +57 -0
  88. data/sig/discorb/channel/container.rbs +33 -0
  89. data/sig/discorb/channel/dm.rbs +14 -0
  90. data/sig/discorb/channel/news.rbs +20 -0
  91. data/sig/discorb/channel/stage.rbs +81 -0
  92. data/sig/discorb/channel/text.rbs +158 -0
  93. data/sig/discorb/channel/thread.rbs +196 -0
  94. data/sig/discorb/channel/voice.rbs +43 -0
  95. data/sig/discorb/client.rbs +2496 -0
  96. data/sig/discorb/color.rbs +148 -0
  97. data/sig/discorb/component/base.rbs +29 -0
  98. data/sig/discorb/component/button.rbs +67 -0
  99. data/sig/discorb/component/select_menu.rbs +111 -0
  100. data/sig/discorb/component/text_input.rbs +70 -0
  101. data/sig/discorb/connectable.rbs +8 -0
  102. data/sig/discorb/custom_emoji.rbs +94 -0
  103. data/sig/discorb/dictionary.rbs +87 -0
  104. data/sig/discorb/discord_model.rbs +17 -0
  105. data/sig/discorb/embed.rbs +286 -0
  106. data/sig/discorb/emoji.rbs +14 -0
  107. data/sig/discorb/error.rbs +73 -0
  108. data/sig/discorb/event_handler.rbs +28 -0
  109. data/sig/discorb/extension.rbs +1735 -0
  110. data/sig/discorb/flag.rbs +74 -0
  111. data/sig/discorb/gateway.rbs +486 -0
  112. data/sig/discorb/guild.rbs +872 -0
  113. data/sig/discorb/guild_template.rbs +174 -0
  114. data/sig/discorb/http.rbs +150 -0
  115. data/sig/discorb/image.rbs +22 -0
  116. data/sig/discorb/integration.rbs +118 -0
  117. data/sig/discorb/intents.rbs +98 -0
  118. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  119. data/sig/discorb/interaction/base.rbs +102 -0
  120. data/sig/discorb/interaction/command.rbs +66 -0
  121. data/sig/discorb/interaction/message_component.rbs +139 -0
  122. data/sig/discorb/interaction/modal.rbs +49 -0
  123. data/sig/discorb/interaction/responder.rbs +157 -0
  124. data/sig/discorb/invite.rbs +86 -0
  125. data/sig/discorb/member.rbs +189 -0
  126. data/sig/discorb/message.rbs +474 -0
  127. data/sig/discorb/messageable.rbs +150 -0
  128. data/sig/discorb/partial_emoji.rbs +38 -0
  129. data/sig/discorb/permissions.rbs +156 -0
  130. data/sig/discorb/presence.rbs +239 -0
  131. data/sig/discorb/reaction.rbs +37 -0
  132. data/sig/discorb/role.rbs +151 -0
  133. data/sig/discorb/scheduled_event.rbs +149 -0
  134. data/sig/discorb/shard.rbs +63 -0
  135. data/sig/discorb/snowflake.rbs +58 -0
  136. data/sig/discorb/stage_instance.rbs +69 -0
  137. data/sig/discorb/sticker.rbs +116 -0
  138. data/sig/discorb/system_channel_flag.rbs +17 -0
  139. data/sig/discorb/unicode_emoji.rbs +53 -0
  140. data/sig/discorb/user.rbs +95 -0
  141. data/sig/discorb/utils.rbs +8 -0
  142. data/sig/discorb/voice_region.rbs +30 -0
  143. data/sig/discorb/voice_state.rbs +71 -0
  144. data/sig/discorb/webhook.rbs +338 -0
  145. data/sig/discorb/welcome_screen.rbs +79 -0
  146. data/sig/discorb.rbs +5 -8661
  147. data/sig/manifest.yaml +3 -0
  148. data/sig/override.rbs +21 -0
  149. metadata +80 -3
@@ -0,0 +1,288 @@
1
+ module Discorb
2
+ #
3
+ # Handles application commands.
4
+ module ApplicationCommand
5
+ VALID_LOCALES: untyped
6
+ type option =
7
+ {
8
+ name_localizations: Hash[(Symbol | String), String]?,
9
+ description: localizable?,
10
+ required: bool?,
11
+ optional: bool?,
12
+ default: untyped?,
13
+ type: (singleton(String)
14
+ | :string
15
+ | :str
16
+ | singleton(Integer)
17
+ | :integer
18
+ | :int
19
+ | singleton(TrueClass)
20
+ | singleton(FalseClass)
21
+ | :boolean
22
+ | :bool
23
+ | singleton(Discorb::User)
24
+ | singleton(Discorb::Member)
25
+ | :user
26
+ | :member
27
+ | singleton(Discorb::Channel)
28
+ | :channel
29
+ | singleton(Discorb::Role)
30
+ | :role
31
+ | :mentionable
32
+ | singleton(Float)
33
+ | :float
34
+ | :attachment)?,
35
+ choices: Hash[String, (String | Integer | Float)]?,
36
+ choices_localizations: Hash[String, Hash[(Symbol | String), String]]?,
37
+ channel_types: Array[Class]?,
38
+ autocomplete: (^(Discorb::CommandInteraction) -> Hash[String, String])?,
39
+ range: Range[(Integer | Float)]?
40
+ }
41
+ type options = ::Hash[String, option]
42
+ type localizable = String | Hash[Symbol | String, String]
43
+ type guild_ids = Array[_ToS] | false | nil
44
+
45
+ def self?.modify_localization_hash: (
46
+ Hash[Symbol | String, String] hash
47
+ ) -> Hash[String, String]
48
+
49
+ #
50
+ # Represents a application command.
51
+ # @abstract
52
+ class Command < Discorb::DiscordModel
53
+ TYPES: Hash[Integer, Symbol]
54
+
55
+ #
56
+ # Initialize a new command.
57
+ # @private
58
+ #
59
+ # @param [String, Hash{Symbol => String}] name The name of the command.
60
+ # @param [Array<#to_s>, false, nil] guild_ids The guild ids that the command is enabled in.
61
+ # @param [Proc] block The block of the command.
62
+ # @param [Integer] type The type of the command.
63
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
64
+ # @param [Discorb::Permission] default_permission The default permission of the command.
65
+ def initialize: (
66
+ Discorb::ApplicationCommand::localizable name,
67
+ Discorb::ApplicationCommand::guild_ids guild_ids,
68
+ ^(Discorb::Interaction, *untyped) -> untyped block,
69
+ Integer `type`,
70
+ ?bool? dm_permission,
71
+ ?Discorb::Permission? default_permission
72
+ ) -> void
73
+
74
+ #
75
+ # Changes the self pointer of block to the given object.
76
+ # @private
77
+ #
78
+ # @param [Object] instance The object to change the self pointer to.
79
+ def replace_block: (Object `instance`) -> untyped
80
+
81
+ #
82
+ # Converts the object to a hash.
83
+ # @private
84
+ #
85
+ # @return [Hash] The hash represents the object.
86
+ %a{pure}
87
+ def to_hash: -> Discorb::json
88
+
89
+ # @return [Hash{String => String}] The name of the command.
90
+ attr_reader name: ::Hash[String, String]
91
+
92
+ # @return [Array<#to_s>] The guild ids that the command is enabled in.
93
+ attr_reader guild_ids: Discorb::ApplicationCommand::guild_ids
94
+
95
+ # @return [Proc] The block of the command.
96
+ attr_reader block: ^(Discorb::Interaction, *untyped) -> untyped
97
+
98
+ # @return [:chat_input, :user, :message] The type of the command.
99
+ attr_reader type: Symbol
100
+
101
+ # @return [Integer] The raw type of the command.
102
+ attr_reader type_raw: Integer
103
+
104
+ # @return [Discorb::Permission] The default permissions for this command.
105
+ attr_reader default_permission: Discorb::Permission?
106
+
107
+ # @return [Boolean] Whether the command is enabled in DMs.
108
+ attr_reader dm_permission: bool?
109
+
110
+ #
111
+ # Represents the slash command.
112
+ class ChatInputCommand < Discorb::ApplicationCommand::Command
113
+ #
114
+ # Initialize a new slash command.
115
+ # @private
116
+ #
117
+ # @param [String, Hash{Symbol => String}] name The name of the command.
118
+ # The hash should have `default`, and language keys.
119
+ # @param [String, Hash{Symbol => String}] description The description of the command.
120
+ # The hash should have `default`, and language keys.
121
+ # @param [Hash{String => Hash}] options The options of the command.
122
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
123
+ # @param [Proc] block The block of the command.
124
+ # @param [Integer] type The type of the command.
125
+ # @param [Discorb::ApplicationCommand::Command, nil] parent The parent command.
126
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
127
+ # @param [Discorb::Permission] default_permission The default permission of the command.
128
+ def initialize: (
129
+ Discorb::ApplicationCommand::localizable name,
130
+ Discorb::ApplicationCommand::localizable description,
131
+ Discorb::ApplicationCommand::options options,
132
+ Discorb::ApplicationCommand::guild_ids guild_ids,
133
+ ^(
134
+ Discorb::CommandInteraction::ChatInputCommand,
135
+ *untyped
136
+ ) -> untyped block,
137
+ Integer `type`,
138
+ Discorb::ApplicationCommand::Command? parent,
139
+ bool? dm_permission,
140
+ Discorb::Permission? default_permission
141
+ ) -> void
142
+
143
+ #
144
+ # Returns the commands name.
145
+ #
146
+ # @return [String] The name of the command.
147
+ %a{pure}
148
+ def to_s: -> String
149
+
150
+ #
151
+ # Converts the object to a hash.
152
+ # @private
153
+ #
154
+ # @return [Hash] The hash represents the object.
155
+ %a{pure}
156
+ def to_hash: -> Discorb::json
157
+
158
+ # @return [Hash{String => String}] The description of the command.
159
+ attr_reader description: ::Hash[String, String]
160
+
161
+ # @return [Hash{String => Hash}] The options of the command.
162
+ attr_reader options: ::Hash[String, ::Hash[untyped, untyped]]
163
+ end
164
+
165
+ #
166
+ # Represents the command with subcommands.
167
+ class GroupCommand < Discorb::ApplicationCommand::Command
168
+ #
169
+ # Initialize a new group command.
170
+ # @private
171
+ #
172
+ # @param [String, Hash{Symbol => String}] name The name of the command.
173
+ # @param [String, Hash{Symbol => String}] description The description of the command.
174
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
175
+ # @param [Discorb::Client] client The client of the command.
176
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
177
+ # @param [Discorb::Permission] default_permission The default permission of the command.
178
+ def initialize: (
179
+ Discorb::ApplicationCommand::localizable name,
180
+ Discorb::ApplicationCommand::localizable description,
181
+ Discorb::ApplicationCommand::guild_ids guild_ids,
182
+ Discorb::Client client,
183
+ bool? dm_permission,
184
+ Discorb::Permission? default_permission
185
+ ) -> void
186
+
187
+ #
188
+ # Add new subcommand.
189
+ #
190
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
191
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
192
+ def slash: (
193
+ String | ::Hash[Symbol, String] command_name,
194
+ String | ::Hash[Symbol, String] description,
195
+ ?Discorb::ApplicationCommand::options options,
196
+ ?dm_permission: bool,
197
+ ?default_permission: Discorb::Permission?
198
+ ) {
199
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
200
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
201
+
202
+ #
203
+ # Add new subcommand group.
204
+ #
205
+ # @param [String] command_name Group name.
206
+ # @param [String] description Group description.
207
+ #
208
+ # @yield Block to yield with the command.
209
+ # @yieldparam [Discorb::ApplicationCommand::Command::SubcommandGroup] group Group command.
210
+ #
211
+ # @return [Discorb::ApplicationCommand::Command::SubcommandGroup] Command object.
212
+ #
213
+ # @see file:docs/application_command.md Application Commands
214
+ def group: (
215
+ String command_name,
216
+ String description
217
+ ) ?{
218
+ (Discorb::ApplicationCommand::Command::SubcommandGroup group) -> void
219
+ } -> Discorb::ApplicationCommand::Command::SubcommandGroup
220
+
221
+ #
222
+ # Returns the command name.
223
+ #
224
+ # @return [String] The command name.
225
+ %a{pure}
226
+ def to_s: -> String
227
+
228
+ #
229
+ # Changes the self pointer to the given object.
230
+ # @private
231
+ #
232
+ # @param [Object] instance The object to change to.
233
+ def block_replace: (Object `instance`) -> untyped
234
+
235
+ #
236
+ # Converts the object to a hash.
237
+ # @private
238
+ #
239
+ # @return [Hash] The hash represents the object.
240
+ %a{pure}
241
+ def to_hash: -> Discorb::json
242
+
243
+ # @return [Array<Discorb::ApplicationCommand::Command>] The subcommands of the command.
244
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
245
+
246
+ # @return [String] The description of the command.
247
+ attr_reader description: ::Hash[String, String]
248
+ end
249
+
250
+ #
251
+ # Represents the subcommand group.
252
+ class SubcommandGroup < Discorb::ApplicationCommand::Command::GroupCommand
253
+ #
254
+ # Initialize a new subcommand group.
255
+ # @private
256
+ #
257
+ # @param [String] name The name of the command.
258
+ # @param [String] description The description of the command.
259
+ # @param [Discorb::ApplicationCommand::Command::GroupCommand] parent The parent command.
260
+ # @param [Discorb::Client] client The client.
261
+ def initialize: (
262
+ String name,
263
+ String description,
264
+ Discorb::ApplicationCommand::Command::GroupCommand parent,
265
+ Discorb::Client client
266
+ ) -> void
267
+
268
+ %a{pure}
269
+ def to_s: -> untyped
270
+
271
+ #
272
+ # Add new subcommand.
273
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
274
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
275
+ def slash: (
276
+ Discorb::ApplicationCommand::localizable command_name,
277
+ Discorb::ApplicationCommand::localizable description,
278
+ ?Discorb::ApplicationCommand::options options
279
+ ) {
280
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
281
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
282
+
283
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand>] The subcommands of the command.
284
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
285
+ end
286
+ end
287
+ end
288
+ end
@@ -0,0 +1,171 @@
1
+ module Discorb
2
+ module ApplicationCommand
3
+ #
4
+ # Module to handle application commands.
5
+ module Handler
6
+ #
7
+ # Add new top-level command.
8
+ #
9
+ # @param [String, Hash{Symbol => String}] command_name Command name.
10
+ # If hash is passed, it must be a pair of Language code and Command name, and `:default` key is required.
11
+ # You can use `_` instead of `-` in language code.
12
+ # @param [String, Hash{Symbol => String}] description Command description.
13
+ # If hash is passed, it must be a pair of Language code and Command description, and `:default` key is required.
14
+ # You can use `_` instead of `-` in language code.
15
+ # @param [Hash{String => Hash{:description => String, :optional => Boolean, :type => Object}}] options
16
+ # Command options.
17
+ # The key is the option name, the value is a hash with the following keys:
18
+ #
19
+ # | Key | Type | Description |
20
+ # | --- | --- | --- |
21
+ # | `:name_localizations` | Hash{Symbol => String} | Localizations of option name. |
22
+ # | `:description` | `String` \| `Hash{Symbol => String}` |
23
+ # Description of the option. If hash is passed, it must be a pair of Language code and description,
24
+ # and `:default` key is required. You can use `_` instead of `-` in language code. |
25
+ # | `:required` | Boolean(true | false) |
26
+ # Whether the argument is required. `optional` will be used if not specified. |
27
+ # | `:optional` | Boolean(true | false) |
28
+ # Whether the argument is optional. `required` will be used if not specified. |
29
+ # | `:type` | `Object` | Type of the option. |
30
+ # | `:choices` | `Hash{String => String, Integer, Float}` | Type of the option. |
31
+ # | `:choices_localizations` | `Hash{String => Hash{Symbol => String}}` |
32
+ # Localization of the choice. Key must be the name of a choice. |
33
+ # | `:default` | `Object` | Default value of the option. |
34
+ # | `:channel_types` | `Array<Class<Discorb::Channel>>` | Type of the channel option. |
35
+ # | `:autocomplete` | `Proc` | Autocomplete function. |
36
+ # | `:range` | `Range` | Range of the option. Only valid for numeric options. (`:int`, `:float`) |
37
+ #
38
+ # @param [Array<#to_s>, false, nil] guild_ids
39
+ # Guild IDs to set the command to. `false` to global command, `nil` to use default.
40
+ # @param [Boolean] dm_permission Whether the command is available in DM.
41
+ # @param [Discorb::Permission] default_permission The default permission of the command.
42
+ # @param [Proc] block Command block.
43
+ #
44
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] Command object.
45
+ #
46
+ # @see file:docs/application_command.md#register-slash-command Application Comamnds: Register Slash Command
47
+ # @see file:docs/cli/setup.md CLI: setup
48
+ def slash: (
49
+ Discorb::ApplicationCommand::localizable command_name,
50
+ Discorb::ApplicationCommand::localizable description,
51
+ ?Discorb::ApplicationCommand::options options,
52
+ ?guild_ids: Discorb::ApplicationCommand::guild_ids?,
53
+ ?dm_permission: bool,
54
+ ?default_permission: Discorb::Permission?
55
+ ) {
56
+ (
57
+ Discorb::CommandInteraction::ChatInputCommand interaction,
58
+ *untyped
59
+ ) -> void
60
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
61
+
62
+ #
63
+ # Add new command with group.
64
+ #
65
+ # @param [String, Hash{Symbol => String}] command_name Command name.
66
+ # @param [String, Hash{Symbol => String}] description Command description.
67
+ # @param [Array<#to_s>, false, nil] guild_ids
68
+ # Guild IDs to set the command to. `false` to global command, `nil` to use default.
69
+ # @param [Boolean] dm_permission Whether the command is available in DM.
70
+ # @param [Discorb::Permission] default_permission The default permission of the command.
71
+ #
72
+ # @yield Block to yield with the command.
73
+ # @yieldparam [Discorb::ApplicationCommand::Command::GroupCommand] group Group command.
74
+ #
75
+ # @return [Discorb::ApplicationCommand::Command::GroupCommand] Command object.
76
+ #
77
+ # @see file:docs/application_command.md Application Commands
78
+ # @see file:docs/cli/setup.md CLI: setup
79
+ def slash_group: (
80
+ Discorb::ApplicationCommand::localizable command_name,
81
+ Discorb::ApplicationCommand::localizable description,
82
+ ?guild_ids: Discorb::ApplicationCommand::guild_ids?,
83
+ ?dm_permission: bool,
84
+ ?default_permission: Discorb::Permission?
85
+ ) ?{
86
+ (Discorb::ApplicationCommand::Command::GroupCommand group) -> void
87
+ } -> Discorb::ApplicationCommand::Command::GroupCommand
88
+
89
+ #
90
+ # Add message context menu command.
91
+ #
92
+ # @param [String, Hash{Symbol => String}] command_name Command name.
93
+ # @param [Array<#to_s>, false, nil] guild_ids
94
+ # Guild IDs to set the command to. `false` to global command, `nil` to use default.
95
+ # @param [Boolean] dm_permission Whether the command is available in DM.
96
+ # @param [Discorb::Permission] default_permission The default permission of the command.
97
+ # @param [Proc] block Command block.
98
+ # @yield [interaction, message] Block to execute.
99
+ # @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
100
+ # @yieldparam [Discorb::Message] message Message object.
101
+ #
102
+ # @return [Discorb::ApplicationCommand::Command] Command object.
103
+ def message_command: (
104
+ Discorb::ApplicationCommand::localizable command_name,
105
+ ?guild_ids: Discorb::ApplicationCommand::guild_ids?,
106
+ ?dm_permission: bool,
107
+ ?default_permission: Discorb::Permission?
108
+ ) {
109
+ (
110
+ Discorb::CommandInteraction::UserMenuCommand interaction,
111
+ Discorb::Message message
112
+ ) -> void
113
+ } -> Discorb::ApplicationCommand::Command
114
+
115
+ #
116
+ # Add user context menu command.
117
+ #
118
+ # @param [String, Hash{Symbol => String}] command_name Command name.
119
+ # @param [Array<#to_s>, false, nil] guild_ids
120
+ # Guild IDs to set the command to. `false` to global command, `nil` to use default.
121
+ # @param [Boolean] dm_permission Whether the command is available in DM.
122
+ # @param [Discorb::Permission] default_permission The default permission of the command.
123
+ # @param [Proc] block Command block.
124
+ # @yield [interaction, user] Block to execute.
125
+ # @yieldparam [Discorb::CommandInteraction::UserMenuCommand] interaction Interaction object.
126
+ # @yieldparam [Discorb::User] user User object.
127
+ #
128
+ # @return [Discorb::ApplicationCommand::Command] Command object.
129
+ def user_command: (
130
+ Discorb::ApplicationCommand::localizable command_name,
131
+ ?guild_ids: Discorb::ApplicationCommand::guild_ids?,
132
+ ?dm_permission: bool,
133
+ ?default_permission: Discorb::Permission?
134
+ ) ?{
135
+ (
136
+ Discorb::CommandInteraction::UserMenuCommand interaction,
137
+ Discorb::User user
138
+ ) -> void
139
+ } -> Discorb::ApplicationCommand::Command
140
+
141
+ #
142
+ # Setup commands.
143
+ # @async
144
+ # @see Client#initialize
145
+ #
146
+ # @param [String] token Bot token.
147
+ # @param [Array<#to_s>, false, nil] guild_ids
148
+ # Guild IDs to use as default. If `false` is given, it will be global command.
149
+ #
150
+ # @note `token` parameter only required if you don't run client.
151
+ def setup_commands: (
152
+ ?String? token,
153
+ ?guild_ids: Discorb::ApplicationCommand::guild_ids?
154
+ ) -> untyped
155
+
156
+ #
157
+ # Claer commands in specified guilds.
158
+ # @async
159
+ # @see Client#initialize
160
+ #
161
+ # @param [String] token Bot token.
162
+ # @param [Array<#to_s>, false, nil] guild_ids Guild IDs to clear.
163
+ #
164
+ # @note `token` parameter only required if you don't run client.
165
+ def clear_commands: (
166
+ String token,
167
+ Discorb::ApplicationCommand::guild_ids guild_ids
168
+ ) -> untyped
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,146 @@
1
+ module Discorb
2
+ #
3
+ # Represents a Discord application.
4
+ class Application < Discorb::DiscordModel
5
+ #
6
+ # Initializes a new instance of the Application class.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client that instantiated the object.
10
+ # @param [Hash] data The data of the object.
11
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
12
+
13
+ %a{pure}
14
+ def inspect: -> String
15
+
16
+ # @return [Discorb::Snowflake] The application's ID.
17
+ attr_reader id: Discorb::Snowflake
18
+
19
+ # @return [String] The application's name.
20
+ attr_reader name: String
21
+
22
+ # @return [Discorb::Asset] The application's icon.
23
+ attr_reader icon: Discorb::Asset
24
+
25
+ # @return [String] The application's description.
26
+ attr_reader description: String
27
+
28
+ # @return [String] The application's summary.
29
+ attr_reader summary: String
30
+
31
+ # @return [String] The application's public key.
32
+ attr_reader verify_key: String
33
+
34
+ # @return [Discorb::User] The application's owner.
35
+ attr_reader owner: Discorb::User
36
+
37
+ # @return [Discorb::Application::Team] The application's team.
38
+ attr_reader team: Discorb::Application::Team
39
+
40
+ # @return [Boolean] Whether the application's bot is public.
41
+ attr_reader bot_public: bool
42
+
43
+ # @return [Boolean] Whether the application's bot requires a code grant.
44
+ attr_reader bot_require_code_grant: bool
45
+
46
+ # @return [Discorb::Application::Flag] The application's flags.
47
+ attr_reader flags: Discorb::Application::Flag
48
+
49
+ #
50
+ # Represents a flag for an application.
51
+ # ## Flag fields
52
+ #
53
+ # | Field|Value|
54
+ # |---|---|
55
+ # | `1 << 12` | `:gateway_presence` |
56
+ # | `1 << 13` | `:gateway_presence_limited` |
57
+ # | `1 << 14` | `:gateway_guild_members` |
58
+ # | `1 << 15` | `:gateway_guild_members_limited` |
59
+ # | `1 << 16` | `:verification_pending_guild_limit` |
60
+ # | `1 << 17` | `:embedded` |
61
+ # | `1 << 18` | `:gateway_message_content` |
62
+ # | `1 << 19` | `:gateway_message_content_limited` |
63
+ class Flag < Discorb::Flag
64
+ attr_accessor gateway_presence: bool
65
+ attr_accessor gateway_presence_limited: bool
66
+ attr_accessor gateway_guild_members: bool
67
+ attr_accessor gateway_guild_members_limited: bool
68
+ attr_accessor verification_pending_guild_limit: bool
69
+ attr_accessor embedded: bool
70
+ attr_accessor gateway_message_content: bool
71
+ attr_accessor gateway_message_content_limited: bool
72
+ end
73
+
74
+ #
75
+ # Represents a team for an application.
76
+ class Team < Discorb::DiscordModel
77
+ #
78
+ # Initializes a new instance of the Team class.
79
+ # @private
80
+ #
81
+ # @param [Discorb::Client] client The client that instantiated the object.
82
+ # @param [Hash] data The data of the object.
83
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
84
+
85
+ #
86
+ # The team's owner.
87
+ #
88
+ # @return [Discorb::Application::Team::Member] The team's owner.
89
+ %a{pure}
90
+ def owner: -> Discorb::Application::Team::Member
91
+
92
+ %a{pure}
93
+ def inspect: -> String
94
+
95
+ # @return [Discorb::Snowflake] The team's ID.
96
+ attr_reader id: Discorb::Snowflake
97
+
98
+ # @return [Discorb::Asset] The team's icon.
99
+ attr_reader icon: Discorb::Asset
100
+
101
+ # @return [String] The team's name.
102
+ attr_reader name: String
103
+
104
+ # @return [Discorb::Snowflake] The team's owner's ID.
105
+ attr_reader owner_user_id: Discorb::Snowflake
106
+
107
+ # @return [Discorb::Application::Team::Member] The team's member.
108
+ attr_reader members: Discorb::Application::Team::Member
109
+
110
+ #
111
+ # Represents a member of team.
112
+ class Member < Discorb::DiscordModel
113
+ MEMBERSHIP_STATE: untyped
114
+
115
+ def initialize: (untyped client, untyped team, untyped data) -> void
116
+
117
+ %a{pure}
118
+ def inspect: -> String
119
+
120
+ def ==: (untyped other) -> untyped
121
+
122
+ # @return [Discorb::User] The user.
123
+ attr_reader user: Discorb::User
124
+
125
+ # @return [Snowflake] The ID of member's team.
126
+ attr_reader team_id: Snowflake
127
+
128
+ # @return [:invited, :accepted] The member's membership state.
129
+ attr_reader membership_state: Symbol
130
+
131
+ # @return [Array<Symbol>] The permissions of the member.
132
+ # @note This always return `:*`.
133
+ attr_reader permissions: ::Array[Symbol]
134
+
135
+ # @return [Boolean] Whether the member is not joined to the team.
136
+ attr_reader pending?: bool
137
+
138
+ # @return [Boolean] Whether the member accepted joining the team.
139
+ attr_reader accepted?: bool
140
+
141
+ # @return [Boolean] Whether the member is the team's owner.
142
+ attr_reader owner?: bool
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,34 @@
1
+ module Discorb
2
+ #
3
+ # Represents a single asset.
4
+ class Asset < Discorb::DiscordModel
5
+ #
6
+ # Initialize a new instance of the Asset class.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client that instantiated the object.
10
+ # @param [Hash] data The data of the object.
11
+ def initialize: (untyped target, untyped hash, ?path: untyped) -> void
12
+
13
+ #
14
+ # URL of the asset.
15
+ #
16
+ # @param [String] image_format The image format.
17
+ # @param [Integer] size The size of the image.
18
+ #
19
+ # @return [String] URL of the asset.
20
+ def url: (?image_format: String?, ?size: Integer) -> String
21
+
22
+ %a{pure}
23
+ def inspect: -> String
24
+
25
+ %a{pure}
26
+ def endpoint: -> untyped
27
+
28
+ # @return [String] The hash of asset.
29
+ attr_reader hash: String
30
+
31
+ # @return [Boolean] Whether the asset is animated.
32
+ attr_reader animated?: bool
33
+ end
34
+ end