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.
- 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,469 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a message in Discord.
|
|
4
|
+
class Message < Discorb::DiscordModel
|
|
5
|
+
MESSAGE_TYPE: Hash[Integer, Symbol]
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Initialize a new message.
|
|
9
|
+
# @private
|
|
10
|
+
#
|
|
11
|
+
# @param [Discorb::Client] client The client.
|
|
12
|
+
# @param [Hash] data The data of the welcome screen.
|
|
13
|
+
# @param [Boolean] no_cache Whether to disable caching.
|
|
14
|
+
def initialize: (
|
|
15
|
+
Discorb::Client client,
|
|
16
|
+
Discorb::json data,
|
|
17
|
+
?no_cache: bool
|
|
18
|
+
) -> void
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# Removes the mentions from the message.
|
|
22
|
+
#
|
|
23
|
+
# @param [Boolean] user Whether to clean user mentions.
|
|
24
|
+
# @param [Boolean] channel Whether to clean channel mentions.
|
|
25
|
+
# @param [Boolean] role Whether to clean role mentions.
|
|
26
|
+
# @param [Boolean] emoji Whether to clean emoji.
|
|
27
|
+
# @param [Boolean] everyone Whether to clean `@everyone` and `@here`.
|
|
28
|
+
# @param [Boolean] codeblock Whether to clean codeblocks.
|
|
29
|
+
#
|
|
30
|
+
# @return [String] The cleaned content of the message.
|
|
31
|
+
def clean_content: (
|
|
32
|
+
?user: bool,
|
|
33
|
+
?channel: bool,
|
|
34
|
+
?role: bool,
|
|
35
|
+
?emoji: bool,
|
|
36
|
+
?everyone: bool,
|
|
37
|
+
?codeblock: bool
|
|
38
|
+
) -> String
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Edit the message.
|
|
42
|
+
# @async
|
|
43
|
+
#
|
|
44
|
+
# @param [String] content The message content.
|
|
45
|
+
# @param [Discorb::Embed] embed The embed to send.
|
|
46
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send.
|
|
47
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions.
|
|
48
|
+
# @param [Array<Discorb::Attachment>] attachments The new attachments.
|
|
49
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
|
50
|
+
# @param [Boolean] supress Whether to supress embeds.
|
|
51
|
+
#
|
|
52
|
+
# @return [Async::Task<void>] The task.
|
|
53
|
+
def edit: (
|
|
54
|
+
?String content,
|
|
55
|
+
?embed: Discorb::Embed,
|
|
56
|
+
?embeds: ::Array[Discorb::Embed],
|
|
57
|
+
?allowed_mentions: Discorb::AllowedMentions,
|
|
58
|
+
?attachments: ::Array[Discorb::Attachment],
|
|
59
|
+
?components: ::Array[Discorb::Component]
|
|
60
|
+
| ::Array[::Array[Discorb::Component]],
|
|
61
|
+
?supress: bool
|
|
62
|
+
) -> Async::Task[void]
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
# Delete the message.
|
|
66
|
+
# @async
|
|
67
|
+
#
|
|
68
|
+
# @param [String] reason The reason for deleting the message.
|
|
69
|
+
#
|
|
70
|
+
# @return [Async::Task<void>] The task.
|
|
71
|
+
def delete!: (?reason: String?) -> Async::Task[void]
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Convert the message to reference object.
|
|
75
|
+
#
|
|
76
|
+
# @param [Boolean] fail_if_not_exists Whether to raise an error if the message does not exist.
|
|
77
|
+
#
|
|
78
|
+
# @return [Hash] The reference object.
|
|
79
|
+
def to_reference: (?fail_if_not_exists: bool) -> Discorb::Message::Reference
|
|
80
|
+
|
|
81
|
+
# Reply to the message.
|
|
82
|
+
# @async
|
|
83
|
+
# @param (see #post)
|
|
84
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
|
85
|
+
def reply: (
|
|
86
|
+
*untyped args,
|
|
87
|
+
**untyped kwargs
|
|
88
|
+
) -> Async::Task[Discorb::Message]
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# Publish the message.
|
|
92
|
+
# @async
|
|
93
|
+
#
|
|
94
|
+
# @return [Async::Task<void>] The task.
|
|
95
|
+
def publish: -> Async::Task[void]
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Add a reaction to the message.
|
|
99
|
+
# @async
|
|
100
|
+
#
|
|
101
|
+
# @param [Discorb::emoji] emoji The emoji to react with.
|
|
102
|
+
#
|
|
103
|
+
# @return [Async::Task<void>] The task.
|
|
104
|
+
def add_reaction: (Discorb::emoji emoji) -> Async::Task[void]
|
|
105
|
+
|
|
106
|
+
#
|
|
107
|
+
# Remove a reaction from the message.
|
|
108
|
+
# @async
|
|
109
|
+
#
|
|
110
|
+
# @param [Discorb::emoji] emoji The emoji to remove.
|
|
111
|
+
#
|
|
112
|
+
# @return [Async::Task<void>] The task.
|
|
113
|
+
def remove_reaction: (Discorb::emoji emoji) -> Async::Task[void]
|
|
114
|
+
|
|
115
|
+
#
|
|
116
|
+
# Remove other member's reaction from the message.
|
|
117
|
+
# @async
|
|
118
|
+
#
|
|
119
|
+
# @param [Discorb::emoji] emoji The emoji to remove.
|
|
120
|
+
# @param [Discorb::Member] member The member to remove the reaction from.
|
|
121
|
+
#
|
|
122
|
+
# @return [Async::Task<void>] The task.
|
|
123
|
+
def remove_reaction_of: (
|
|
124
|
+
Discorb::emoji emoji,
|
|
125
|
+
Discorb::Member member
|
|
126
|
+
) -> Async::Task[void]
|
|
127
|
+
|
|
128
|
+
#
|
|
129
|
+
# Fetch reacted users of reaction.
|
|
130
|
+
# @async
|
|
131
|
+
#
|
|
132
|
+
# @param [Discorb::emoji, Discorb::PartialEmoji] emoji The emoji to fetch.
|
|
133
|
+
# @param [Integer, nil] limit The maximum number of users to fetch. `nil` for no limit.
|
|
134
|
+
# @param [Discorb::Snowflake, nil] after The ID of the user to start fetching from.
|
|
135
|
+
#
|
|
136
|
+
# @return [Async::Task<Array<Discorb::User>>] The users.
|
|
137
|
+
def fetch_reacted_users: (
|
|
138
|
+
Discorb::emoji emoji,
|
|
139
|
+
?limit: Integer?,
|
|
140
|
+
?after: Discorb::Snowflake?
|
|
141
|
+
) -> Async::Task[::Array[Discorb::User]]
|
|
142
|
+
|
|
143
|
+
#
|
|
144
|
+
# Pin the message.
|
|
145
|
+
# @async
|
|
146
|
+
#
|
|
147
|
+
# @param [String] reason The reason for pinning the message.
|
|
148
|
+
#
|
|
149
|
+
# @return [Async::Task<void>] The task.
|
|
150
|
+
def pin: (?reason: String?) -> Async::Task[void]
|
|
151
|
+
|
|
152
|
+
#
|
|
153
|
+
# Unpin the message.
|
|
154
|
+
# @async
|
|
155
|
+
#
|
|
156
|
+
# @param [String] reason The reason for unpinning the message.
|
|
157
|
+
#
|
|
158
|
+
# @return [Async::Task<void>] The task.
|
|
159
|
+
def unpin: (?reason: String?) -> Async::Task[void]
|
|
160
|
+
|
|
161
|
+
#
|
|
162
|
+
# Start thread from the message.
|
|
163
|
+
# @async
|
|
164
|
+
#
|
|
165
|
+
# @param (see Discorb::Channel#start_thread)
|
|
166
|
+
#
|
|
167
|
+
# @return [Async::Task<Discorb::ThreadChannel>] <description>
|
|
168
|
+
def start_thread: (
|
|
169
|
+
*untyped args,
|
|
170
|
+
**untyped kwargs
|
|
171
|
+
) -> Async::Task[Discorb::ThreadChannel]
|
|
172
|
+
|
|
173
|
+
# Meta
|
|
174
|
+
def inspect: -> String
|
|
175
|
+
|
|
176
|
+
# @return [Discorb::Snowflake] The ID of the message.
|
|
177
|
+
attr_reader id: Discorb::Snowflake
|
|
178
|
+
|
|
179
|
+
# @return [Discorb::User, Discorb::Member] The user that sent the message.
|
|
180
|
+
attr_reader author: Discorb::User
|
|
181
|
+
| Discorb::Member
|
|
182
|
+
| Discorb::Webhook::Message::Author
|
|
183
|
+
|
|
184
|
+
# @return [String] The content of the message.
|
|
185
|
+
attr_reader content: String
|
|
186
|
+
alias to_s content
|
|
187
|
+
|
|
188
|
+
# @return [Time] The time the message was created.
|
|
189
|
+
attr_reader created_at: Time
|
|
190
|
+
alias timestamp created_at
|
|
191
|
+
alias sent_at created_at
|
|
192
|
+
|
|
193
|
+
# @return [Time] The time the message was edited.
|
|
194
|
+
# @return [nil] If the message was not edited.
|
|
195
|
+
attr_reader updated_at: Time?
|
|
196
|
+
alias edited_at updated_at
|
|
197
|
+
alias edited_timestamp updated_at
|
|
198
|
+
|
|
199
|
+
# @return [Array<Discorb::Attachment>] The attachments of the message.
|
|
200
|
+
attr_reader attachments: ::Array[Discorb::Attachment]
|
|
201
|
+
|
|
202
|
+
# @return [Array<Discorb::Embed>] The embeds of the message.
|
|
203
|
+
attr_reader embeds: ::Array[Discorb::Embed]
|
|
204
|
+
|
|
205
|
+
# @return [Array<Discorb::Reaction>] The reactions of the message.
|
|
206
|
+
attr_reader reactions: ::Array[Discorb::Reaction]
|
|
207
|
+
|
|
208
|
+
# @return [Discorb::Snowflake] The ID of the channel the message was sent in.
|
|
209
|
+
attr_reader webhook_id: Discorb::Snowflake
|
|
210
|
+
|
|
211
|
+
# @return [Symbol] The type of the message.
|
|
212
|
+
# Currently, this will be one of:
|
|
213
|
+
#
|
|
214
|
+
# * `:default`
|
|
215
|
+
# * `:recipient_add`
|
|
216
|
+
# * `:recipient_remove`
|
|
217
|
+
# * `:call`
|
|
218
|
+
# * `:channel_name_change`
|
|
219
|
+
# * `:channel_icon_change`
|
|
220
|
+
# * `:channel_pinned_message`
|
|
221
|
+
# * `:guild_member_join`
|
|
222
|
+
# * `:user_premium_guild_subscription`
|
|
223
|
+
# * `:user_premium_guild_subscription_tier_1`
|
|
224
|
+
# * `:user_premium_guild_subscription_tier_2`
|
|
225
|
+
# * `:user_premium_guild_subscription_tier_3`
|
|
226
|
+
# * `:channel_follow_add`
|
|
227
|
+
# * `:guild_discovery_disqualified`
|
|
228
|
+
# * `:guild_discovery_requalified`
|
|
229
|
+
# * `:guild_discovery_grace_period_initial_warning`
|
|
230
|
+
# * `:guild_discovery_grace_period_final_warning`
|
|
231
|
+
# * `:thread_created`
|
|
232
|
+
# * `:reply`
|
|
233
|
+
# * `:chat_input_command`
|
|
234
|
+
# * `:thread_starter_message`
|
|
235
|
+
# * `:guild_invite_reminder`
|
|
236
|
+
# * `:context_menu_command`
|
|
237
|
+
attr_reader type: Symbol
|
|
238
|
+
|
|
239
|
+
# @return [Discorb::Message::Activity] The activity of the message.
|
|
240
|
+
attr_reader activity: Discorb::Message::Activity
|
|
241
|
+
|
|
242
|
+
# @return [Discorb::Application] The application of the message.
|
|
243
|
+
attr_reader application_id: Discorb::Application
|
|
244
|
+
|
|
245
|
+
# @return [Discorb::Message::Reference] The reference of the message.
|
|
246
|
+
attr_reader message_reference: Discorb::Message::Reference
|
|
247
|
+
|
|
248
|
+
# @return [Discorb::Message::Flag] The flag of the message.
|
|
249
|
+
# @see Discorb::Message::Flag
|
|
250
|
+
attr_reader flag: Discorb::Message::Flag
|
|
251
|
+
|
|
252
|
+
# @return [Discorb::Message::Sticker] The sticker of the message.
|
|
253
|
+
attr_reader stickers: Discorb::Message::Sticker
|
|
254
|
+
|
|
255
|
+
# @return [Discorb::Message::Interaction] The interaction of the message.
|
|
256
|
+
attr_reader interaction: Discorb::Message::Interaction
|
|
257
|
+
|
|
258
|
+
# @return [Discorb::ThreadChannel] The thread channel of the message.
|
|
259
|
+
attr_reader thread: Discorb::ThreadChannel
|
|
260
|
+
|
|
261
|
+
# @return [Array<Array<Discorb::Component>>] The components of the message.
|
|
262
|
+
attr_reader components: ::Array[::Array[Discorb::Component]]
|
|
263
|
+
|
|
264
|
+
# @return [Boolean] Whether the message is deleted.
|
|
265
|
+
attr_reader deleted: bool
|
|
266
|
+
|
|
267
|
+
# @return [Boolean] Whether the message is tts.
|
|
268
|
+
attr_reader tts: bool
|
|
269
|
+
|
|
270
|
+
# @return [Boolean] Whether the message mentions everyone.
|
|
271
|
+
attr_reader mention_everyone: bool
|
|
272
|
+
|
|
273
|
+
# @return [Boolean] Whether the message is pinned.
|
|
274
|
+
attr_reader pinned: bool
|
|
275
|
+
|
|
276
|
+
# @macro client_cache
|
|
277
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
|
278
|
+
attr_reader channel: Discorb::Channel & Discorb::Messageable
|
|
279
|
+
|
|
280
|
+
# @macro client_cache
|
|
281
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
|
282
|
+
# @return [nil] If the message was not sent in a guild.
|
|
283
|
+
attr_reader guild: Discorb::Guild?
|
|
284
|
+
|
|
285
|
+
# @return [Boolean] Whether the message was sent by a webhook.
|
|
286
|
+
attr_reader webhook?: bool
|
|
287
|
+
|
|
288
|
+
# @return [Boolean] Whether the message was edited.
|
|
289
|
+
attr_reader edited?: bool
|
|
290
|
+
|
|
291
|
+
# @return [String] The URL to jump to the message.
|
|
292
|
+
attr_reader jump_url: String
|
|
293
|
+
|
|
294
|
+
# @return [Discorb::Embed] The embed of the message.
|
|
295
|
+
# @return [nil] If the message has no embed.
|
|
296
|
+
attr_reader embed: Discorb::Embed?
|
|
297
|
+
|
|
298
|
+
# @!attribute [r] channel
|
|
299
|
+
# @macro client_cache
|
|
300
|
+
# @return [Discorb::Channel] The channel the message was sent in.
|
|
301
|
+
# @!attribute [r] guild
|
|
302
|
+
# @macro client_cache
|
|
303
|
+
# @return [Discorb::Guild] The guild the message was sent in.
|
|
304
|
+
# @return [nil] If the message was not sent in a guild.
|
|
305
|
+
# @!attribute [r] webhook?
|
|
306
|
+
# @return [Boolean] Whether the message was sent by a webhook.
|
|
307
|
+
# @!attribute [r] edited?
|
|
308
|
+
# @return [Boolean] Whether the message was edited.
|
|
309
|
+
# @!attribute [r] jump_url
|
|
310
|
+
# @return [String] The URL to jump to the message.
|
|
311
|
+
# @!attribute [r] embed
|
|
312
|
+
# @return [Discorb::Embed] The embed of the message.
|
|
313
|
+
# @return [nil] If the message has no embed.
|
|
314
|
+
# @!attribute [r] embed?
|
|
315
|
+
# @return [Boolean] Whether the message has an embed.
|
|
316
|
+
# @!attribute [r] reply?
|
|
317
|
+
# @return [Boolean] Whether the message is a reply.
|
|
318
|
+
# @!attribute [r] dm?
|
|
319
|
+
# @return [Boolean] Whether the message was sent in a DM.
|
|
320
|
+
# @!attribute [r] guild?
|
|
321
|
+
# @return [Boolean] Whether the message was sent in a guild.
|
|
322
|
+
attr_reader embed?: bool
|
|
323
|
+
|
|
324
|
+
# @return [Boolean] Whether the message is a reply.
|
|
325
|
+
attr_reader reply?: bool
|
|
326
|
+
|
|
327
|
+
# @return [Boolean] Whether the message was sent in a DM.
|
|
328
|
+
attr_reader dm?: bool
|
|
329
|
+
|
|
330
|
+
# @return [Boolean] Whether the message was sent in a guild.
|
|
331
|
+
attr_reader guild?: bool
|
|
332
|
+
|
|
333
|
+
#
|
|
334
|
+
# Represents message flag.
|
|
335
|
+
# ## Flag fields
|
|
336
|
+
# |Field|Value|
|
|
337
|
+
# |-|-|
|
|
338
|
+
# |`1 << 0`|`:crossposted`|
|
|
339
|
+
# |`1 << 1`|`:crosspost`|
|
|
340
|
+
# |`1 << 2`|`:supress_embeds`|
|
|
341
|
+
# |`1 << 3`|`:source_message_deleted`|
|
|
342
|
+
# |`1 << 4`|`:urgent`|
|
|
343
|
+
# |`1 << 5`|`:has_thread`|
|
|
344
|
+
# |`1 << 6`|`:ephemeral`|
|
|
345
|
+
# |`1 << 7`|`:loading`|
|
|
346
|
+
class Flag < Discorb::Flag
|
|
347
|
+
attr_accessor crossposted: bool
|
|
348
|
+
attr_accessor crosspost: bool
|
|
349
|
+
attr_accessor supress_embeds: bool
|
|
350
|
+
attr_accessor source_message_deleted: bool
|
|
351
|
+
attr_accessor urgent: bool
|
|
352
|
+
attr_accessor has_thread: bool
|
|
353
|
+
attr_accessor ephemeral: bool
|
|
354
|
+
attr_accessor loading: bool
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
#
|
|
358
|
+
# Represents reference of message.
|
|
359
|
+
class Reference
|
|
360
|
+
#
|
|
361
|
+
# Initialize a new reference.
|
|
362
|
+
#
|
|
363
|
+
# @param [Discorb::Snowflake] guild_id The guild ID.
|
|
364
|
+
# @param [Discorb::Snowflake] channel_id The channel ID.
|
|
365
|
+
# @param [Discorb::Snowflake] message_id The message ID.
|
|
366
|
+
# @param [Boolean] fail_if_not_exists Whether fail the request if the message is not found.
|
|
367
|
+
def initialize: (
|
|
368
|
+
Discorb::Snowflake guild_id,
|
|
369
|
+
Discorb::Snowflake channel_id,
|
|
370
|
+
Discorb::Snowflake message_id,
|
|
371
|
+
?fail_if_not_exists: bool
|
|
372
|
+
) -> void
|
|
373
|
+
|
|
374
|
+
#
|
|
375
|
+
# Convert the reference to a hash.
|
|
376
|
+
#
|
|
377
|
+
# @return [Hash] The hash.
|
|
378
|
+
def to_hash: -> Discorb::json
|
|
379
|
+
|
|
380
|
+
#
|
|
381
|
+
# Initialize a new reference from a hash.
|
|
382
|
+
#
|
|
383
|
+
# @param [Hash] data The hash.
|
|
384
|
+
#
|
|
385
|
+
# @return [Discorb::Message::Reference] The reference.
|
|
386
|
+
# @see https://discord.com/developers/docs/resources/channel#message-reference-object
|
|
387
|
+
def self.from_hash: (Discorb::json data) -> Discorb::Message::Reference
|
|
388
|
+
|
|
389
|
+
def inspect: -> String
|
|
390
|
+
|
|
391
|
+
# @return [Discorb::Snowflake] The guild ID.
|
|
392
|
+
attr_accessor guild_id: Discorb::Snowflake
|
|
393
|
+
|
|
394
|
+
# @return [Discorb::Snowflake] The channel ID.
|
|
395
|
+
attr_accessor channel_id: Discorb::Snowflake
|
|
396
|
+
|
|
397
|
+
# @return [Discorb::Snowflake] The message ID.
|
|
398
|
+
attr_accessor message_id: Discorb::Snowflake
|
|
399
|
+
|
|
400
|
+
# @return [Boolean] Whether fail the request if the message is not found.
|
|
401
|
+
attr_accessor fail_if_not_exists: bool
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
#
|
|
405
|
+
# Represents a sticker.
|
|
406
|
+
class Sticker
|
|
407
|
+
def initialize: (untyped data) -> void
|
|
408
|
+
|
|
409
|
+
def inspect: -> String
|
|
410
|
+
|
|
411
|
+
# @return [Discorb::Snowflake] The sticker ID.
|
|
412
|
+
attr_reader id: Discorb::Snowflake
|
|
413
|
+
|
|
414
|
+
# @return [String] The sticker name.
|
|
415
|
+
attr_reader name: String
|
|
416
|
+
|
|
417
|
+
# @return [Symbol] The sticker format.
|
|
418
|
+
attr_reader format: Symbol
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
#
|
|
422
|
+
# Represents a interaction of message.
|
|
423
|
+
class Interaction < Discorb::DiscordModel
|
|
424
|
+
#
|
|
425
|
+
# Initialize a new interaction.
|
|
426
|
+
# @private
|
|
427
|
+
#
|
|
428
|
+
# @param [Discorb::Client] client The client.
|
|
429
|
+
# @param [Hash] data The interaction data.
|
|
430
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
|
431
|
+
|
|
432
|
+
def inspect: -> String
|
|
433
|
+
|
|
434
|
+
# @return [Discorb::Snowflake] The interaction ID.
|
|
435
|
+
attr_reader id: Discorb::Snowflake
|
|
436
|
+
|
|
437
|
+
# @return [String] The name of command.
|
|
438
|
+
# @return [nil] If the message is not a command.
|
|
439
|
+
attr_reader name: String?
|
|
440
|
+
|
|
441
|
+
# @return [Class] The type of interaction.
|
|
442
|
+
attr_reader type: Class
|
|
443
|
+
|
|
444
|
+
# @return [Discorb::User] The user.
|
|
445
|
+
attr_reader user: Discorb::User
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
#
|
|
449
|
+
# Represents a activity of message.
|
|
450
|
+
class Activity < Discorb::DiscordModel
|
|
451
|
+
TYPES: untyped
|
|
452
|
+
|
|
453
|
+
#
|
|
454
|
+
# Initialize a new activity.
|
|
455
|
+
# @private
|
|
456
|
+
#
|
|
457
|
+
# @param [Hash] data The activity data.
|
|
458
|
+
def initialize: (Discorb::json data) -> void
|
|
459
|
+
|
|
460
|
+
def inspect: -> String
|
|
461
|
+
|
|
462
|
+
# @return [String] The name of activity.
|
|
463
|
+
attr_reader name: String
|
|
464
|
+
|
|
465
|
+
# @return [Symbol] The type of activity.
|
|
466
|
+
attr_reader type: Symbol
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Module for sending and reading messages.
|
|
4
|
+
module Messageable
|
|
5
|
+
#
|
|
6
|
+
# Returns the dm channel id of the user.
|
|
7
|
+
# @private
|
|
8
|
+
#
|
|
9
|
+
# @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
|
|
10
|
+
def channel_id: -> Async::Task[Discorb::Snowflake]
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Post a message to the channel.
|
|
14
|
+
# @async
|
|
15
|
+
#
|
|
16
|
+
# @param [String] content The message content.
|
|
17
|
+
# @param [Boolean] tts Whether the message is tts.
|
|
18
|
+
# @param [Discorb::Embed] embed The embed to send.
|
|
19
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send.
|
|
20
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions.
|
|
21
|
+
# @param [Discorb::Message, Discorb::Message::Reference] reference The message to reply to.
|
|
22
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
|
23
|
+
# @param [Discorb::Attachment] attachment The attachment to send.
|
|
24
|
+
# @param [Array<Discorb::Attachment>] attachments The attachments to send.
|
|
25
|
+
#
|
|
26
|
+
# @return [Async::Task<Discorb::Message>] The message sent.
|
|
27
|
+
def post: (
|
|
28
|
+
?String? content,
|
|
29
|
+
?tts: bool,
|
|
30
|
+
?embed: Discorb::Embed?,
|
|
31
|
+
?embeds: ::Array[Discorb::Embed]?,
|
|
32
|
+
?allowed_mentions: Discorb::AllowedMentions?,
|
|
33
|
+
?reference: (Discorb::Message | Discorb::Message::Reference)?,
|
|
34
|
+
?components: (::Array[Discorb::Component]
|
|
35
|
+
| ::Array[::Array[Discorb::Component]])?,
|
|
36
|
+
?attachment: Discorb::Attachment?,
|
|
37
|
+
?attachments: ::Array[Discorb::Attachment]?
|
|
38
|
+
) -> Async::Task[Discorb::Message]
|
|
39
|
+
|
|
40
|
+
#
|
|
41
|
+
# Edit a message.
|
|
42
|
+
# @async
|
|
43
|
+
# @!macro edit
|
|
44
|
+
#
|
|
45
|
+
# @param [#to_s] message_id The message id.
|
|
46
|
+
# @param [String] content The message content.
|
|
47
|
+
# @param [Discorb::Embed] embed The embed to send.
|
|
48
|
+
# @param [Array<Discorb::Embed>] embeds The embeds to send.
|
|
49
|
+
# @param [Discorb::AllowedMentions] allowed_mentions The allowed mentions.
|
|
50
|
+
# @param [Array<Discorb::Attachment>] attachments The new attachments.
|
|
51
|
+
# @param [Array<Discorb::Component>, Array<Array<Discorb::Component>>] components The components to send.
|
|
52
|
+
# @param [Boolean] supress Whether to supress embeds.
|
|
53
|
+
#
|
|
54
|
+
# @return [Async::Task<void>] The task.
|
|
55
|
+
def edit_message: (
|
|
56
|
+
_ToS message_id,
|
|
57
|
+
?String content,
|
|
58
|
+
?embed: Discorb::Embed,
|
|
59
|
+
?embeds: ::Array[Discorb::Embed],
|
|
60
|
+
?allowed_mentions: Discorb::AllowedMentions,
|
|
61
|
+
?attachments: ::Array[Discorb::Attachment],
|
|
62
|
+
?components: ::Array[Discorb::Component]
|
|
63
|
+
| ::Array[::Array[Discorb::Component]],
|
|
64
|
+
?supress: bool
|
|
65
|
+
) -> Async::Task[void]
|
|
66
|
+
|
|
67
|
+
#
|
|
68
|
+
# Delete a message.
|
|
69
|
+
# @async
|
|
70
|
+
#
|
|
71
|
+
# @param [#to_s] message_id The message id.
|
|
72
|
+
# @param [String] reason The reason for deleting the message.
|
|
73
|
+
#
|
|
74
|
+
# @return [Async::Task<void>] The task.
|
|
75
|
+
def delete_message!: (
|
|
76
|
+
_ToS message_id,
|
|
77
|
+
?reason: String?
|
|
78
|
+
) -> Async::Task[void]
|
|
79
|
+
|
|
80
|
+
#
|
|
81
|
+
# Fetch a message from ID.
|
|
82
|
+
# @async
|
|
83
|
+
#
|
|
84
|
+
# @param [Discorb::Snowflake] id The ID of the message.
|
|
85
|
+
#
|
|
86
|
+
# @return [Async::Task<Discorb::Message>] The message.
|
|
87
|
+
# @raise [Discorb::NotFoundError] If the message is not found.
|
|
88
|
+
def fetch_message: (Discorb::Snowflake id) -> Async::Task[Discorb::Message]
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# Fetch a message history.
|
|
92
|
+
# @async
|
|
93
|
+
#
|
|
94
|
+
# @param [Integer] limit The number of messages to fetch.
|
|
95
|
+
# @param [Discorb::Snowflake] before The ID of the message to fetch before.
|
|
96
|
+
# @param [Discorb::Snowflake] after The ID of the message to fetch after.
|
|
97
|
+
# @param [Discorb::Snowflake] around The ID of the message to fetch around.
|
|
98
|
+
#
|
|
99
|
+
# @return [Async::Task<Array<Discorb::Message>>] The messages.
|
|
100
|
+
def fetch_messages: (
|
|
101
|
+
?Integer limit,
|
|
102
|
+
?before: Discorb::Snowflake?,
|
|
103
|
+
?after: Discorb::Snowflake?,
|
|
104
|
+
?around: Discorb::Snowflake?
|
|
105
|
+
) -> Async::Task[::Array[Discorb::Message]]
|
|
106
|
+
|
|
107
|
+
#
|
|
108
|
+
# Fetch the pinned messages in the channel.
|
|
109
|
+
# @async
|
|
110
|
+
#
|
|
111
|
+
# @return [Async::Task<Array<Discorb::Message>>] The pinned messages in the channel.
|
|
112
|
+
def fetch_pins: -> Async::Task[::Array[Discorb::Message]]
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# Pin a message in the channel.
|
|
116
|
+
# @async
|
|
117
|
+
#
|
|
118
|
+
# @param [Discorb::Message] message The message to pin.
|
|
119
|
+
# @param [String] reason The reason of pinning the message.
|
|
120
|
+
#
|
|
121
|
+
# @return [Async::Task<void>] The task.
|
|
122
|
+
def pin_message: (
|
|
123
|
+
Discorb::Message message,
|
|
124
|
+
?reason: String?
|
|
125
|
+
) -> Async::Task[void]
|
|
126
|
+
|
|
127
|
+
#
|
|
128
|
+
# Unpin a message in the channel.
|
|
129
|
+
# @async
|
|
130
|
+
#
|
|
131
|
+
# @param [Discorb::Message] message The message to unpin.
|
|
132
|
+
# @param [String] reason The reason of unpinning the message.
|
|
133
|
+
#
|
|
134
|
+
# @return [Async::Task<void>] The task.
|
|
135
|
+
def unpin_message: (
|
|
136
|
+
Discorb::Message message,
|
|
137
|
+
?reason: String?
|
|
138
|
+
) -> Async::Task[void]
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Trigger the typing indicator in the channel.
|
|
142
|
+
# @async
|
|
143
|
+
#
|
|
144
|
+
# If block is given, trigger typing indicator during executing block.
|
|
145
|
+
# @example
|
|
146
|
+
# channel.typing do
|
|
147
|
+
# channel.post("Waiting for 60 seconds...")
|
|
148
|
+
# sleep 60
|
|
149
|
+
# channel.post("Done!")
|
|
150
|
+
# end
|
|
151
|
+
def typing: -> Async::Task[void] | [R] { -> R } -> R
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a partial custom emoji in discord.
|
|
4
|
+
class PartialEmoji < Discorb::DiscordModel
|
|
5
|
+
#
|
|
6
|
+
# Initialize a new partial custom emoji.
|
|
7
|
+
# @private
|
|
8
|
+
#
|
|
9
|
+
# @param [Hash] data The data of the emoji.
|
|
10
|
+
def initialize: (Discorb::json data) -> void
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Format the emoji for URI.
|
|
14
|
+
#
|
|
15
|
+
# @return [String] the formatted emoji.
|
|
16
|
+
def to_uri: -> String
|
|
17
|
+
|
|
18
|
+
def inspect: -> String
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# Format the emoji for sending.
|
|
22
|
+
#
|
|
23
|
+
# @return [String] the formatted emoji.
|
|
24
|
+
def to_s: -> String
|
|
25
|
+
|
|
26
|
+
# @return [Discorb::Snowflake] The ID of the emoji.
|
|
27
|
+
attr_reader id: Discorb::Snowflake
|
|
28
|
+
|
|
29
|
+
# @return [String] The name of the emoji.
|
|
30
|
+
attr_reader name: String
|
|
31
|
+
|
|
32
|
+
# @return [Boolean] Whether the emoji is deleted.
|
|
33
|
+
attr_reader deleted: bool
|
|
34
|
+
end
|
|
35
|
+
end
|