discorb 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/build_main.yml +2 -2
  4. data/.github/workflows/build_version.yml +1 -1
  5. data/.github/workflows/codeql-analysis.yml +1 -1
  6. data/.github/workflows/lint-push.yml +3 -5
  7. data/.github/workflows/lint.yml +2 -4
  8. data/.github/workflows/spec.yml +33 -0
  9. data/.github/workflows/validate.yml +21 -0
  10. data/.gitignore +2 -0
  11. data/.lefthook/commit-msg/validator.rb +5 -0
  12. data/.rspec +2 -0
  13. data/.rspec_parallel +2 -0
  14. data/.rubocop.yml +43 -6
  15. data/Changelog.md +30 -1
  16. data/Gemfile +20 -8
  17. data/Rakefile +226 -98
  18. data/Steepfile +28 -0
  19. data/bin/console +3 -3
  20. data/docs/Examples.md +1 -1
  21. data/docs/application_command.md +156 -47
  22. data/docs/cli/irb.md +2 -2
  23. data/docs/cli/new.md +14 -9
  24. data/docs/cli/run.md +7 -11
  25. data/docs/cli.md +17 -10
  26. data/docs/events.md +247 -213
  27. data/docs/extension.md +1 -2
  28. data/docs/faq.md +0 -1
  29. data/docs/tutorial.md +18 -18
  30. data/docs/voice_events.md +106 -106
  31. data/examples/commands/message.rb +68 -0
  32. data/examples/commands/permission.rb +19 -0
  33. data/examples/commands/slash.rb +48 -0
  34. data/examples/commands/user.rb +54 -0
  35. data/examples/components/authorization_button.rb +4 -3
  36. data/examples/components/select_menu.rb +6 -3
  37. data/examples/extension/main.rb +2 -1
  38. data/examples/extension/message_expander.rb +6 -2
  39. data/examples/sig/commands/message.rbs +5 -0
  40. data/examples/simple/eval.rb +3 -2
  41. data/examples/simple/ping_pong.rb +2 -1
  42. data/examples/simple/rolepanel.rb +17 -6
  43. data/examples/simple/shard.rb +3 -2
  44. data/examples/simple/wait_for_message.rb +4 -1
  45. data/exe/discorb +33 -18
  46. data/lefthook.yml +45 -0
  47. data/lib/discorb/allowed_mentions.rb +2 -1
  48. data/lib/discorb/app_command/command.rb +130 -72
  49. data/lib/discorb/app_command/common.rb +25 -0
  50. data/lib/discorb/app_command/handler.rb +130 -33
  51. data/lib/discorb/app_command.rb +2 -1
  52. data/lib/discorb/application.rb +1 -0
  53. data/lib/discorb/asset.rb +1 -2
  54. data/lib/discorb/attachment.rb +1 -1
  55. data/lib/discorb/audit_logs.rb +19 -10
  56. data/lib/discorb/automod.rb +269 -0
  57. data/lib/discorb/channel/base.rb +108 -0
  58. data/lib/discorb/channel/category.rb +32 -0
  59. data/lib/discorb/channel/container.rb +44 -0
  60. data/lib/discorb/channel/dm.rb +28 -0
  61. data/lib/discorb/channel/guild.rb +246 -0
  62. data/lib/discorb/channel/stage.rb +140 -0
  63. data/lib/discorb/channel/text.rb +336 -0
  64. data/lib/discorb/channel/thread.rb +325 -0
  65. data/lib/discorb/channel/voice.rb +79 -0
  66. data/lib/discorb/channel.rb +2 -1165
  67. data/lib/discorb/client.rb +50 -36
  68. data/lib/discorb/color.rb +37 -60
  69. data/lib/discorb/common.rb +2 -1
  70. data/lib/discorb/components/button.rb +2 -1
  71. data/lib/discorb/components/select_menu.rb +4 -2
  72. data/lib/discorb/components/text_input.rb +12 -2
  73. data/lib/discorb/components.rb +1 -1
  74. data/lib/discorb/dictionary.rb +1 -1
  75. data/lib/discorb/embed.rb +26 -10
  76. data/lib/discorb/emoji.rb +31 -4
  77. data/lib/discorb/emoji_table.rb +4969 -3
  78. data/lib/discorb/event.rb +29 -4
  79. data/lib/discorb/exe/about.rb +2 -1
  80. data/lib/discorb/exe/irb.rb +2 -4
  81. data/lib/discorb/exe/new.rb +89 -26
  82. data/lib/discorb/exe/run.rb +8 -22
  83. data/lib/discorb/exe/setup.rb +25 -12
  84. data/lib/discorb/exe/show.rb +4 -3
  85. data/lib/discorb/extend.rb +1 -0
  86. data/lib/discorb/extension.rb +6 -7
  87. data/lib/discorb/flag.rb +13 -2
  88. data/lib/discorb/gateway.rb +79 -589
  89. data/lib/discorb/gateway_events.rb +638 -0
  90. data/lib/discorb/guild.rb +318 -67
  91. data/lib/discorb/guild_template.rb +11 -5
  92. data/lib/discorb/http.rb +53 -24
  93. data/lib/discorb/integration.rb +4 -1
  94. data/lib/discorb/intents.rb +28 -19
  95. data/lib/discorb/interaction/autocomplete.rb +28 -16
  96. data/lib/discorb/interaction/command.rb +42 -14
  97. data/lib/discorb/interaction/components.rb +5 -2
  98. data/lib/discorb/interaction/modal.rb +0 -1
  99. data/lib/discorb/interaction/response.rb +125 -26
  100. data/lib/discorb/interaction/root.rb +13 -13
  101. data/lib/discorb/interaction.rb +1 -0
  102. data/lib/discorb/invite.rb +5 -2
  103. data/lib/discorb/member.rb +28 -8
  104. data/lib/discorb/message.rb +60 -25
  105. data/lib/discorb/message_meta.rb +3 -3
  106. data/lib/discorb/modules.rb +59 -16
  107. data/lib/discorb/presence.rb +2 -0
  108. data/lib/discorb/rate_limit.rb +7 -2
  109. data/lib/discorb/reaction.rb +2 -2
  110. data/lib/discorb/role.rb +20 -5
  111. data/lib/discorb/shard.rb +1 -1
  112. data/lib/discorb/sticker.rb +9 -8
  113. data/lib/discorb/user.rb +4 -3
  114. data/lib/discorb/utils/colored_puts.rb +1 -0
  115. data/lib/discorb/voice_state.rb +6 -2
  116. data/lib/discorb/webhook.rb +64 -31
  117. data/lib/discorb.rb +7 -5
  118. data/po/yard.pot +20 -20
  119. data/rbs_collection.lock.yaml +88 -0
  120. data/rbs_collection.yaml +21 -0
  121. data/sig/async.rbs +11 -0
  122. data/sig/discorb/activity.rbs +23 -0
  123. data/sig/discorb/allowed_mentions.rbs +44 -0
  124. data/sig/discorb/app_command/base.rbs +282 -0
  125. data/sig/discorb/app_command/handler.rbs +171 -0
  126. data/sig/discorb/application.rbs +142 -0
  127. data/sig/discorb/asset.rbs +32 -0
  128. data/sig/discorb/attachment.rbs +91 -0
  129. data/sig/discorb/audit_log.rbs +231 -0
  130. data/sig/discorb/automod.rbs +128 -0
  131. data/sig/discorb/avatar.rbs +26 -0
  132. data/sig/discorb/channel/base.rbs +179 -0
  133. data/sig/discorb/channel/category.rbs +56 -0
  134. data/sig/discorb/channel/container.rbs +29 -0
  135. data/sig/discorb/channel/dm.rbs +14 -0
  136. data/sig/discorb/channel/news.rbs +20 -0
  137. data/sig/discorb/channel/stage.rbs +77 -0
  138. data/sig/discorb/channel/text.rbs +158 -0
  139. data/sig/discorb/channel/thread.rbs +185 -0
  140. data/sig/discorb/channel/voice.rbs +41 -0
  141. data/sig/discorb/client.rbs +2495 -0
  142. data/sig/discorb/color.rbs +142 -0
  143. data/sig/discorb/component/base.rbs +28 -0
  144. data/sig/discorb/component/button.rbs +65 -0
  145. data/sig/discorb/component/select_menu.rbs +107 -0
  146. data/sig/discorb/component/text_input.rbs +69 -0
  147. data/sig/discorb/connectable.rbs +8 -0
  148. data/sig/discorb/custom_emoji.rbs +90 -0
  149. data/sig/discorb/dictionary.rbs +85 -0
  150. data/sig/discorb/discord_model.rbs +15 -0
  151. data/sig/discorb/embed.rbs +279 -0
  152. data/sig/discorb/emoji.rbs +13 -0
  153. data/sig/discorb/error.rbs +73 -0
  154. data/sig/discorb/event_handler.rbs +27 -0
  155. data/sig/discorb/extension.rbs +1734 -0
  156. data/sig/discorb/flag.rbs +72 -0
  157. data/sig/discorb/gateway.rbs +481 -0
  158. data/sig/discorb/guild.rbs +870 -0
  159. data/sig/discorb/guild_template.rbs +174 -0
  160. data/sig/discorb/http.rbs +147 -0
  161. data/sig/discorb/image.rbs +20 -0
  162. data/sig/discorb/integration.rbs +118 -0
  163. data/sig/discorb/intents.rbs +97 -0
  164. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  165. data/sig/discorb/interaction/base.rbs +66 -0
  166. data/sig/discorb/interaction/command.rbs +66 -0
  167. data/sig/discorb/interaction/message_component.rbs +140 -0
  168. data/sig/discorb/interaction/modal.rbs +50 -0
  169. data/sig/discorb/interaction/responder.rbs +157 -0
  170. data/sig/discorb/invite.rbs +86 -0
  171. data/sig/discorb/member.rbs +187 -0
  172. data/sig/discorb/message.rbs +469 -0
  173. data/sig/discorb/messageable.rbs +153 -0
  174. data/sig/discorb/partial_emoji.rbs +35 -0
  175. data/sig/discorb/permissions.rbs +149 -0
  176. data/sig/discorb/presence.rbs +237 -0
  177. data/sig/discorb/reaction.rbs +33 -0
  178. data/sig/discorb/role.rbs +145 -0
  179. data/sig/discorb/scheduled_event.rbs +148 -0
  180. data/sig/discorb/shard.rbs +62 -0
  181. data/sig/discorb/snowflake.rbs +56 -0
  182. data/sig/discorb/stage_instance.rbs +63 -0
  183. data/sig/discorb/sticker.rbs +116 -0
  184. data/sig/discorb/system_channel_flag.rbs +17 -0
  185. data/sig/discorb/unicode_emoji.rbs +49 -0
  186. data/sig/discorb/user.rbs +93 -0
  187. data/sig/discorb/utils.rbs +8 -0
  188. data/sig/discorb/voice_region.rbs +30 -0
  189. data/sig/discorb/voice_state.rbs +71 -0
  190. data/sig/discorb/webhook.rbs +327 -0
  191. data/sig/discorb/welcome_screen.rbs +78 -0
  192. data/sig/discorb.rbs +6 -7230
  193. data/sig/manifest.yaml +3 -0
  194. data/sig/override.rbs +19 -0
  195. data/template-replace/files/css/common.css +4 -0
  196. metadata +102 -6
  197. data/examples/commands/bookmarker.rb +0 -42
  198. data/examples/commands/hello.rb +0 -10
  199. data/examples/commands/inspect.rb +0 -25
@@ -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
@@ -0,0 +1,91 @@
1
+ module Discorb
2
+ #
3
+ # Represents a attachment file.
4
+ class Attachment
5
+ #
6
+ # Creates a new attachment.
7
+ #
8
+ # @param [#read, String] source The Source of the attachment.
9
+ # @param [String] filename The filename of the attachment. If not set, path or object_id of the IO is used.
10
+ # @param [String] description The description of the attachment.
11
+ # @param [String] content_type The content type of the attachment. If not set, it is guessed from the filename.
12
+ # If failed to guess, it is set to `application/octet-stream`.
13
+ # @param [Boolean] will_close Whether the IO will be closed after the attachment is sent.
14
+ def initialize: (
15
+ untyped | String source,
16
+ ?String? filename,
17
+ ?description: String?,
18
+ ?content_type: String?,
19
+ ?will_close: bool
20
+ ) -> void
21
+
22
+ #
23
+ # Initializes the object from a hash.
24
+ # @private
25
+ def initialize_hash: (untyped data) -> untyped
26
+
27
+ def inspect: -> String
28
+
29
+ #
30
+ # Creates a new file from a hash.
31
+ # @private
32
+ def self.from_hash: (untyped data) -> untyped
33
+
34
+ #
35
+ # Creates a new file from a string.
36
+ #
37
+ # @param [String] string The string to create the file from.
38
+ # @param [String] filename The filename of the file. object_id of the string is used if not set.
39
+ # @param [String] content_type The content type of the file. If not set, it is guessed from the filename.
40
+ #
41
+ # @return [Discorb::Attachment] The new file.
42
+ def self.from_string: (
43
+ String string,
44
+ ?String? filename,
45
+ ?content_type: String?,
46
+ ?description: untyped
47
+ ) -> Discorb::Attachment
48
+
49
+ # @return [#read] The file content.
50
+ attr_reader io: untyped
51
+
52
+ # @return [String] The attachment filename.
53
+ attr_reader filename: String
54
+
55
+ # @return [String] The attachment content type.
56
+ attr_reader content_type: String
57
+
58
+ # @return [String] The attachment description.
59
+ attr_reader description: String?
60
+
61
+ # @return [Discorb::Snowflake] The attachment id.
62
+ attr_reader id: Discorb::Snowflake
63
+
64
+ # @return [Integer] The attachment size in bytes.
65
+ attr_reader size: Integer
66
+
67
+ # @return [String] The attachment url.
68
+ attr_reader url: String
69
+
70
+ # @return [String] The attachment proxy url.
71
+ attr_reader proxy_url: String
72
+
73
+ # @return [Integer] The image height.
74
+ # @return [nil] If the attachment is not an image.
75
+ attr_reader height: Integer?
76
+
77
+ # @return [Integer] The image width.
78
+ # @return [nil] If the attachment is not an image.
79
+ attr_reader width: Integer?
80
+
81
+ # @return [:client, :discord] The attachment was created by.
82
+ attr_reader created_by: :client | :discord
83
+
84
+ # @private
85
+ # @return [Boolean] Whether the attachment will be closed after it is sent.
86
+ attr_reader will_close: bool
87
+
88
+ # @return [Boolean] whether the file is an image.
89
+ attr_reader image?: bool
90
+ end
91
+ end
@@ -0,0 +1,231 @@
1
+ module Discorb
2
+ #
3
+ # Represents a Discord audit log.
4
+ class AuditLog < Discorb::DiscordModel
5
+ #
6
+ # Initializes a new instance of the AuditLog class.
7
+ # @private
8
+ def initialize: (untyped client, untyped data, untyped guild) -> void
9
+
10
+ def inspect: -> String
11
+
12
+ #
13
+ # Gets an entry from entries.
14
+ #
15
+ # @param [Integer] index The index of the entry.
16
+ #
17
+ # @return [Discorb::AuditLog::Entry] The entry.
18
+ # @return [nil] If the index is out of range.
19
+ def []: (Integer index) -> Discorb::AuditLog::Entry
20
+
21
+ # @return [Array<Discorb::Webhook>] The webhooks in this audit log.
22
+ attr_reader webhooks: ::Array[Discorb::Webhook]
23
+
24
+ # @return [Array<Discorb::User>] The users in this audit log.
25
+ attr_reader users: ::Array[Discorb::User]
26
+
27
+ # @return [Array<Discorb::ThreadChannel>] The threads in this audit log.
28
+ attr_reader threads: ::Array[Discorb::ThreadChannel]
29
+
30
+ # @return [Array<Discorb::AuditLog::Entry>] The entries in this audit log.
31
+ attr_reader entries: ::Array[Discorb::AuditLog::Entry]
32
+
33
+ #
34
+ # Represents an entry in an audit log.
35
+ class Entry < Discorb::DiscordModel
36
+ EVENTS: untyped
37
+ CONVERTERS: untyped
38
+
39
+ #
40
+ # Initializes a new AuditLog entry.
41
+ # @private
42
+ def initialize: (untyped client, untyped data, _ToS guild_id) -> void
43
+
44
+ #
45
+ # Get a change with the given key.
46
+ #
47
+ # @param [Symbol] key The key to get.
48
+ #
49
+ # @return [Discorb::AuditLog::Entry::Change] The change with the given key.
50
+ # @return [nil] The change with the given key does not exist.
51
+ def []: (Symbol key) -> Discorb::AuditLog::Entry::Change
52
+
53
+ def inspect: -> String
54
+
55
+ # @return [Discorb::Snowflake] The ID of the entry.
56
+ attr_reader id: Discorb::Snowflake
57
+
58
+ # @return [Discorb::Snowflake] The ID of the user who performed the action.
59
+ attr_reader user_id: Discorb::Snowflake
60
+
61
+ # @return [Discorb::Snowflake] The ID of the target of the action.
62
+ attr_reader target_id: Discorb::Snowflake
63
+
64
+ # @return [Symbol] The type of the entry.
65
+ # These symbols will be used:
66
+ #
67
+ # * `:guild_update`
68
+ # * `:channel_create`
69
+ # * `:channel_update`
70
+ # * `:channel_delete`
71
+ # * `:channel_overwrite_create`
72
+ # * `:channel_overwrite_update`
73
+ # * `:channel_overwrite_delete`
74
+ # * `:member_kick`
75
+ # * `:member_prune`
76
+ # * `:member_ban_add`
77
+ # * `:member_ban_remove`
78
+ # * `:member_update`
79
+ # * `:member_role_update`
80
+ # * `:member_move`
81
+ # * `:member_disconnect`
82
+ # * `:bot_add`
83
+ # * `:role_create`
84
+ # * `:role_update`
85
+ # * `:role_delete`
86
+ # * `:invite_create`
87
+ # * `:invite_update`
88
+ # * `:invite_delete`
89
+ # * `:webhook_create`
90
+ # * `:webhook_update`
91
+ # * `:webhook_delete`
92
+ # * `:emoji_create`
93
+ # * `:emoji_update`
94
+ # * `:emoji_delete`
95
+ # * `:message_delete`
96
+ # * `:message_bulk_delete`
97
+ # * `:message_pin`
98
+ # * `:message_unpin`
99
+ # * `:integration_create`
100
+ # * `:integration_update`
101
+ # * `:integration_delete`
102
+ # * `:stage_instance_create`
103
+ # * `:stage_instance_update`
104
+ # * `:stage_instance_delete`
105
+ # * `:sticker_create`
106
+ # * `:sticker_update`
107
+ # * `:sticker_delete`
108
+ # * `:guild_scheduled_event_create`
109
+ # * `:guild_scheduled_event_update`
110
+ # * `:guild_scheduled_event_delete`
111
+ # * `:thread_create`
112
+ # * `:thread_update`
113
+ # * `:thread_delete`
114
+ # * `:application_command_permission_update``
115
+ attr_reader type: Symbol
116
+
117
+ # @return [Discorb::AuditLog::Entry::Changes] The changes in this entry.
118
+ attr_reader changes: Discorb::AuditLog::Entry::Changes
119
+
120
+ # @return [Discorb::Channel, Discorb::Role, Discorb::Member, Discorb::Guild, Discorb::Message]
121
+ # The target of the entry.
122
+ attr_reader target: Discorb::Channel
123
+ | Discorb::Role
124
+ | Discorb::Member
125
+ | Discorb::Guild
126
+ | Discorb::Message
127
+ | Discorb::Snowflake
128
+
129
+ # @return [Hash{Symbol => Object}] The optional data for this entry.
130
+ # @note You can use dot notation to access the data.
131
+ attr_reader options: ::Hash[Symbol, Object]
132
+
133
+ # @return [Discorb::User] The user who performed the action.
134
+ attr_reader user: Discorb::User
135
+
136
+ #
137
+ # Represents the changes in an audit log entry.
138
+ class Changes < Discorb::DiscordModel
139
+ #
140
+ # Initializes a new changes object.
141
+ # @private
142
+ #
143
+ # @param [Hash] data The data to initialize with.
144
+ def initialize: (Discorb::json data) -> void
145
+
146
+ #
147
+ # Formats the changes into a string.
148
+ def inspect: -> String
149
+
150
+ #
151
+ # Get keys of changes.
152
+ #
153
+ # @return [Array<Symbol>] The keys of the changes.
154
+ def keys: -> ::Array[Symbol]
155
+
156
+ #
157
+ # Get a change with the given key.
158
+ #
159
+ # @param [Symbol] key The key to get.
160
+ #
161
+ # @return [Discorb::AuditLog::Entry::Change] The change with the given key.
162
+ # @return [nil] The change with the given key does not exist.
163
+ def []: (Symbol key) -> Discorb::AuditLog::Entry::Change
164
+
165
+ # Returns the value of attribute data.
166
+ attr_reader data: untyped
167
+ end
168
+
169
+ #
170
+ # Represents a change in an audit log entry.
171
+ # @note This instance will try to call a method of {#new_value} if the method wasn't defined.
172
+ class Change < Discorb::DiscordModel
173
+ #
174
+ # Initializes a new change object.
175
+ # @private
176
+ def initialize: (untyped data) -> void
177
+
178
+ #
179
+ # Send a message to the new value.
180
+ def method_missing: (untyped method) -> untyped
181
+
182
+ #
183
+ # Format the change into a string.
184
+ #
185
+ # @return [String] The string representation of the change.
186
+ def inspect: -> String
187
+
188
+ #
189
+ # Whether the change responds to the given method.
190
+ #
191
+ # @return [Boolean] Whether the change responds to the given method.
192
+ def respond_to_missing?: (
193
+ untyped method,
194
+ ?untyped include_private
195
+ ) -> bool
196
+
197
+ # @return [Symbol] The key of the change.
198
+ attr_reader key: Symbol
199
+
200
+ # @return [Object] The old value of the change.
201
+ attr_reader old_value: Object
202
+
203
+ # @return [Object] The new value of the change.
204
+ attr_reader new_value: Object
205
+ end
206
+ end
207
+
208
+ #
209
+ # Represents an integration in an audit log entry.
210
+ class Integration < Discorb::DiscordModel
211
+ #
212
+ # Initializes a new integration object.
213
+ # @private
214
+ def initialize: (untyped data) -> void
215
+
216
+ def inspect: -> String
217
+
218
+ # @return [Discorb::Snowflake] The ID of the integration.
219
+ attr_reader id: Discorb::Snowflake
220
+
221
+ # @return [Symbol] The type of the integration.
222
+ attr_reader type: Symbol
223
+
224
+ # @return [String] The name of the integration.
225
+ attr_reader name: String
226
+
227
+ # @return [Discorb::Integration::Account] The account of the integration.
228
+ attr_reader account: Discorb::Integration::Account
229
+ end
230
+ end
231
+ end