discorb 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) 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 +10 -0
  5. data/Gemfile +6 -0
  6. data/Rakefile +210 -98
  7. data/Steepfile +28 -0
  8. data/docs/events.md +42 -6
  9. data/docs/tutorial.md +7 -7
  10. data/docs/voice_events.md +2 -2
  11. data/examples/commands/message.rb +12 -7
  12. data/examples/commands/permission.rb +2 -1
  13. data/examples/commands/slash.rb +23 -19
  14. data/examples/commands/user.rb +15 -12
  15. data/examples/components/authorization_button.rb +2 -1
  16. data/examples/components/select_menu.rb +4 -1
  17. data/examples/extension/main.rb +1 -0
  18. data/examples/extension/message_expander.rb +1 -0
  19. data/examples/sig/commands/message.rbs +5 -0
  20. data/examples/simple/eval.rb +1 -0
  21. data/examples/simple/ping_pong.rb +1 -0
  22. data/examples/simple/rolepanel.rb +16 -5
  23. data/examples/simple/shard.rb +2 -1
  24. data/examples/simple/wait_for_message.rb +3 -0
  25. data/exe/discorb +3 -3
  26. data/lib/discorb/allowed_mentions.rb +1 -1
  27. data/lib/discorb/app_command/command.rb +12 -13
  28. data/lib/discorb/app_command/handler.rb +20 -6
  29. data/lib/discorb/audit_logs.rb +6 -2
  30. data/lib/discorb/automod.rb +269 -0
  31. data/lib/discorb/channel/guild.rb +2 -1
  32. data/lib/discorb/channel/stage.rb +1 -1
  33. data/lib/discorb/channel/text.rb +11 -20
  34. data/lib/discorb/channel/thread.rb +15 -11
  35. data/lib/discorb/client.rb +12 -10
  36. data/lib/discorb/color.rb +37 -60
  37. data/lib/discorb/common.rb +1 -1
  38. data/lib/discorb/dictionary.rb +1 -1
  39. data/lib/discorb/embed.rb +4 -3
  40. data/lib/discorb/emoji.rb +2 -2
  41. data/lib/discorb/exe/about.rb +1 -1
  42. data/lib/discorb/exe/new.rb +1 -5
  43. data/lib/discorb/extension.rb +0 -4
  44. data/lib/discorb/flag.rb +2 -2
  45. data/lib/discorb/gateway.rb +21 -582
  46. data/lib/discorb/gateway_events.rb +638 -0
  47. data/lib/discorb/guild.rb +136 -17
  48. data/lib/discorb/guild_template.rb +1 -1
  49. data/lib/discorb/http.rb +47 -25
  50. data/lib/discorb/intents.rb +27 -18
  51. data/lib/discorb/interaction/command.rb +14 -10
  52. data/lib/discorb/interaction/response.rb +74 -14
  53. data/lib/discorb/member.rb +3 -3
  54. data/lib/discorb/message.rb +13 -11
  55. data/lib/discorb/message_meta.rb +2 -3
  56. data/lib/discorb/modules.rb +3 -2
  57. data/lib/discorb/presence.rb +4 -2
  58. data/lib/discorb/reaction.rb +2 -2
  59. data/lib/discorb/role.rb +1 -1
  60. data/lib/discorb/sticker.rb +3 -3
  61. data/lib/discorb/user.rb +2 -2
  62. data/lib/discorb/voice_state.rb +5 -5
  63. data/lib/discorb/webhook.rb +15 -6
  64. data/lib/discorb.rb +2 -2
  65. data/rbs_collection.lock.yaml +88 -96
  66. data/rbs_collection.yaml +21 -17
  67. data/sig/async.rbs +11 -5
  68. data/sig/discorb/activity.rbs +23 -0
  69. data/sig/discorb/allowed_mentions.rbs +44 -0
  70. data/sig/discorb/app_command/base.rbs +282 -0
  71. data/sig/discorb/app_command/handler.rbs +171 -0
  72. data/sig/discorb/application.rbs +142 -0
  73. data/sig/discorb/asset.rbs +32 -0
  74. data/sig/discorb/attachment.rbs +91 -0
  75. data/sig/discorb/audit_log.rbs +231 -0
  76. data/sig/discorb/automod.rbs +128 -0
  77. data/sig/discorb/avatar.rbs +26 -0
  78. data/sig/discorb/channel/base.rbs +179 -0
  79. data/sig/discorb/channel/category.rbs +56 -0
  80. data/sig/discorb/channel/container.rbs +29 -0
  81. data/sig/discorb/channel/dm.rbs +14 -0
  82. data/sig/discorb/channel/news.rbs +20 -0
  83. data/sig/discorb/channel/stage.rbs +77 -0
  84. data/sig/discorb/channel/text.rbs +158 -0
  85. data/sig/discorb/channel/thread.rbs +185 -0
  86. data/sig/discorb/channel/voice.rbs +41 -0
  87. data/sig/discorb/client.rbs +2495 -0
  88. data/sig/discorb/color.rbs +142 -0
  89. data/sig/discorb/component/base.rbs +28 -0
  90. data/sig/discorb/component/button.rbs +65 -0
  91. data/sig/discorb/component/select_menu.rbs +107 -0
  92. data/sig/discorb/component/text_input.rbs +69 -0
  93. data/sig/discorb/connectable.rbs +8 -0
  94. data/sig/discorb/custom_emoji.rbs +90 -0
  95. data/sig/discorb/dictionary.rbs +85 -0
  96. data/sig/discorb/discord_model.rbs +15 -0
  97. data/sig/discorb/embed.rbs +279 -0
  98. data/sig/discorb/emoji.rbs +13 -0
  99. data/sig/discorb/error.rbs +73 -0
  100. data/sig/discorb/event_handler.rbs +27 -0
  101. data/sig/discorb/extension.rbs +1734 -0
  102. data/sig/discorb/flag.rbs +72 -0
  103. data/sig/discorb/gateway.rbs +481 -0
  104. data/sig/discorb/guild.rbs +870 -0
  105. data/sig/discorb/guild_template.rbs +174 -0
  106. data/sig/discorb/http.rbs +147 -0
  107. data/sig/discorb/image.rbs +20 -0
  108. data/sig/discorb/integration.rbs +118 -0
  109. data/sig/discorb/intents.rbs +97 -0
  110. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  111. data/sig/discorb/interaction/base.rbs +66 -0
  112. data/sig/discorb/interaction/command.rbs +66 -0
  113. data/sig/discorb/interaction/message_component.rbs +140 -0
  114. data/sig/discorb/interaction/modal.rbs +50 -0
  115. data/sig/discorb/interaction/responder.rbs +157 -0
  116. data/sig/discorb/invite.rbs +86 -0
  117. data/sig/discorb/member.rbs +187 -0
  118. data/sig/discorb/message.rbs +469 -0
  119. data/sig/discorb/messageable.rbs +153 -0
  120. data/sig/discorb/partial_emoji.rbs +35 -0
  121. data/sig/discorb/permissions.rbs +149 -0
  122. data/sig/discorb/presence.rbs +237 -0
  123. data/sig/discorb/reaction.rbs +33 -0
  124. data/sig/discorb/role.rbs +145 -0
  125. data/sig/discorb/scheduled_event.rbs +148 -0
  126. data/sig/discorb/shard.rbs +62 -0
  127. data/sig/discorb/snowflake.rbs +56 -0
  128. data/sig/discorb/stage_instance.rbs +63 -0
  129. data/sig/discorb/sticker.rbs +116 -0
  130. data/sig/discorb/system_channel_flag.rbs +17 -0
  131. data/sig/discorb/unicode_emoji.rbs +49 -0
  132. data/sig/discorb/user.rbs +93 -0
  133. data/sig/discorb/utils.rbs +8 -0
  134. data/sig/discorb/voice_region.rbs +30 -0
  135. data/sig/discorb/voice_state.rbs +71 -0
  136. data/sig/discorb/webhook.rbs +327 -0
  137. data/sig/discorb/welcome_screen.rbs +78 -0
  138. data/sig/discorb.rbs +5 -8661
  139. data/sig/manifest.yaml +3 -0
  140. data/sig/override.rbs +19 -0
  141. metadata +80 -3
@@ -0,0 +1,282 @@
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
+ def to_hash: -> Discorb::json
87
+
88
+ # @return [Hash{String => String}] The name of the command.
89
+ attr_reader name: ::Hash[String, String]
90
+
91
+ # @return [Array<#to_s>] The guild ids that the command is enabled in.
92
+ attr_reader guild_ids: Discorb::ApplicationCommand::guild_ids
93
+
94
+ # @return [Proc] The block of the command.
95
+ attr_reader block: ^(Discorb::Interaction, *untyped) -> untyped
96
+
97
+ # @return [:chat_input, :user, :message] The type of the command.
98
+ attr_reader type: Symbol
99
+
100
+ # @return [Integer] The raw type of the command.
101
+ attr_reader type_raw: Integer
102
+
103
+ # @return [Discorb::Permission] The default permissions for this command.
104
+ attr_reader default_permission: Discorb::Permission?
105
+
106
+ # @return [Boolean] Whether the command is enabled in DMs.
107
+ attr_reader dm_permission: bool?
108
+
109
+ #
110
+ # Represents the slash command.
111
+ class ChatInputCommand < Discorb::ApplicationCommand::Command
112
+ #
113
+ # Initialize a new slash command.
114
+ # @private
115
+ #
116
+ # @param [String, Hash{Symbol => String}] name The name of the command.
117
+ # The hash should have `default`, and language keys.
118
+ # @param [String, Hash{Symbol => String}] description The description of the command.
119
+ # The hash should have `default`, and language keys.
120
+ # @param [Hash{String => Hash}] options The options of the command.
121
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
122
+ # @param [Proc] block The block of the command.
123
+ # @param [Integer] type The type of the command.
124
+ # @param [Discorb::ApplicationCommand::Command, nil] parent The parent command.
125
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
126
+ # @param [Discorb::Permission] default_permission The default permission of the command.
127
+ def initialize: (
128
+ Discorb::ApplicationCommand::localizable name,
129
+ Discorb::ApplicationCommand::localizable description,
130
+ Discorb::ApplicationCommand::options options,
131
+ Discorb::ApplicationCommand::guild_ids guild_ids,
132
+ ^(
133
+ Discorb::CommandInteraction::ChatInputCommand,
134
+ *untyped
135
+ ) -> untyped block,
136
+ Integer `type`,
137
+ Discorb::ApplicationCommand::Command? parent,
138
+ bool? dm_permission,
139
+ Discorb::Permission? default_permission
140
+ ) -> void
141
+
142
+ #
143
+ # Returns the commands name.
144
+ #
145
+ # @return [String] The name of the command.
146
+ def to_s: -> String
147
+
148
+ #
149
+ # Converts the object to a hash.
150
+ # @private
151
+ #
152
+ # @return [Hash] The hash represents the object.
153
+ def to_hash: -> Discorb::json
154
+
155
+ # @return [Hash{String => String}] The description of the command.
156
+ attr_reader description: ::Hash[String, String]
157
+
158
+ # @return [Hash{String => Hash}] The options of the command.
159
+ attr_reader options: ::Hash[String, ::Hash[untyped, untyped]]
160
+ end
161
+
162
+ #
163
+ # Represents the command with subcommands.
164
+ class GroupCommand < Discorb::ApplicationCommand::Command
165
+ #
166
+ # Initialize a new group command.
167
+ # @private
168
+ #
169
+ # @param [String, Hash{Symbol => String}] name The name of the command.
170
+ # @param [String, Hash{Symbol => String}] description The description of the command.
171
+ # @param [Array<#to_s>] guild_ids The guild ids that the command is enabled in.
172
+ # @param [Discorb::Client] client The client of the command.
173
+ # @param [Boolean] dm_permission Whether the command is enabled in DMs.
174
+ # @param [Discorb::Permission] default_permission The default permission of the command.
175
+ def initialize: (
176
+ Discorb::ApplicationCommand::localizable name,
177
+ Discorb::ApplicationCommand::localizable description,
178
+ Discorb::ApplicationCommand::guild_ids guild_ids,
179
+ Discorb::Client client,
180
+ bool? dm_permission,
181
+ Discorb::Permission? default_permission
182
+ ) -> void
183
+
184
+ #
185
+ # Add new subcommand.
186
+ #
187
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
188
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
189
+ def slash: (
190
+ String | ::Hash[Symbol, String] command_name,
191
+ String | ::Hash[Symbol, String] description,
192
+ ?Discorb::ApplicationCommand::options options,
193
+ ?dm_permission: bool,
194
+ ?default_permission: Discorb::Permission?
195
+ ) {
196
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
197
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
198
+
199
+ #
200
+ # Add new subcommand group.
201
+ #
202
+ # @param [String] command_name Group name.
203
+ # @param [String] description Group description.
204
+ #
205
+ # @yield Block to yield with the command.
206
+ # @yieldparam [Discorb::ApplicationCommand::Command::SubcommandGroup] group Group command.
207
+ #
208
+ # @return [Discorb::ApplicationCommand::Command::SubcommandGroup] Command object.
209
+ #
210
+ # @see file:docs/application_command.md Application Commands
211
+ def group: (
212
+ String command_name,
213
+ String description
214
+ ) ?{
215
+ (Discorb::ApplicationCommand::Command::SubcommandGroup group) -> void
216
+ } -> Discorb::ApplicationCommand::Command::SubcommandGroup
217
+
218
+ #
219
+ # Returns the command name.
220
+ #
221
+ # @return [String] The command name.
222
+ def to_s: -> String
223
+
224
+ #
225
+ # Changes the self pointer to the given object.
226
+ # @private
227
+ #
228
+ # @param [Object] instance The object to change to.
229
+ def block_replace: (Object `instance`) -> untyped
230
+
231
+ #
232
+ # Converts the object to a hash.
233
+ # @private
234
+ #
235
+ # @return [Hash] The hash represents the object.
236
+ def to_hash: -> Discorb::json
237
+
238
+ # @return [Array<Discorb::ApplicationCommand::Command>] The subcommands of the command.
239
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
240
+
241
+ # @return [String] The description of the command.
242
+ attr_reader description: ::Hash[String, String]
243
+ end
244
+
245
+ #
246
+ # Represents the subcommand group.
247
+ class SubcommandGroup < Discorb::ApplicationCommand::Command::GroupCommand
248
+ #
249
+ # Initialize a new subcommand group.
250
+ # @private
251
+ #
252
+ # @param [String] name The name of the command.
253
+ # @param [String] description The description of the command.
254
+ # @param [Discorb::ApplicationCommand::Command::GroupCommand] parent The parent command.
255
+ # @param [Discorb::Client] client The client.
256
+ def initialize: (
257
+ String name,
258
+ String description,
259
+ Discorb::ApplicationCommand::Command::GroupCommand parent,
260
+ Discorb::Client client
261
+ ) -> void
262
+
263
+ def to_s: -> untyped
264
+
265
+ #
266
+ # Add new subcommand.
267
+ # @param (see Discorb::ApplicationCommand::Handler#slash)
268
+ # @return [Discorb::ApplicationCommand::Command::ChatInputCommand] The added subcommand.
269
+ def slash: (
270
+ Discorb::ApplicationCommand::localizable command_name,
271
+ Discorb::ApplicationCommand::localizable description,
272
+ ?Discorb::ApplicationCommand::options options
273
+ ) {
274
+ (Discorb::CommandInteraction::ChatInputCommand, *untyped) -> void
275
+ } -> Discorb::ApplicationCommand::Command::ChatInputCommand
276
+
277
+ # @return [Array<Discorb::ApplicationCommand::Command::ChatInputCommand>] The subcommands of the command.
278
+ attr_reader commands: ::Array[Discorb::ApplicationCommand::Command]
279
+ end
280
+ end
281
+ end
282
+ 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,142 @@
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
+ def inspect: -> String
14
+
15
+ # @return [Discorb::Snowflake] The application's ID.
16
+ attr_reader id: Discorb::Snowflake
17
+
18
+ # @return [String] The application's name.
19
+ attr_reader name: String
20
+
21
+ # @return [Discorb::Asset] The application's icon.
22
+ attr_reader icon: Discorb::Asset
23
+
24
+ # @return [String] The application's description.
25
+ attr_reader description: String
26
+
27
+ # @return [String] The application's summary.
28
+ attr_reader summary: String
29
+
30
+ # @return [String] The application's public key.
31
+ attr_reader verify_key: String
32
+
33
+ # @return [Discorb::User] The application's owner.
34
+ attr_reader owner: Discorb::User
35
+
36
+ # @return [Discorb::Application::Team] The application's team.
37
+ attr_reader team: Discorb::Application::Team
38
+
39
+ # @return [Boolean] Whether the application's bot is public.
40
+ attr_reader bot_public: bool
41
+
42
+ # @return [Boolean] Whether the application's bot requires a code grant.
43
+ attr_reader bot_require_code_grant: bool
44
+
45
+ # @return [Discorb::Application::Flag] The application's flags.
46
+ attr_reader flags: Discorb::Application::Flag
47
+
48
+ #
49
+ # Represents a flag for an application.
50
+ # ## Flag fields
51
+ #
52
+ # | Field|Value|
53
+ # |---|---|
54
+ # | `1 << 12` | `:gateway_presence` |
55
+ # | `1 << 13` | `:gateway_presence_limited` |
56
+ # | `1 << 14` | `:gateway_guild_members` |
57
+ # | `1 << 15` | `:gateway_guild_members_limited` |
58
+ # | `1 << 16` | `:verification_pending_guild_limit` |
59
+ # | `1 << 17` | `:embedded` |
60
+ # | `1 << 18` | `:gateway_message_content` |
61
+ # | `1 << 19` | `:gateway_message_content_limited` |
62
+ class Flag < Discorb::Flag
63
+ attr_accessor gateway_presence: bool
64
+ attr_accessor gateway_presence_limited: bool
65
+ attr_accessor gateway_guild_members: bool
66
+ attr_accessor gateway_guild_members_limited: bool
67
+ attr_accessor verification_pending_guild_limit: bool
68
+ attr_accessor embedded: bool
69
+ attr_accessor gateway_message_content: bool
70
+ attr_accessor gateway_message_content_limited: bool
71
+ end
72
+
73
+ #
74
+ # Represents a team for an application.
75
+ class Team < Discorb::DiscordModel
76
+ #
77
+ # Initializes a new instance of the Team class.
78
+ # @private
79
+ #
80
+ # @param [Discorb::Client] client The client that instantiated the object.
81
+ # @param [Hash] data The data of the object.
82
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
83
+
84
+ #
85
+ # The team's owner.
86
+ #
87
+ # @return [Discorb::Application::Team::Member] The team's owner.
88
+ def owner: -> Discorb::Application::Team::Member
89
+
90
+ def inspect: -> String
91
+
92
+ # @return [Discorb::Snowflake] The team's ID.
93
+ attr_reader id: Discorb::Snowflake
94
+
95
+ # @return [Discorb::Asset] The team's icon.
96
+ attr_reader icon: Discorb::Asset
97
+
98
+ # @return [String] The team's name.
99
+ attr_reader name: String
100
+
101
+ # @return [Discorb::Snowflake] The team's owner's ID.
102
+ attr_reader owner_user_id: Discorb::Snowflake
103
+
104
+ # @return [Discorb::Application::Team::Member] The team's member.
105
+ attr_reader members: Discorb::Application::Team::Member
106
+
107
+ #
108
+ # Represents a member of team.
109
+ class Member < Discorb::DiscordModel
110
+ MEMBERSHIP_STATE: untyped
111
+
112
+ def initialize: (untyped client, untyped team, untyped data) -> void
113
+
114
+ def inspect: -> String
115
+
116
+ def ==: (untyped other) -> untyped
117
+
118
+ # @return [Discorb::User] The user.
119
+ attr_reader user: Discorb::User
120
+
121
+ # @return [Snowflake] The ID of member's team.
122
+ attr_reader team_id: Snowflake
123
+
124
+ # @return [:invited, :accepted] The member's membership state.
125
+ attr_reader membership_state: Symbol
126
+
127
+ # @return [Array<Symbol>] The permissions of the member.
128
+ # @note This always return `:*`.
129
+ attr_reader permissions: ::Array[Symbol]
130
+
131
+ # @return [Boolean] Whether the member is not joined to the team.
132
+ attr_reader pending?: bool
133
+
134
+ # @return [Boolean] Whether the member accepted joining the team.
135
+ attr_reader accepted?: bool
136
+
137
+ # @return [Boolean] Whether the member is the team's owner.
138
+ attr_reader owner?: bool
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,32 @@
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
+ def inspect: -> String
23
+
24
+ def endpoint: -> untyped
25
+
26
+ # @return [String] The hash of asset.
27
+ attr_reader hash: String
28
+
29
+ # @return [Boolean] Whether the asset is animated.
30
+ attr_reader animated?: bool
31
+ end
32
+ end