discorb 0.17.1 → 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 (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,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