discorb 0.16.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
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,174 @@
1
+ module Discorb
2
+ #
3
+ # Represents a guild template.
4
+ class GuildTemplate < Discorb::DiscordModel
5
+ #
6
+ # Initialize a new template.
7
+ # @private
8
+ #
9
+ # @param [Discorb::Client] client The client.
10
+ # @param [Hash] data The data from Discord.
11
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
12
+
13
+ #
14
+ # Edit the template.
15
+ # @async
16
+ # @macro edit
17
+ #
18
+ # @param [String] name The new name of the template.
19
+ # @param [String] description The new description of the template.
20
+ #
21
+ # @return [Async::Task<void>] The task.
22
+ def edit: (?String? name, ?String description) -> Async::Task[void]
23
+
24
+ #
25
+ # Update the template.
26
+ # @async
27
+ #
28
+ # @return [Async::Task<void>] The task.
29
+ def update: -> Async::Task[void]
30
+
31
+ #
32
+ # Delete the template.
33
+ # @async
34
+ #
35
+ # @return [Async::Task<void>] The task.
36
+ def delete!: -> Async::Task[void]
37
+
38
+ # @return [String] The code of the template.
39
+ attr_reader code: String
40
+
41
+ # @return [String] The name of the template.
42
+ attr_reader name: String
43
+
44
+ # @return [String] The description of the template.
45
+ attr_reader description: String
46
+
47
+ # @return [Integer] The number of times this template has been used.
48
+ attr_reader usage_count: Integer
49
+
50
+ # @return [Discorb::User] The user who created this template.
51
+ attr_reader creator: Discorb::User
52
+
53
+ # @return [Time] The time this template was created.
54
+ attr_reader created_at: Time
55
+
56
+ # @return [Time] The time this template was last updated.
57
+ attr_reader updated_at: Time
58
+
59
+ # @return [Discorb::Snowflake] The ID of guild where the template was created.
60
+ attr_reader source_guild_id: Discorb::Snowflake
61
+
62
+ # @return [Discorb::GuildTemplate::TemplateGuild] The guild where the template was created.
63
+ attr_reader serialized_source_guild: Discorb::GuildTemplate::TemplateGuild
64
+
65
+ # @return [Boolean] Whether this template is dirty.
66
+ attr_reader is_dirty: bool
67
+
68
+ # @macro client_cache
69
+ # @return [Discorb::Guild] The guild this template is based on.
70
+ # @return [nil] Client wasn't able to find the guild this template is based on.
71
+ attr_reader source_guild: Discorb::Guild?
72
+
73
+ #
74
+ # Represents a guild in guild template.
75
+ class TemplateGuild < Discorb::DiscordModel
76
+ #
77
+ # Initialize a new guild in guild template.
78
+ # @private
79
+ #
80
+ # @param [Hash] data The data from Discord.
81
+ def initialize: (Discorb::json data) -> void
82
+
83
+ # @return [String] The name of the guild.
84
+ attr_reader name: String
85
+
86
+ # @return [Integer] The AFK timeout of the guild.
87
+ attr_reader afk_timeout: Integer
88
+
89
+ # @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::Role}] A dictionary of roles in the guild.
90
+ attr_reader roles: Discorb::Dictionary[Discorb::Snowflake, Discorb::Role]
91
+
92
+ # @return [Discorb::SystemChannelFlag] The flag for the system channel.
93
+ attr_reader system_channel_flags: Discorb::SystemChannelFlag
94
+
95
+ # @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::GuildChannel}]
96
+ # A dictionary of channels in the guild.
97
+ attr_reader channels: Discorb::Dictionary[Discorb::Snowflake, Discorb::GuildChannel]
98
+
99
+ # @return [String] The description of the guild.
100
+ attr_reader description: String
101
+
102
+ # @return [Symbol] The preffered language of the guild.
103
+ # @note This modifies the language code, `-` will be replaced with `_`.
104
+ attr_reader preferred_locale: Symbol
105
+
106
+ # @return [:none, :low, :medium, :high, :very_high] The verification level of the guild.
107
+ attr_reader verification_level: Symbol
108
+
109
+ # @return [:all_messages, :only_mentions] The default message notification level of the guild.
110
+ attr_reader default_message_notifications: Symbol
111
+
112
+ # @return [:disabled_in_text, :members_without_roles, :all_members] The explict content filter level of the guild.
113
+ attr_reader explicit_content_filter: Symbol
114
+
115
+ # @return [Boolean] Whether the guild enabled the widget.
116
+ attr_reader widget_enabled: bool
117
+
118
+ #
119
+ # Represents a role in guild template.
120
+ class Role < Discorb::DiscordModel
121
+ #
122
+ # Initialize a new role in guild template.
123
+ # @private
124
+ #
125
+ # @param [Hash] data The data from Discord.
126
+ def initialize: (Discorb::json data) -> void
127
+
128
+ # @return [String] The name of the role.
129
+ attr_reader name: String
130
+
131
+ # @return [Discorb::Permission] The permissions of the role.
132
+ attr_reader permissions: Discorb::Permission
133
+
134
+ # @return [Discorb::Color] The color of the role.
135
+ attr_reader color: Discorb::Color
136
+ end
137
+
138
+ #
139
+ # Represents a channel in guild template.
140
+ class Channel < Discorb::DiscordModel
141
+ #
142
+ # Initialize a new channel in guild template.
143
+ # @private
144
+ #
145
+ # @param [Hash] data The data from Discord.
146
+ def initialize: (Discorb::json data) -> void
147
+
148
+ # @return [String] The name of the channel.
149
+ attr_reader name: String
150
+
151
+ # @return [Integer] The position of the channel.
152
+ attr_reader position: Integer
153
+
154
+ # @return [String] The type of the channel.
155
+ attr_reader topic: String
156
+
157
+ # @return [Integer] The bitrate of the channel.
158
+ attr_reader bitrate: Integer
159
+
160
+ # @return [Integer] The user limit of the channel.
161
+ attr_reader user_limit: Integer
162
+
163
+ # @return [Boolean] Whether the channel is nsfw.
164
+ attr_reader nsfw: bool
165
+
166
+ # @return [Integer] The rate limit of the channel.
167
+ attr_reader rate_limit_per_user: Integer
168
+
169
+ # @return [Class] The class of the channel.
170
+ attr_reader type: Class
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,147 @@
1
+ module Discorb
2
+ type json =
3
+ ::Hash[Symbol | String, json]
4
+ | ::Array[json]
5
+ | ::String
6
+ | ::Symbol
7
+ | ::Numeric
8
+ | bool
9
+ | nil
10
+
11
+ #
12
+ # A class to handle http requests.
13
+ # @private
14
+ class HTTP
15
+ #
16
+ # Initializes the http client.
17
+ # @private
18
+ #
19
+ # @param [Discorb::Client] client The client.
20
+ def initialize: (Discorb::Client client) -> void
21
+
22
+ #
23
+ # Execute a request.
24
+ # @async
25
+ #
26
+ # @param [Discorb::Route] path The path to the resource.
27
+ # @param [String, Hash] body The body of the request. Defaults to an empty string.
28
+ # @param [String] audit_log_reason The audit log reason to send with the request.
29
+ # @param [Hash] kwargs The keyword arguments.
30
+ #
31
+ # @return [Async::Task<Array(Net::HTTPResponse, Hash)>] The response and as JSON.
32
+ # @return [Async::Task<Array(Net::HTTPResponse, nil)>] The response was 204.
33
+ #
34
+ # @raise [Discorb::HTTPError] The request was failed.
35
+ def request: (
36
+ Discorb::Route path,
37
+ ?json | String body,
38
+ ?audit_log_reason: String?,
39
+ **String kwargs
40
+ ) -> Async::Task[[Net::HTTPResponse, json]]
41
+
42
+ #
43
+ # Execute a multipart request.
44
+ # @async
45
+ #
46
+ # @param [Discorb::Route] path The path to the resource.
47
+ # @param [String, Hash] body The body of the request.
48
+ # @param [Array<Discorb::Attachment>] files The files to upload.
49
+ # @param [Hash] headers The headers to send with the request.
50
+ # @param [String] audit_log_reason The audit log reason to send with the request.
51
+ # @param [Hash] kwargs The keyword arguments.
52
+ #
53
+ # @return [Async::Task<Array(Net::HTTPResponse, Hash)>] The response and as JSON.
54
+ # @return [Async::Task<Array(Net::HTTPResponse, nil)>] The response was 204.
55
+ #
56
+ # @raise [Discorb::HTTPError] The request was failed.
57
+ def multipart_request: (
58
+ Discorb::Route path,
59
+ json | String body,
60
+ ::Array[Discorb::Attachment] files,
61
+ ?audit_log_reason: String?,
62
+ **untyped kwargs
63
+ ) -> Async::Task[[Net::HTTPResponse, json]]
64
+
65
+ def inspect: -> String
66
+
67
+ private
68
+
69
+ def handle_response: (
70
+ Net::HTTPResponse resp,
71
+ json data,
72
+ Discorb::Route path,
73
+ json | String body,
74
+ ::Array[Discorb::Attachment]? files,
75
+ String? audit_log_reason,
76
+ untyped kwargs
77
+ ) -> [Net::HTTPResponse, json]
78
+
79
+ def get_headers: (
80
+ ?String | json body,
81
+ ?String? audit_log_reason
82
+ ) -> ::Hash[String, String]
83
+
84
+ def get_body: (nil | String | json body) -> String
85
+
86
+ def get_path: (Discorb::Route path) -> String
87
+
88
+ def get_response_data: (Net::HTTPResponse resp) -> json?
89
+
90
+ def http: -> Net::HTTP
91
+
92
+ def cdn_http: -> Net::HTTP
93
+
94
+ def recr_utf8: [O] (O data) -> O
95
+ end
96
+
97
+ #
98
+ # Represents an endpoint.
99
+ # @private
100
+ class Route
101
+ def initialize: (untyped url, untyped key, untyped method) -> void
102
+
103
+ def inspect: -> String
104
+
105
+ def hash: -> untyped
106
+
107
+ def identifier: -> untyped
108
+
109
+ def major_param: -> untyped
110
+
111
+ # Returns the value of attribute url.
112
+ attr_reader url: untyped
113
+
114
+ # Returns the value of attribute key.
115
+ attr_reader key: untyped
116
+
117
+ # Returns the value of attribute method.
118
+ attr_reader method: untyped
119
+ end
120
+
121
+ #
122
+ # Class to handle rate limiting.
123
+ # @private
124
+ class RatelimitHandler
125
+ #
126
+ # Initialize a rate limit handler.
127
+ # @private
128
+ #
129
+ # @param [Discorb::Client] client The client.
130
+ def initialize: (Discorb::Client client) -> void
131
+
132
+ def inspect: -> String
133
+
134
+ #
135
+ # Wait for the rate limit to reset.
136
+ #
137
+ # @param [Discorb::Route] path The path.
138
+ def wait: (Discorb::Route path) -> untyped
139
+
140
+ #
141
+ # Save the rate limit.
142
+ #
143
+ # @param [String] path The path.
144
+ # @param [Net::HTTPResponse] resp The response.
145
+ def save: (String path, Net::HTTPResponse resp) -> untyped
146
+ end
147
+ end
@@ -0,0 +1,20 @@
1
+ module Discorb
2
+ #
3
+ # Represents an image.
4
+ class Image
5
+ #
6
+ # Initializes a new Image.
7
+ #
8
+ # @param [#read, String] source The IO source or path of the image.
9
+ # @param [String] type The MIME type of the image.
10
+ def initialize: (untyped | String source, ?String? `type`) -> void
11
+
12
+ #
13
+ # Formats the image as a Discord style.
14
+ #
15
+ # @return [String] The image as a Discord style.
16
+ def to_s: -> String
17
+
18
+ def inspect: -> String
19
+ end
20
+ end
@@ -0,0 +1,118 @@
1
+ module Discorb
2
+ #
3
+ # Represents a integration.
4
+ class Integration < Discorb::DiscordModel
5
+ EXPIRE_BEHAVIOR: Hash[Integer, Symbol]
6
+
7
+ #
8
+ # Initialize a new integration.
9
+ # @private
10
+ #
11
+ # @param [Discorb::Client] client The client.
12
+ # @param [Hash] data The data of the welcome screen.
13
+ # @param [Discorb::Guild] guild The guild this integration is in.
14
+ def initialize: (
15
+ Discorb::Client client,
16
+ Discorb::json data,
17
+ _ToS guild_id
18
+ ) -> void
19
+
20
+ #
21
+ # Delete the integration.
22
+ # @async
23
+ #
24
+ # @param [String] reason The reason for deleting the integration.
25
+ #
26
+ # @return [Async::Task<void>] The task.
27
+ def delete!: (?reason: String?) -> Async::Task[void]
28
+
29
+ # @return [Discorb::Snowflake] The ID of the integration.
30
+ attr_reader id: Discorb::Snowflake
31
+
32
+ # @return [Symbol] The type of integration.
33
+ attr_reader type: Symbol
34
+
35
+ # @return [Boolean] Whether the integration is enabled.
36
+ attr_reader enabled: bool
37
+
38
+ # @return [Boolean] Whether the integration is syncing.
39
+ attr_reader syncing: bool
40
+
41
+ # @return [Boolean] Whether the integration is enabled emoticons.
42
+ attr_reader enable_emoticons: bool
43
+
44
+ # @return [:remove_role, :kick] The behavior of the integration when it expires.
45
+ attr_reader expire_behavior: Symbol
46
+
47
+ # @return [Integer] The grace period of the integration.
48
+ attr_reader expire_grace_period: Integer
49
+
50
+ # @return [Discorb::User] The user for the integration.
51
+ attr_reader user: Discorb::User
52
+
53
+ # @return [Discorb::Integration::Account] The account for the integration.
54
+ attr_reader account: Discorb::Integration::Account
55
+
56
+ # @return [Integer] The number of subscribers for the integration.
57
+ attr_reader subscriber_count: Integer
58
+
59
+ # @return [Boolean] Whether the integration is revoked.
60
+ attr_reader revoked: bool
61
+
62
+ # @return [Discorb::Application] The application for the integration.
63
+ attr_reader application: Discorb::Application
64
+
65
+ # @macro client_cache
66
+ # @return [Discorb::Guild] The guild this integration is in.
67
+ attr_reader guild: Discorb::Guild?
68
+
69
+ #
70
+ # Represents an account for an integration.
71
+ class Account < Discorb::DiscordModel
72
+ #
73
+ # Initialize a new account.
74
+ # @private
75
+ #
76
+ # @param [Hash] data The data from Discord.
77
+ def initialize: (Discorb::json data) -> void
78
+
79
+ # @return [String] The ID of the account.
80
+ attr_reader id: String
81
+
82
+ # @return [String] The name of the account.
83
+ attr_reader name: String
84
+ end
85
+
86
+ #
87
+ # Represents an application for an integration.
88
+ class Application < Discorb::DiscordModel
89
+ #
90
+ # Initialize a new application.
91
+ # @private
92
+ #
93
+ # @param [Discorb::Client] client The client.
94
+ # @param [Hash] data The data from Discord.
95
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
96
+
97
+ # @return [Discorb::Snowflake] The ID of the application.
98
+ attr_reader id: Discorb::Snowflake
99
+
100
+ # @return [String] The name of the application.
101
+ attr_reader name: String
102
+
103
+ # @return [Asset] The icon of the application.
104
+ # @return [nil] If the application has no icon.
105
+ attr_reader icon: Asset?
106
+
107
+ # @return [String] The description of the application.
108
+ attr_reader description: String
109
+
110
+ # @return [String] The summary of the application.
111
+ attr_reader summary: String
112
+
113
+ # @return [Discorb::User] The bot user associated with the application.
114
+ # @return [nil] If the application has no bot user.
115
+ attr_reader bot: Discorb::User?
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,97 @@
1
+ module Discorb
2
+ # Represents intents.
3
+ class Intents
4
+ INTENT_BITS: Hash[Symbol, Integer]
5
+
6
+ #
7
+ # Create new intents object with default (no members and presence) intents.
8
+ #
9
+ # @param guilds [Boolean] Whether guild related events are enabled.
10
+ # @param members [Boolean] Whether guild members related events are enabled.
11
+ # @param bans [Boolean] Whether guild ban related events are enabled.
12
+ # @param emojis [Boolean] Whether guild emojis related events are enabled.
13
+ # @param integrations [Boolean] Whether guild integration related events are enabled.
14
+ # @param webhooks [Boolean] Whether guild webhooks related events are enabled.
15
+ # @param invites [Boolean] Whether guild invite related events are enabled.
16
+ # @param voice_states [Boolean] Whether guild voice state related events are enabled.
17
+ # @param presences [Boolean] Whether guild presences related events are enabled.
18
+ # @param messages [Boolean] Whether guild messages related events are enabled.
19
+ # @param reactions [Boolean] Whether guild reaction related events are enabled.
20
+ # @param dm_messages [Boolean] Whether dm messages related events are enabled.
21
+ # @param dm_reactions [Boolean] Whether dm reactions related events are enabled.
22
+ # @param dm_typing [Boolean] Whether dm typing related events are enabled.
23
+ # @param message_content [Boolean] Whether message content will be sent with events.
24
+ # @param scheduled_events [Boolean] Whether events related scheduled events are enabled.
25
+ # @param automod_configuration [Boolean] Whether automod configuration related events are enabled.
26
+ # @param automod_execution [Boolean] Whether automod execution related events are enabled.
27
+ #
28
+ # @note You must enable privileged intents to use `members` and/or `presences` intents.
29
+ # @note Message Content Intent is not required to use `message_content` intents for now,
30
+ # this will be required in September 1, 2022. [Learn More](https://support-dev.discord.com/hc/en-us/articles/4404772028055).
31
+ # You should specify `message_content` intent for preventing unexpected changes in the future.
32
+ def initialize: (
33
+ automod_configuration: bool,
34
+ automod_execution: bool,
35
+ ?guilds: bool,
36
+ ?members: bool,
37
+ ?bans: bool,
38
+ ?emojis: bool,
39
+ ?integrations: bool,
40
+ ?webhooks: bool,
41
+ ?invites: bool,
42
+ ?voice_states: bool,
43
+ ?presences: bool,
44
+ ?messages: bool,
45
+ ?reactions: bool,
46
+ ?typing: bool,
47
+ ?dm_messages: bool,
48
+ ?dm_reactions: bool,
49
+ ?dm_typing: bool,
50
+ ?message_content: bool?,
51
+ ?scheduled_events: bool
52
+ ) -> void
53
+
54
+ #
55
+ # Returns the value of the flag.
56
+ def method_missing: (untyped name, ?untyped args) -> untyped
57
+
58
+ def respond_to_missing?: (untyped name, untyped include_private) -> bool
59
+
60
+ # Returns value of the intent.
61
+ # @return [Integer] The value of the intent.
62
+ def value: -> Integer
63
+
64
+ def inspect: -> String
65
+
66
+ def to_h: -> Hash[Symbol, bool]
67
+
68
+ # Create new intent object from raw value.
69
+ # @param value [Integer] The value of the intent.
70
+ def self.from_value: (Integer value) -> Intents
71
+
72
+ # Create new intent object with all intents.
73
+ def self.all: -> Discorb::Intents
74
+
75
+ # Create new intent object with no intents.
76
+ def self.none: -> Discorb::Intents
77
+
78
+ attr_accessor guilds: bool
79
+ attr_accessor members: bool
80
+ attr_accessor bans: bool
81
+ attr_accessor emojis: bool
82
+ attr_accessor integrations: bool
83
+ attr_accessor webhooks: bool
84
+ attr_accessor invites: bool
85
+ attr_accessor voice_states: bool
86
+ attr_accessor presences: bool
87
+ attr_accessor messages: bool
88
+ attr_accessor reactions: bool
89
+ attr_accessor dm_messages: bool
90
+ attr_accessor dm_reactions: bool
91
+ attr_accessor dm_typing: bool
92
+ attr_accessor message_content: bool
93
+ attr_accessor scheduled_events: bool
94
+ attr_accessor automod_configuration: bool
95
+ attr_accessor automod_execution: bool
96
+ end
97
+ end
@@ -0,0 +1,9 @@
1
+ module Discorb
2
+ #
3
+ # Represents auto complete interaction.
4
+ class AutoComplete < Discorb::Interaction
5
+ def send_complete_result: (
6
+ ::Hash[String, String | Integer | Float] val
7
+ ) -> untyped
8
+ end
9
+ end
@@ -0,0 +1,66 @@
1
+ module Discorb
2
+ #
3
+ # Represents an interaction of Discord.
4
+ class Interaction < Discorb::DiscordModel
5
+ @client: Discorb::Client
6
+
7
+ #
8
+ # Initialize a new interaction.
9
+ # @private
10
+ #
11
+ # @param [Discorb::Client] client The client this interaction belongs to.
12
+ # @param [Hash] data The data of the interaction.
13
+ def initialize: (Discorb::Client client, Discorb::json data) -> void
14
+
15
+ def guild: -> Discorb::Guild?
16
+
17
+ def channel: -> Discorb::Channel
18
+
19
+ def inspect: -> String
20
+
21
+ #
22
+ # Create a new Interaction instance from the data.
23
+ # @private
24
+ #
25
+ # @param [Discorb::Client] client The client this interaction belongs to.
26
+ # @param [Hash] data The data of the interaction.
27
+ def self.make_interaction: (
28
+ Discorb::Client client,
29
+ Discorb::json data
30
+ ) -> untyped
31
+
32
+ #
33
+ # Returns the descendants of the class.
34
+ # @private
35
+ def self.descendants: -> Array[Class]
36
+
37
+ def _set_data: (untyped) -> untyped
38
+
39
+ # @return [Discorb::Snowflake] The ID of the interaction.
40
+ attr_reader id: Discorb::Snowflake
41
+
42
+ # @return [Discorb::Snowflake] The ID of the application that created the interaction.
43
+ attr_reader application_id: Discorb::Snowflake
44
+
45
+ # @return [Symbol] The type of interaction.
46
+ attr_reader type: Symbol
47
+
48
+ # @return [Discorb::User, Discorb::Member] The user or member that created the interaction.
49
+ attr_reader user: Discorb::User | Discorb::Member
50
+
51
+ # @return [Integer] The type of interaction.
52
+ # @note This is always `1` for now.
53
+ attr_reader version: Integer
54
+
55
+ # @return [String] The token for the interaction.
56
+ attr_reader token: String
57
+
58
+ # @return [Symbol] The locale of the user that created the interaction.
59
+ # @note This modifies the language code, `-` will be replaced with `_`.
60
+ attr_reader locale: Symbol
61
+
62
+ # @return [Symbol] The locale of the guild that created the interaction.
63
+ # @note This modifies the language code, `-` will be replaced with `_`.
64
+ attr_reader guild_locale: Symbol
65
+ end
66
+ end
@@ -0,0 +1,66 @@
1
+ module Discorb
2
+ #
3
+ # Represents a command interaction.
4
+ class CommandInteraction < Discorb::Interaction
5
+ include Discorb::Interaction::SourceResponder
6
+ include Discorb::Interaction::ModalResponder
7
+
8
+ #
9
+ # Creates a new CommandInteraction instance for the given data.
10
+ # @private
11
+ #
12
+ # @param [Discorb::Client] client The client.
13
+ # @param [Hash] data The data for the command.
14
+ def self.make_interaction: (
15
+ Discorb::Client client,
16
+ Discorb::json data
17
+ ) -> untyped
18
+
19
+ #
20
+ # Returns the classes under this class.
21
+ # @private
22
+ def self.nested_classes: -> untyped
23
+
24
+ #
25
+ # Represents a slash command interaction.
26
+ class ChatInputCommand < Discorb::CommandInteraction
27
+ #
28
+ # Get command data from the given data.
29
+ # @private
30
+ #
31
+ # @param [Hash] data The data of the command.
32
+ def self.get_command_data: (Discorb::json data) -> untyped
33
+
34
+ #
35
+ # Modify the option map with the given options.
36
+ # @private
37
+ #
38
+ # @param [Hash] option_map The option map to modify.
39
+ # @param [Array<Hash>] options The options for modifying.
40
+ # @param [Discorb::Guild] guild The guild where the command is executed.
41
+ # @param [{Discorb::Snowflake => Discorb::Member}] members The cached members of the guild.
42
+ # @param [{Integer => Discorb::Attachment}] attachments The cached attachments of the message.
43
+ def self.modify_option_map: (
44
+ ::Hash[untyped, untyped] option_map,
45
+ ::Array[::Hash[untyped, untyped]] options,
46
+ Discorb::Guild? guild,
47
+ ::Hash[Discorb::Snowflake, Discorb::Member] members,
48
+ ::Hash[Integer, Discorb::Attachment] attachments
49
+ ) -> untyped
50
+ end
51
+
52
+ #
53
+ # Represents a user context menu interaction.
54
+ class UserMenuCommand < Discorb::CommandInteraction
55
+ # @return [Discorb::Member, Discorb::User] The target user.
56
+ attr_reader target: Discorb::Member | Discorb::User
57
+ end
58
+
59
+ #
60
+ # Represents a message context menu interaction.
61
+ class MessageMenuCommand < Discorb::CommandInteraction
62
+ # @return [Discorb::Message] The target message.
63
+ attr_reader target: Discorb::Message
64
+ end
65
+ end
66
+ end