discorb 0.17.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +1 -3
- data/.github/workflows/validate.yml +21 -0
- data/Changelog.md +10 -0
- data/Gemfile +6 -0
- data/Rakefile +210 -98
- data/Steepfile +28 -0
- data/docs/events.md +42 -6
- data/docs/tutorial.md +7 -7
- data/docs/voice_events.md +2 -2
- data/examples/commands/message.rb +12 -7
- data/examples/commands/permission.rb +2 -1
- data/examples/commands/slash.rb +23 -19
- data/examples/commands/user.rb +15 -12
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +4 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +1 -0
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +16 -5
- data/examples/simple/shard.rb +2 -1
- data/examples/simple/wait_for_message.rb +3 -0
- data/exe/discorb +3 -3
- data/lib/discorb/allowed_mentions.rb +1 -1
- data/lib/discorb/app_command/command.rb +12 -13
- data/lib/discorb/app_command/handler.rb +20 -6
- data/lib/discorb/audit_logs.rb +6 -2
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/guild.rb +2 -1
- data/lib/discorb/channel/stage.rb +1 -1
- data/lib/discorb/channel/text.rb +11 -20
- data/lib/discorb/channel/thread.rb +15 -11
- data/lib/discorb/client.rb +12 -10
- data/lib/discorb/color.rb +37 -60
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -3
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/exe/about.rb +1 -1
- data/lib/discorb/exe/new.rb +1 -5
- data/lib/discorb/extension.rb +0 -4
- data/lib/discorb/flag.rb +2 -2
- data/lib/discorb/gateway.rb +21 -582
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +136 -17
- data/lib/discorb/guild_template.rb +1 -1
- data/lib/discorb/http.rb +47 -25
- data/lib/discorb/intents.rb +27 -18
- data/lib/discorb/interaction/command.rb +14 -10
- data/lib/discorb/interaction/response.rb +74 -14
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +13 -11
- data/lib/discorb/message_meta.rb +2 -3
- data/lib/discorb/modules.rb +3 -2
- data/lib/discorb/presence.rb +4 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +1 -1
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +5 -5
- data/lib/discorb/webhook.rb +15 -6
- data/lib/discorb.rb +2 -2
- data/rbs_collection.lock.yaml +88 -96
- data/rbs_collection.yaml +21 -17
- data/sig/async.rbs +11 -5
- data/sig/discorb/activity.rbs +23 -0
- data/sig/discorb/allowed_mentions.rbs +44 -0
- data/sig/discorb/app_command/base.rbs +282 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +142 -0
- data/sig/discorb/asset.rbs +32 -0
- data/sig/discorb/attachment.rbs +91 -0
- data/sig/discorb/audit_log.rbs +231 -0
- data/sig/discorb/automod.rbs +128 -0
- data/sig/discorb/avatar.rbs +26 -0
- data/sig/discorb/channel/base.rbs +179 -0
- data/sig/discorb/channel/category.rbs +56 -0
- data/sig/discorb/channel/container.rbs +29 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +77 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +185 -0
- data/sig/discorb/channel/voice.rbs +41 -0
- data/sig/discorb/client.rbs +2495 -0
- data/sig/discorb/color.rbs +142 -0
- data/sig/discorb/component/base.rbs +28 -0
- data/sig/discorb/component/button.rbs +65 -0
- data/sig/discorb/component/select_menu.rbs +107 -0
- data/sig/discorb/component/text_input.rbs +69 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +90 -0
- data/sig/discorb/dictionary.rbs +85 -0
- data/sig/discorb/discord_model.rbs +15 -0
- data/sig/discorb/embed.rbs +279 -0
- data/sig/discorb/emoji.rbs +13 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +27 -0
- data/sig/discorb/extension.rbs +1734 -0
- data/sig/discorb/flag.rbs +72 -0
- data/sig/discorb/gateway.rbs +481 -0
- data/sig/discorb/guild.rbs +870 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +147 -0
- data/sig/discorb/image.rbs +20 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +97 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +66 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +140 -0
- data/sig/discorb/interaction/modal.rbs +50 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +187 -0
- data/sig/discorb/message.rbs +469 -0
- data/sig/discorb/messageable.rbs +153 -0
- data/sig/discorb/partial_emoji.rbs +35 -0
- data/sig/discorb/permissions.rbs +149 -0
- data/sig/discorb/presence.rbs +237 -0
- data/sig/discorb/reaction.rbs +33 -0
- data/sig/discorb/role.rbs +145 -0
- data/sig/discorb/scheduled_event.rbs +148 -0
- data/sig/discorb/shard.rbs +62 -0
- data/sig/discorb/snowflake.rbs +56 -0
- data/sig/discorb/stage_instance.rbs +63 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +49 -0
- data/sig/discorb/user.rbs +93 -0
- data/sig/discorb/utils.rbs +8 -0
- data/sig/discorb/voice_region.rbs +30 -0
- data/sig/discorb/voice_state.rbs +71 -0
- data/sig/discorb/webhook.rbs +327 -0
- data/sig/discorb/welcome_screen.rbs +78 -0
- data/sig/discorb.rbs +5 -8661
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- metadata +80 -3
@@ -0,0 +1,72 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a flag.
|
4
|
+
# @abstract
|
5
|
+
class Flag
|
6
|
+
# Initialize the flag.
|
7
|
+
# @note This is usually called by the subclass.
|
8
|
+
#
|
9
|
+
# @param [Integer] value The value of the flag.
|
10
|
+
def initialize: (Integer value) -> void
|
11
|
+
|
12
|
+
#
|
13
|
+
# Union of two flags.
|
14
|
+
#
|
15
|
+
# @param [Discorb::Flag] other The other flag.
|
16
|
+
#
|
17
|
+
# @return [Discorb::Flag] The union of the two flags.
|
18
|
+
def |: (instance other) -> instance
|
19
|
+
|
20
|
+
#
|
21
|
+
# Subtraction of two flags.
|
22
|
+
#
|
23
|
+
# @param [Discorb::Flag] other The other flag.
|
24
|
+
#
|
25
|
+
# @return [Discorb::Flag] The subtraction of the two flags.
|
26
|
+
def -: (instance other) -> instance
|
27
|
+
|
28
|
+
#
|
29
|
+
# Intersection of two flags.
|
30
|
+
#
|
31
|
+
# @param [Discorb::Flag] other The other flag.
|
32
|
+
#
|
33
|
+
# @return [Discorb::Flag] The intersection of the two flags.
|
34
|
+
def &: (instance other) -> instance
|
35
|
+
|
36
|
+
#
|
37
|
+
# XOR of two flags.
|
38
|
+
#
|
39
|
+
# @param [Discorb::Flag] other The other flag.
|
40
|
+
#
|
41
|
+
# @return [Discorb::Flag] The XOR of the two flags.
|
42
|
+
def ^: (instance other) -> instance
|
43
|
+
|
44
|
+
#
|
45
|
+
# Negation of the flag.
|
46
|
+
#
|
47
|
+
# @return [Discorb::Flag] The negation of the flag.
|
48
|
+
def ~: -> instance
|
49
|
+
|
50
|
+
def to_i: -> Integer
|
51
|
+
|
52
|
+
def inspect: -> String
|
53
|
+
|
54
|
+
#
|
55
|
+
# Max value of the flag.
|
56
|
+
#
|
57
|
+
# @return [Integer] the max value of the flag.
|
58
|
+
def self.max_value: -> (Integer | Numeric)
|
59
|
+
|
60
|
+
#
|
61
|
+
# Initialize a new flag with keys.
|
62
|
+
def self.from_keys: (*Symbol keys) -> untyped
|
63
|
+
|
64
|
+
attr_reader self.bits: Hash[Symbol, Integer]
|
65
|
+
|
66
|
+
# @return [Hash{Symbol => Boolean}] the values of the flag.
|
67
|
+
attr_reader values: ::Hash[Symbol, bool]
|
68
|
+
|
69
|
+
# @return [Integer] the value of the flag.
|
70
|
+
attr_reader value: Integer
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,481 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# A module for Discord Gateway.
|
4
|
+
# This module is internal use only.
|
5
|
+
module Gateway
|
6
|
+
#
|
7
|
+
# Represents an event.
|
8
|
+
# @abstract
|
9
|
+
class GatewayEvent
|
10
|
+
#
|
11
|
+
# Initializes a new instance of the GatewayEvent class.
|
12
|
+
# @private
|
13
|
+
#
|
14
|
+
# @param [Hash] data The data of the event.
|
15
|
+
def initialize: (Discorb::json data) -> void
|
16
|
+
|
17
|
+
def inspect: -> String
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Represents a reaction event.
|
22
|
+
class ReactionEvent < Discorb::Gateway::GatewayEvent
|
23
|
+
#
|
24
|
+
# Initializes a new instance of the ReactionEvent class.
|
25
|
+
# @private
|
26
|
+
#
|
27
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
28
|
+
# @param [Hash] data The data of the event.
|
29
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
30
|
+
|
31
|
+
# Fetch the message.
|
32
|
+
# If message is cached, it will be returned.
|
33
|
+
# @async
|
34
|
+
#
|
35
|
+
# @param [Boolean] force Whether to force fetching the message.
|
36
|
+
#
|
37
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
38
|
+
def fetch_message: (?force: bool) -> Async::Task[Discorb::Message]
|
39
|
+
|
40
|
+
# @return [Hash] The raw data of the event.
|
41
|
+
attr_reader data: Discorb::json
|
42
|
+
|
43
|
+
# @return [Discorb::Snowflake] The ID of the user who reacted.
|
44
|
+
attr_reader user_id: Discorb::Snowflake
|
45
|
+
|
46
|
+
# @return [Discorb::Snowflake] The ID of the channel the message was sent in.
|
47
|
+
attr_reader channel_id: Discorb::Snowflake
|
48
|
+
|
49
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
50
|
+
attr_reader message_id: Discorb::Snowflake
|
51
|
+
|
52
|
+
# @return [Discorb::Snowflake] The ID of the guild the message was sent in.
|
53
|
+
attr_reader guild_id: Discorb::Snowflake
|
54
|
+
|
55
|
+
# @macro client_cache
|
56
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
57
|
+
attr_reader channel: Discorb::Channel?
|
58
|
+
|
59
|
+
# @macro client_cache
|
60
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
61
|
+
attr_reader guild: Discorb::Guild?
|
62
|
+
|
63
|
+
# @macro client_cache
|
64
|
+
# @return [Discorb::Message] The message the reaction was sent in.
|
65
|
+
attr_reader message: Discorb::Message?
|
66
|
+
|
67
|
+
# @return [Discorb::UnicodeEmoji, Discorb::PartialEmoji] The emoji that was reacted with.
|
68
|
+
attr_reader emoji: Discorb::UnicodeEmoji | Discorb::PartialEmoji
|
69
|
+
|
70
|
+
# @macro client_cache
|
71
|
+
# @return [Discorb::User, Discorb::Member] The user that is typing.
|
72
|
+
attr_reader user: Discorb::Member | Discorb::User
|
73
|
+
alias member user
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Represents a `INTEGRATION_DELETE` event.
|
78
|
+
class IntegrationDeleteEvent < Discorb::Gateway::GatewayEvent
|
79
|
+
#
|
80
|
+
# Initialize a new instance of the IntegrationDeleteEvent class.
|
81
|
+
# @private
|
82
|
+
#
|
83
|
+
#
|
84
|
+
# @param [Hash] data The data of the event.
|
85
|
+
def initialize: (untyped _client, Discorb::json data) -> void
|
86
|
+
|
87
|
+
# @return [Discorb::Snowflake] The ID of the integration.
|
88
|
+
attr_reader id: Discorb::Snowflake
|
89
|
+
|
90
|
+
# @macro client_cache
|
91
|
+
# @return [Discorb::Guild] The guild of the integration.
|
92
|
+
attr_reader guild: Discorb::Guild?
|
93
|
+
|
94
|
+
# @macro client_cache
|
95
|
+
# @return [Discorb::User] The user associated with the integration.
|
96
|
+
attr_reader user: Discorb::User?
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Represents a `MESSAGE_REACTION_REMOVE_ALL` event.
|
101
|
+
class ReactionRemoveAllEvent < Discorb::Gateway::GatewayEvent
|
102
|
+
#
|
103
|
+
# Initialize a new instance of the ReactionRemoveAllEvent class.
|
104
|
+
# @private
|
105
|
+
#
|
106
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
107
|
+
# @param [Hash] data The data of the event.
|
108
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
109
|
+
|
110
|
+
# Fetch the message.
|
111
|
+
# If message is cached, it will be returned.
|
112
|
+
# @async
|
113
|
+
#
|
114
|
+
# @param [Boolean] force Whether to force fetching the message.
|
115
|
+
#
|
116
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
117
|
+
def fetch_message: (?force: bool) -> Async::Task[Discorb::Message]
|
118
|
+
|
119
|
+
# @return [Discorb::Snowflake] The ID of the channel the message was sent in.
|
120
|
+
attr_reader channel_id: Discorb::Snowflake
|
121
|
+
|
122
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
123
|
+
attr_reader message_id: Discorb::Snowflake
|
124
|
+
|
125
|
+
# @return [Discorb::Snowflake] The ID of the guild the message was sent in.
|
126
|
+
attr_reader guild_id: Discorb::Snowflake
|
127
|
+
|
128
|
+
# @macro client_cache
|
129
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
130
|
+
attr_reader channel: Discorb::Channel?
|
131
|
+
|
132
|
+
# @macro client_cache
|
133
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
134
|
+
attr_reader guild: Discorb::Guild?
|
135
|
+
|
136
|
+
# @macro client_cache
|
137
|
+
# @return [Discorb::Message] The message the reaction was sent in.
|
138
|
+
attr_reader message: Discorb::Message?
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# Represents a `MESSAGE_REACTION_REMOVE_EMOJI` event.
|
143
|
+
class ReactionRemoveEmojiEvent < Discorb::Gateway::GatewayEvent
|
144
|
+
#
|
145
|
+
# Initialize a new instance of the ReactionRemoveEmojiEvent class.
|
146
|
+
# @private
|
147
|
+
#
|
148
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
149
|
+
# @param [Hash] data The data of the event.
|
150
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
151
|
+
|
152
|
+
# Fetch the message.
|
153
|
+
# If message is cached, it will be returned.
|
154
|
+
# @async
|
155
|
+
#
|
156
|
+
# @param [Boolean] force Whether to force fetching the message.
|
157
|
+
#
|
158
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
159
|
+
def fetch_message: (?force: bool) -> Async::Task[Discorb::Message]
|
160
|
+
|
161
|
+
# @return [Discorb::Snowflake] The ID of the channel the message was sent in.
|
162
|
+
attr_reader channel_id: Discorb::Snowflake
|
163
|
+
|
164
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
165
|
+
attr_reader message_id: Discorb::Snowflake
|
166
|
+
|
167
|
+
# @return [Discorb::Snowflake] The ID of the guild the message was sent in.
|
168
|
+
attr_reader guild_id: Discorb::Snowflake
|
169
|
+
|
170
|
+
# @macro client_cache
|
171
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
172
|
+
attr_reader channel: Discorb::Channel?
|
173
|
+
|
174
|
+
# @macro client_cache
|
175
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
176
|
+
attr_reader guild: Discorb::Guild?
|
177
|
+
|
178
|
+
# @macro client_cache
|
179
|
+
# @return [Discorb::Message] The message the reaction was sent in.
|
180
|
+
attr_reader message: Discorb::Message?
|
181
|
+
|
182
|
+
# @return [Discorb::UnicodeEmoji, Discorb::PartialEmoji] The emoji that was reacted with.
|
183
|
+
attr_reader emoji: Discorb::UnicodeEmoji | Discorb::PartialEmoji
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
# Represents a `GUILD_SCHEDULED_EVENT_USER_ADD` and `GUILD_SCHEDULED_EVENT_USER_REMOVE` event.
|
188
|
+
class ScheduledEventUserEvent < Discorb::Gateway::GatewayEvent
|
189
|
+
#
|
190
|
+
# Initialize a new instance of the ScheduledEventUserEvent class.
|
191
|
+
# @private
|
192
|
+
#
|
193
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
194
|
+
# @param [Hash] data The data of the event.
|
195
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
196
|
+
|
197
|
+
# @return [Discorb::User] The user that triggered the event.
|
198
|
+
attr_reader user: Discorb::User
|
199
|
+
|
200
|
+
# @return [Discorb::Guild] The guild the event was triggered in.
|
201
|
+
attr_reader guild: Discorb::Guild
|
202
|
+
|
203
|
+
# @return [Discorb::ScheduledEvent] The scheduled event.
|
204
|
+
attr_reader scheduled_event: Discorb::ScheduledEvent
|
205
|
+
end
|
206
|
+
|
207
|
+
#
|
208
|
+
# Represents a `MESSAGE_UPDATE` event.
|
209
|
+
class MessageUpdateEvent < Discorb::Gateway::GatewayEvent
|
210
|
+
# @!attribute [r] channel
|
211
|
+
# @macro client_cache
|
212
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
213
|
+
# @!attribute [r] guild
|
214
|
+
# @macro client_cache
|
215
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
216
|
+
def initialize: (
|
217
|
+
untyped client,
|
218
|
+
untyped data,
|
219
|
+
untyped before,
|
220
|
+
untyped after
|
221
|
+
) -> void
|
222
|
+
|
223
|
+
# Fetch the message.
|
224
|
+
# @async
|
225
|
+
#
|
226
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
227
|
+
def fetch_message: -> Async::Task[Discorb::Message]
|
228
|
+
|
229
|
+
# @return [Discorb::Message] The message before update.
|
230
|
+
attr_reader before: Discorb::Message
|
231
|
+
|
232
|
+
# @return [Discorb::Message] The message after update.
|
233
|
+
attr_reader after: Discorb::Message
|
234
|
+
|
235
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
236
|
+
attr_reader id: Discorb::Snowflake
|
237
|
+
|
238
|
+
# @return [Discorb::Snowflake] The ID of the channel the message was sent in.
|
239
|
+
attr_reader channel_id: Discorb::Snowflake
|
240
|
+
|
241
|
+
# @return [Discorb::Snowflake] The ID of the guild the message was sent in.
|
242
|
+
attr_reader guild_id: Discorb::Snowflake
|
243
|
+
|
244
|
+
# @return [String] The new content of the message.
|
245
|
+
attr_reader content: String
|
246
|
+
|
247
|
+
# @return [Time] The time the message was edited.
|
248
|
+
attr_reader timestamp: Time
|
249
|
+
|
250
|
+
# @return [Boolean] Whether the message pings @everyone.
|
251
|
+
attr_reader mention_everyone: bool
|
252
|
+
|
253
|
+
# @macro client_cache
|
254
|
+
# @return [Array<Discorb::Role>] The roles mentioned in the message.
|
255
|
+
attr_reader mention_roles: ::Array[Discorb::Role]?
|
256
|
+
|
257
|
+
# @return [Array<Discorb::Attachment>] The attachments in the message.
|
258
|
+
attr_reader attachments: ::Array[Discorb::Attachment]
|
259
|
+
|
260
|
+
# @return [Array<Discorb::Embed>] The embeds in the message.
|
261
|
+
attr_reader embeds: ::Array[Discorb::Embed]
|
262
|
+
|
263
|
+
# @macro client_cache
|
264
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
265
|
+
attr_reader channel: Discorb::Channel?
|
266
|
+
|
267
|
+
# @macro client_cache
|
268
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
269
|
+
attr_reader guild: Discorb::Guild?
|
270
|
+
end
|
271
|
+
|
272
|
+
#
|
273
|
+
# Represents a message but it has only ID.
|
274
|
+
class UnknownDeleteBulkMessage < Discorb::Gateway::GatewayEvent
|
275
|
+
#
|
276
|
+
# Initialize a new instance of the UnknownDeleteBulkMessage class.
|
277
|
+
# @private
|
278
|
+
#
|
279
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
280
|
+
# @param [Hash] data The data of the event.
|
281
|
+
def initialize: (
|
282
|
+
Discorb::Client client,
|
283
|
+
_ToS id,
|
284
|
+
Discorb::json data
|
285
|
+
) -> void
|
286
|
+
|
287
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
288
|
+
attr_reader id: Discorb::Snowflake
|
289
|
+
|
290
|
+
# @macro client_cache
|
291
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
292
|
+
attr_reader channel: Discorb::Channel?
|
293
|
+
|
294
|
+
# @macro client_cache
|
295
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
296
|
+
attr_reader guild: Discorb::Guild?
|
297
|
+
end
|
298
|
+
|
299
|
+
#
|
300
|
+
# Represents a `INVITE_DELETE` event.
|
301
|
+
class InviteDeleteEvent < Discorb::Gateway::GatewayEvent
|
302
|
+
#
|
303
|
+
# Initialize a new instance of the InviteDeleteEvent class.
|
304
|
+
# @private
|
305
|
+
#
|
306
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
307
|
+
# @param [Hash] data The data of the event.
|
308
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
309
|
+
|
310
|
+
# @return [String] The invite code.
|
311
|
+
attr_reader code: String
|
312
|
+
|
313
|
+
# @macro client_cache
|
314
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
315
|
+
attr_reader channel: Discorb::Channel?
|
316
|
+
|
317
|
+
# @macro client_cache
|
318
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
319
|
+
attr_reader guild: Discorb::Guild?
|
320
|
+
end
|
321
|
+
|
322
|
+
#
|
323
|
+
# Represents a `TYPING_START` event.
|
324
|
+
class TypingStartEvent < Discorb::Gateway::GatewayEvent
|
325
|
+
#
|
326
|
+
# Initialize a new instance of the TypingStartEvent class.
|
327
|
+
# @private
|
328
|
+
#
|
329
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
330
|
+
# @param [Hash] data The data of the event.
|
331
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
332
|
+
|
333
|
+
# @return [Discorb::Snowflake] The ID of the channel the user is typing in.
|
334
|
+
attr_reader user_id: Discorb::Snowflake
|
335
|
+
|
336
|
+
# @macro client_cache
|
337
|
+
# @return [Discorb::Channel] The channel the user is typing in.
|
338
|
+
attr_reader channel: Discorb::Channel?
|
339
|
+
|
340
|
+
# @macro client_cache
|
341
|
+
# @return [Discorb::Guild] The guild the user is typing in.
|
342
|
+
attr_reader guild: Discorb::Guild?
|
343
|
+
|
344
|
+
# @macro client_cache
|
345
|
+
# @return [Discorb::User, Discorb::Member] The user that is typing.
|
346
|
+
attr_reader user: Discorb::Member | Discorb::User
|
347
|
+
alias member user
|
348
|
+
end
|
349
|
+
|
350
|
+
#
|
351
|
+
# Represents a message pin event.
|
352
|
+
class MessagePinEvent < Discorb::Gateway::GatewayEvent
|
353
|
+
# @!attribute [r] pinned?
|
354
|
+
# @return [Boolean] Whether the message was pinned.
|
355
|
+
# @!attribute [r] unpinned?
|
356
|
+
# @return [Boolean] Whether the message was unpinned.
|
357
|
+
def initialize: (untyped client, untyped data, untyped message) -> void
|
358
|
+
|
359
|
+
# @return [Discorb::Message] The message that was pinned.
|
360
|
+
attr_reader message: Discorb::Message
|
361
|
+
|
362
|
+
# @return [:pinned, :unpinned] The type of event.
|
363
|
+
attr_reader type: Symbol
|
364
|
+
|
365
|
+
# @return [Boolean] Whether the message was pinned.
|
366
|
+
attr_reader pinned?: bool
|
367
|
+
|
368
|
+
# @return [Boolean] Whether the message was unpinned.
|
369
|
+
attr_reader unpinned?: bool
|
370
|
+
end
|
371
|
+
|
372
|
+
#
|
373
|
+
# Represents a `WEBHOOKS_UPDATE` event.
|
374
|
+
class WebhooksUpdateEvent < Discorb::Gateway::GatewayEvent
|
375
|
+
#
|
376
|
+
# Initialize a new instance of the WebhooksUpdateEvent class.
|
377
|
+
# @private
|
378
|
+
#
|
379
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
380
|
+
# @param [Hash] data The data of the event.
|
381
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
382
|
+
|
383
|
+
# @macro client_cache
|
384
|
+
# @return [Discorb::Channel] The channel where the webhook was updated.
|
385
|
+
attr_reader channel: Discorb::Channel?
|
386
|
+
|
387
|
+
# @macro client_cache
|
388
|
+
# @return [Discorb::Guild] The guild where the webhook was updated.
|
389
|
+
attr_reader guild: Discorb::Guild?
|
390
|
+
end
|
391
|
+
|
392
|
+
#
|
393
|
+
# Represents a `AUTO_MODERATION_ACTION_EXECUTION` event.
|
394
|
+
class AutoModerationActionExecutionEvent < GatewayEvent
|
395
|
+
# @return [Discorb::Snowflake] The id of the rule.
|
396
|
+
attr_reader rule_id: Discorb::Snowflake
|
397
|
+
|
398
|
+
# @return [Symbol] The type of action that was executed.
|
399
|
+
attr_reader rule_trigger_type: Discorb::AutoModRule::trigger_type
|
400
|
+
|
401
|
+
# @return [Discorb::Snowflake] The id of the message that triggered the action.
|
402
|
+
# @return [nil] If the message was deleted.
|
403
|
+
attr_reader message_id: Discorb::Snowflake?
|
404
|
+
|
405
|
+
# @return [Discorb::Snowflake] The id of the system message that was sent.
|
406
|
+
# @return [nil] If the system message channel was not set.
|
407
|
+
attr_reader alert_system_message_id: Discorb::Snowflake?
|
408
|
+
|
409
|
+
# @return [String] The content of the message that was sent.
|
410
|
+
attr_reader content: String
|
411
|
+
|
412
|
+
# @return [String] The keyword that triggered the action.
|
413
|
+
# @return [nil] If the action was not triggered by a keyword.
|
414
|
+
attr_reader matched_keyword: String?
|
415
|
+
|
416
|
+
# @return [String] The content that triggered the action.
|
417
|
+
# @return [nil] If the action was not triggered by a keyword.
|
418
|
+
attr_reader matched_content: String?
|
419
|
+
|
420
|
+
# @return [Discorb::AutoModRule::Action] The action that was executed.
|
421
|
+
attr_reader action: Discorb::AutoModRule::Action
|
422
|
+
|
423
|
+
#
|
424
|
+
# Initialize a new instance of the AutoModerationActionExecutionEvent class.
|
425
|
+
# @private
|
426
|
+
#
|
427
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
428
|
+
# @param [Hash] data The data of the event.
|
429
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
430
|
+
|
431
|
+
# @!attribute [r] guild
|
432
|
+
# @return [Discorb::Guild] The guild where the rule was executed.
|
433
|
+
def guild: -> Discorb::Guild
|
434
|
+
|
435
|
+
# @!attribute [r] channel
|
436
|
+
# @return [Discorb::Channel] The channel where the rule was executed.
|
437
|
+
def channel: -> Discorb::Channel
|
438
|
+
|
439
|
+
# @!attribute [r] member
|
440
|
+
# @return [Discorb::Member] The member that triggered the action.
|
441
|
+
def member: -> Discorb::Member
|
442
|
+
|
443
|
+
alias user member
|
444
|
+
end
|
445
|
+
|
446
|
+
#
|
447
|
+
# A module to handle gateway events.
|
448
|
+
module Handler
|
449
|
+
def connect_gateway: (untyped reconnect) -> untyped
|
450
|
+
|
451
|
+
def send_gateway: (untyped opcode, **untyped value) -> untyped
|
452
|
+
|
453
|
+
def handle_gateway: (untyped payload, untyped reconnect) -> untyped
|
454
|
+
|
455
|
+
def handle_heartbeat: -> untyped
|
456
|
+
|
457
|
+
def handle_event: (untyped event_name, untyped data) -> untyped
|
458
|
+
|
459
|
+
def ready: -> untyped
|
460
|
+
end
|
461
|
+
|
462
|
+
#
|
463
|
+
# A class for connecting websocket with raw bytes data.
|
464
|
+
# @private
|
465
|
+
class RawConnection < Async::WebSocket::Connection
|
466
|
+
def inspect: -> String
|
467
|
+
|
468
|
+
def closed?: -> bool
|
469
|
+
|
470
|
+
def close: -> untyped
|
471
|
+
|
472
|
+
def force_close: -> untyped
|
473
|
+
|
474
|
+
def io: -> untyped
|
475
|
+
|
476
|
+
def parse: (untyped buffer) -> untyped
|
477
|
+
|
478
|
+
def dump: (untyped object) -> untyped
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|