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,91 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a attachment file.
|
4
|
+
class Attachment
|
5
|
+
#
|
6
|
+
# Creates a new attachment.
|
7
|
+
#
|
8
|
+
# @param [#read, String] source The Source of the attachment.
|
9
|
+
# @param [String] filename The filename of the attachment. If not set, path or object_id of the IO is used.
|
10
|
+
# @param [String] description The description of the attachment.
|
11
|
+
# @param [String] content_type The content type of the attachment. If not set, it is guessed from the filename.
|
12
|
+
# If failed to guess, it is set to `application/octet-stream`.
|
13
|
+
# @param [Boolean] will_close Whether the IO will be closed after the attachment is sent.
|
14
|
+
def initialize: (
|
15
|
+
untyped | String source,
|
16
|
+
?String? filename,
|
17
|
+
?description: String?,
|
18
|
+
?content_type: String?,
|
19
|
+
?will_close: bool
|
20
|
+
) -> void
|
21
|
+
|
22
|
+
#
|
23
|
+
# Initializes the object from a hash.
|
24
|
+
# @private
|
25
|
+
def initialize_hash: (untyped data) -> untyped
|
26
|
+
|
27
|
+
def inspect: -> String
|
28
|
+
|
29
|
+
#
|
30
|
+
# Creates a new file from a hash.
|
31
|
+
# @private
|
32
|
+
def self.from_hash: (untyped data) -> untyped
|
33
|
+
|
34
|
+
#
|
35
|
+
# Creates a new file from a string.
|
36
|
+
#
|
37
|
+
# @param [String] string The string to create the file from.
|
38
|
+
# @param [String] filename The filename of the file. object_id of the string is used if not set.
|
39
|
+
# @param [String] content_type The content type of the file. If not set, it is guessed from the filename.
|
40
|
+
#
|
41
|
+
# @return [Discorb::Attachment] The new file.
|
42
|
+
def self.from_string: (
|
43
|
+
String string,
|
44
|
+
?String? filename,
|
45
|
+
?content_type: String?,
|
46
|
+
?description: untyped
|
47
|
+
) -> Discorb::Attachment
|
48
|
+
|
49
|
+
# @return [#read] The file content.
|
50
|
+
attr_reader io: untyped
|
51
|
+
|
52
|
+
# @return [String] The attachment filename.
|
53
|
+
attr_reader filename: String
|
54
|
+
|
55
|
+
# @return [String] The attachment content type.
|
56
|
+
attr_reader content_type: String
|
57
|
+
|
58
|
+
# @return [String] The attachment description.
|
59
|
+
attr_reader description: String?
|
60
|
+
|
61
|
+
# @return [Discorb::Snowflake] The attachment id.
|
62
|
+
attr_reader id: Discorb::Snowflake
|
63
|
+
|
64
|
+
# @return [Integer] The attachment size in bytes.
|
65
|
+
attr_reader size: Integer
|
66
|
+
|
67
|
+
# @return [String] The attachment url.
|
68
|
+
attr_reader url: String
|
69
|
+
|
70
|
+
# @return [String] The attachment proxy url.
|
71
|
+
attr_reader proxy_url: String
|
72
|
+
|
73
|
+
# @return [Integer] The image height.
|
74
|
+
# @return [nil] If the attachment is not an image.
|
75
|
+
attr_reader height: Integer?
|
76
|
+
|
77
|
+
# @return [Integer] The image width.
|
78
|
+
# @return [nil] If the attachment is not an image.
|
79
|
+
attr_reader width: Integer?
|
80
|
+
|
81
|
+
# @return [:client, :discord] The attachment was created by.
|
82
|
+
attr_reader created_by: :client | :discord
|
83
|
+
|
84
|
+
# @private
|
85
|
+
# @return [Boolean] Whether the attachment will be closed after it is sent.
|
86
|
+
attr_reader will_close: bool
|
87
|
+
|
88
|
+
# @return [Boolean] whether the file is an image.
|
89
|
+
attr_reader image?: bool
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a Discord audit log.
|
4
|
+
class AuditLog < Discorb::DiscordModel
|
5
|
+
#
|
6
|
+
# Initializes a new instance of the AuditLog class.
|
7
|
+
# @private
|
8
|
+
def initialize: (untyped client, untyped data, untyped guild) -> void
|
9
|
+
|
10
|
+
def inspect: -> String
|
11
|
+
|
12
|
+
#
|
13
|
+
# Gets an entry from entries.
|
14
|
+
#
|
15
|
+
# @param [Integer] index The index of the entry.
|
16
|
+
#
|
17
|
+
# @return [Discorb::AuditLog::Entry] The entry.
|
18
|
+
# @return [nil] If the index is out of range.
|
19
|
+
def []: (Integer index) -> Discorb::AuditLog::Entry
|
20
|
+
|
21
|
+
# @return [Array<Discorb::Webhook>] The webhooks in this audit log.
|
22
|
+
attr_reader webhooks: ::Array[Discorb::Webhook]
|
23
|
+
|
24
|
+
# @return [Array<Discorb::User>] The users in this audit log.
|
25
|
+
attr_reader users: ::Array[Discorb::User]
|
26
|
+
|
27
|
+
# @return [Array<Discorb::ThreadChannel>] The threads in this audit log.
|
28
|
+
attr_reader threads: ::Array[Discorb::ThreadChannel]
|
29
|
+
|
30
|
+
# @return [Array<Discorb::AuditLog::Entry>] The entries in this audit log.
|
31
|
+
attr_reader entries: ::Array[Discorb::AuditLog::Entry]
|
32
|
+
|
33
|
+
#
|
34
|
+
# Represents an entry in an audit log.
|
35
|
+
class Entry < Discorb::DiscordModel
|
36
|
+
EVENTS: untyped
|
37
|
+
CONVERTERS: untyped
|
38
|
+
|
39
|
+
#
|
40
|
+
# Initializes a new AuditLog entry.
|
41
|
+
# @private
|
42
|
+
def initialize: (untyped client, untyped data, _ToS guild_id) -> void
|
43
|
+
|
44
|
+
#
|
45
|
+
# Get a change with the given key.
|
46
|
+
#
|
47
|
+
# @param [Symbol] key The key to get.
|
48
|
+
#
|
49
|
+
# @return [Discorb::AuditLog::Entry::Change] The change with the given key.
|
50
|
+
# @return [nil] The change with the given key does not exist.
|
51
|
+
def []: (Symbol key) -> Discorb::AuditLog::Entry::Change
|
52
|
+
|
53
|
+
def inspect: -> String
|
54
|
+
|
55
|
+
# @return [Discorb::Snowflake] The ID of the entry.
|
56
|
+
attr_reader id: Discorb::Snowflake
|
57
|
+
|
58
|
+
# @return [Discorb::Snowflake] The ID of the user who performed the action.
|
59
|
+
attr_reader user_id: Discorb::Snowflake
|
60
|
+
|
61
|
+
# @return [Discorb::Snowflake] The ID of the target of the action.
|
62
|
+
attr_reader target_id: Discorb::Snowflake
|
63
|
+
|
64
|
+
# @return [Symbol] The type of the entry.
|
65
|
+
# These symbols will be used:
|
66
|
+
#
|
67
|
+
# * `:guild_update`
|
68
|
+
# * `:channel_create`
|
69
|
+
# * `:channel_update`
|
70
|
+
# * `:channel_delete`
|
71
|
+
# * `:channel_overwrite_create`
|
72
|
+
# * `:channel_overwrite_update`
|
73
|
+
# * `:channel_overwrite_delete`
|
74
|
+
# * `:member_kick`
|
75
|
+
# * `:member_prune`
|
76
|
+
# * `:member_ban_add`
|
77
|
+
# * `:member_ban_remove`
|
78
|
+
# * `:member_update`
|
79
|
+
# * `:member_role_update`
|
80
|
+
# * `:member_move`
|
81
|
+
# * `:member_disconnect`
|
82
|
+
# * `:bot_add`
|
83
|
+
# * `:role_create`
|
84
|
+
# * `:role_update`
|
85
|
+
# * `:role_delete`
|
86
|
+
# * `:invite_create`
|
87
|
+
# * `:invite_update`
|
88
|
+
# * `:invite_delete`
|
89
|
+
# * `:webhook_create`
|
90
|
+
# * `:webhook_update`
|
91
|
+
# * `:webhook_delete`
|
92
|
+
# * `:emoji_create`
|
93
|
+
# * `:emoji_update`
|
94
|
+
# * `:emoji_delete`
|
95
|
+
# * `:message_delete`
|
96
|
+
# * `:message_bulk_delete`
|
97
|
+
# * `:message_pin`
|
98
|
+
# * `:message_unpin`
|
99
|
+
# * `:integration_create`
|
100
|
+
# * `:integration_update`
|
101
|
+
# * `:integration_delete`
|
102
|
+
# * `:stage_instance_create`
|
103
|
+
# * `:stage_instance_update`
|
104
|
+
# * `:stage_instance_delete`
|
105
|
+
# * `:sticker_create`
|
106
|
+
# * `:sticker_update`
|
107
|
+
# * `:sticker_delete`
|
108
|
+
# * `:guild_scheduled_event_create`
|
109
|
+
# * `:guild_scheduled_event_update`
|
110
|
+
# * `:guild_scheduled_event_delete`
|
111
|
+
# * `:thread_create`
|
112
|
+
# * `:thread_update`
|
113
|
+
# * `:thread_delete`
|
114
|
+
# * `:application_command_permission_update``
|
115
|
+
attr_reader type: Symbol
|
116
|
+
|
117
|
+
# @return [Discorb::AuditLog::Entry::Changes] The changes in this entry.
|
118
|
+
attr_reader changes: Discorb::AuditLog::Entry::Changes
|
119
|
+
|
120
|
+
# @return [Discorb::Channel, Discorb::Role, Discorb::Member, Discorb::Guild, Discorb::Message]
|
121
|
+
# The target of the entry.
|
122
|
+
attr_reader target: Discorb::Channel
|
123
|
+
| Discorb::Role
|
124
|
+
| Discorb::Member
|
125
|
+
| Discorb::Guild
|
126
|
+
| Discorb::Message
|
127
|
+
| Discorb::Snowflake
|
128
|
+
|
129
|
+
# @return [Hash{Symbol => Object}] The optional data for this entry.
|
130
|
+
# @note You can use dot notation to access the data.
|
131
|
+
attr_reader options: ::Hash[Symbol, Object]
|
132
|
+
|
133
|
+
# @return [Discorb::User] The user who performed the action.
|
134
|
+
attr_reader user: Discorb::User
|
135
|
+
|
136
|
+
#
|
137
|
+
# Represents the changes in an audit log entry.
|
138
|
+
class Changes < Discorb::DiscordModel
|
139
|
+
#
|
140
|
+
# Initializes a new changes object.
|
141
|
+
# @private
|
142
|
+
#
|
143
|
+
# @param [Hash] data The data to initialize with.
|
144
|
+
def initialize: (Discorb::json data) -> void
|
145
|
+
|
146
|
+
#
|
147
|
+
# Formats the changes into a string.
|
148
|
+
def inspect: -> String
|
149
|
+
|
150
|
+
#
|
151
|
+
# Get keys of changes.
|
152
|
+
#
|
153
|
+
# @return [Array<Symbol>] The keys of the changes.
|
154
|
+
def keys: -> ::Array[Symbol]
|
155
|
+
|
156
|
+
#
|
157
|
+
# Get a change with the given key.
|
158
|
+
#
|
159
|
+
# @param [Symbol] key The key to get.
|
160
|
+
#
|
161
|
+
# @return [Discorb::AuditLog::Entry::Change] The change with the given key.
|
162
|
+
# @return [nil] The change with the given key does not exist.
|
163
|
+
def []: (Symbol key) -> Discorb::AuditLog::Entry::Change
|
164
|
+
|
165
|
+
# Returns the value of attribute data.
|
166
|
+
attr_reader data: untyped
|
167
|
+
end
|
168
|
+
|
169
|
+
#
|
170
|
+
# Represents a change in an audit log entry.
|
171
|
+
# @note This instance will try to call a method of {#new_value} if the method wasn't defined.
|
172
|
+
class Change < Discorb::DiscordModel
|
173
|
+
#
|
174
|
+
# Initializes a new change object.
|
175
|
+
# @private
|
176
|
+
def initialize: (untyped data) -> void
|
177
|
+
|
178
|
+
#
|
179
|
+
# Send a message to the new value.
|
180
|
+
def method_missing: (untyped method) -> untyped
|
181
|
+
|
182
|
+
#
|
183
|
+
# Format the change into a string.
|
184
|
+
#
|
185
|
+
# @return [String] The string representation of the change.
|
186
|
+
def inspect: -> String
|
187
|
+
|
188
|
+
#
|
189
|
+
# Whether the change responds to the given method.
|
190
|
+
#
|
191
|
+
# @return [Boolean] Whether the change responds to the given method.
|
192
|
+
def respond_to_missing?: (
|
193
|
+
untyped method,
|
194
|
+
?untyped include_private
|
195
|
+
) -> bool
|
196
|
+
|
197
|
+
# @return [Symbol] The key of the change.
|
198
|
+
attr_reader key: Symbol
|
199
|
+
|
200
|
+
# @return [Object] The old value of the change.
|
201
|
+
attr_reader old_value: Object
|
202
|
+
|
203
|
+
# @return [Object] The new value of the change.
|
204
|
+
attr_reader new_value: Object
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
#
|
209
|
+
# Represents an integration in an audit log entry.
|
210
|
+
class Integration < Discorb::DiscordModel
|
211
|
+
#
|
212
|
+
# Initializes a new integration object.
|
213
|
+
# @private
|
214
|
+
def initialize: (untyped data) -> void
|
215
|
+
|
216
|
+
def inspect: -> String
|
217
|
+
|
218
|
+
# @return [Discorb::Snowflake] The ID of the integration.
|
219
|
+
attr_reader id: Discorb::Snowflake
|
220
|
+
|
221
|
+
# @return [Symbol] The type of the integration.
|
222
|
+
attr_reader type: Symbol
|
223
|
+
|
224
|
+
# @return [String] The name of the integration.
|
225
|
+
attr_reader name: String
|
226
|
+
|
227
|
+
# @return [Discorb::Integration::Account] The account of the integration.
|
228
|
+
attr_reader account: Discorb::Integration::Account
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module Discorb
|
2
|
+
class AutoModRule < DiscordModel
|
3
|
+
type trigger_type = :keyword | :harmful_link | :spam | :keyword_preset
|
4
|
+
type preset_type = :profanity | :sexual_content | :slurs
|
5
|
+
|
6
|
+
# @return [Hash{Integer => Symbol}] The mapping of trigger types.
|
7
|
+
# @private
|
8
|
+
TRIGGER_TYPES: Hash[Integer, trigger_type]
|
9
|
+
|
10
|
+
# @return [Hash{Integer => Symbol}] The mapping of preset types.
|
11
|
+
# @private
|
12
|
+
PRESET_TYPES: Hash[Integer, preset_type]
|
13
|
+
|
14
|
+
# @return [Hash{Integer => Symbol}] The mapping of event types.
|
15
|
+
# @private
|
16
|
+
EVENT_TYPES: Hash[Integer, :message_send]
|
17
|
+
|
18
|
+
# @return [Discorb::Snowflake] The ID of the rule.
|
19
|
+
attr_reader id: Discorb::Snowflake
|
20
|
+
|
21
|
+
# @return [String] The name of the rule.
|
22
|
+
attr_reader name: String
|
23
|
+
|
24
|
+
# @return [Boolean] Whether the rule is enabled.
|
25
|
+
attr_reader enabled: bool
|
26
|
+
alias enabled? enabled
|
27
|
+
|
28
|
+
# @return [Array<Discorb::AutoModRule::Action>] The actions of the rule.
|
29
|
+
attr_reader actions: Array[Discorb::AutoModRule::Action]
|
30
|
+
|
31
|
+
# @return [Array<String>] The keywords that the rule is triggered by.
|
32
|
+
# @note This is only available if the trigger type is `:keyword`.
|
33
|
+
attr_reader keyword_filter: Array[String]?
|
34
|
+
|
35
|
+
# @return [Symbol] Returns the type of the preset.
|
36
|
+
# @note This is only available if the trigger type is `:keyword_preset`.
|
37
|
+
def preset_type: -> preset_type
|
38
|
+
|
39
|
+
# @return [Symbol] Returns the type of the trigger.
|
40
|
+
def trigger_type: -> trigger_type
|
41
|
+
|
42
|
+
# @return [Symbol] Returns the type of the event.
|
43
|
+
def event_type: -> :message_send
|
44
|
+
|
45
|
+
def creator: -> Discorb::Member
|
46
|
+
|
47
|
+
def guild: -> Discorb::Guild
|
48
|
+
|
49
|
+
def exempt_roles: -> Array[Discorb::Role]
|
50
|
+
|
51
|
+
def exempt_channels: -> Array[Discorb::Channel]
|
52
|
+
|
53
|
+
#
|
54
|
+
# Initialize a new auto mod.
|
55
|
+
# @private
|
56
|
+
#
|
57
|
+
# @param [Discorb::Client] client The client.
|
58
|
+
# @param [Hash] data The auto mod data.
|
59
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
60
|
+
|
61
|
+
#
|
62
|
+
# Edit the rule.
|
63
|
+
# @async
|
64
|
+
# @edit
|
65
|
+
#
|
66
|
+
# @param [String] name The name of the rule.
|
67
|
+
# @param [Symbol] event_type The event type of the rule. See {Discorb::AutoModRule::EVENT_TYPES}.
|
68
|
+
# @param [Array<Discorb::AutoModRule::Action>] actions The actions of the rule.
|
69
|
+
# @param [Boolean] enabled Whether the rule is enabled or not.
|
70
|
+
# @param [Array<Discorb::Role>] exempt_roles The roles that are exempt from the rule.
|
71
|
+
# @param [Array<Discorb::Channel>] exempt_channels The channels that are exempt from the rule.
|
72
|
+
# @param [Array<String>] keyword_filter The keywords to filter.
|
73
|
+
# @param [Symbol] presets The preset of the rule. See {Discorb::AutoModRule::PRESET_TYPES}.
|
74
|
+
# @param [String] reason The reason for creating the rule.
|
75
|
+
#
|
76
|
+
# @return [Async::Task<void>] The task.
|
77
|
+
def edit: (
|
78
|
+
?name: String,
|
79
|
+
?event_type: :send_message,
|
80
|
+
?actions: Array[Discorb::AutoModRule::Action],
|
81
|
+
?enabled: bool,
|
82
|
+
?exempt_roles: Array[Discorb::Role],
|
83
|
+
?exempt_channels: Array[Discorb::Channel],
|
84
|
+
?keyword_filter: Array[String]?,
|
85
|
+
?presets: :profanity | :sexual_content | :slurs,
|
86
|
+
?reason: nil
|
87
|
+
) -> Async::Task[void]
|
88
|
+
|
89
|
+
#
|
90
|
+
# Delete the rule.
|
91
|
+
#
|
92
|
+
# @param [String] reason The reason for deleting the rule.
|
93
|
+
#
|
94
|
+
# @return [Async::Task<void>] The task.
|
95
|
+
def delete!: (?reason: nil) -> Async::Task[void]
|
96
|
+
|
97
|
+
class Action < Discorb::DiscordModel
|
98
|
+
# @return [Hash{Integer => Symbol}] The mapping of action types.
|
99
|
+
# @private
|
100
|
+
ACTION_TYPES: Hash[Integer, Symbol]
|
101
|
+
|
102
|
+
# @return [Symbol] Returns the type of the action.
|
103
|
+
attr_reader type: :ban | :kick | :mute | :warn
|
104
|
+
|
105
|
+
# @return [Integer] The duration of the timeout.
|
106
|
+
# @note This is only available if the action type is `:timeout`.
|
107
|
+
attr_reader duration_seconds: Integer?
|
108
|
+
|
109
|
+
#
|
110
|
+
# Initialize a new action.
|
111
|
+
#
|
112
|
+
# @param [Symbol] type The type of the action.
|
113
|
+
# @param [Integer] duration_seconds The duration of the timeout.
|
114
|
+
# This is only available if the action type is `:timeout`.
|
115
|
+
# @param [Discorb::Channel] channel The channel that the alert message is sent to.
|
116
|
+
# This is only available if the action type is `:send_alert_message`.
|
117
|
+
def initialize: (
|
118
|
+
Symbol `type`,
|
119
|
+
?duration_seconds: Integer?,
|
120
|
+
?channel: Discorb::Channel?
|
121
|
+
) -> void
|
122
|
+
|
123
|
+
# @return [Discorb::Channel] The channel that the alert message is sent to.
|
124
|
+
# @note This is only available if the action type is `:send_alert_message`.
|
125
|
+
def channel: -> Discorb::Channel?
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a default avatar.
|
4
|
+
class DefaultAvatar < Discorb::DiscordModel
|
5
|
+
#
|
6
|
+
# Initialize a new instance of the DefaultAvatar class.
|
7
|
+
# @private
|
8
|
+
def initialize: (untyped discriminator) -> void
|
9
|
+
|
10
|
+
#
|
11
|
+
# Returns the URL of the avatar.
|
12
|
+
#
|
13
|
+
# @param [String] image_format The image format. This is compatible with {Asset#url}, will be ignored.
|
14
|
+
# @param [Integer] size The size of the image. This is compatible with {Asset#url}, will be ignored.
|
15
|
+
#
|
16
|
+
# @return [String] URL of the avatar.
|
17
|
+
#
|
18
|
+
# rubocop: disable Lint/UnusedMethodArgument
|
19
|
+
def url: (?image_format: String?, ?size: Integer) -> String
|
20
|
+
|
21
|
+
def inspect: -> String
|
22
|
+
|
23
|
+
# @return [false] For compatibility with {Asset}, always `false`.
|
24
|
+
attr_reader animated?: bool
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a channel of Discord.
|
4
|
+
# @abstract
|
5
|
+
class Channel < Discorb::DiscordModel
|
6
|
+
#
|
7
|
+
# Initializes a new instance of the Channel class.
|
8
|
+
# @private
|
9
|
+
def initialize: (untyped client, untyped data, ?no_cache: untyped) -> void
|
10
|
+
|
11
|
+
#
|
12
|
+
# Checks if the channel is other channel.
|
13
|
+
#
|
14
|
+
# @param [Discorb::Channel] other The channel to check.
|
15
|
+
#
|
16
|
+
# @return [Boolean] True if the channel is other channel.
|
17
|
+
def ==: (Discorb::Channel other) -> bool
|
18
|
+
|
19
|
+
def inspect: -> String
|
20
|
+
|
21
|
+
#
|
22
|
+
# Returns the descendants of the Channel class.
|
23
|
+
# @private
|
24
|
+
def self.descendants: -> untyped
|
25
|
+
|
26
|
+
#
|
27
|
+
# Creates a new instance of the Channel class or instance of its descendants.
|
28
|
+
# @private
|
29
|
+
#
|
30
|
+
# @param [Discorb::Client] client The client that instantiated the object.
|
31
|
+
# @param [Hash] data The data of the object.
|
32
|
+
# @param [Boolean] no_cache Whether to disable cache the object.
|
33
|
+
def self.make_channel: (
|
34
|
+
Discorb::Client client,
|
35
|
+
Discorb::json data,
|
36
|
+
?no_cache: bool
|
37
|
+
) -> untyped
|
38
|
+
|
39
|
+
def `type`: -> String
|
40
|
+
|
41
|
+
#
|
42
|
+
# Returns the channel id to request.
|
43
|
+
# @private
|
44
|
+
#
|
45
|
+
# @return [Async::Task<Discorb::Snowflake>] A task that resolves to the channel id.
|
46
|
+
def channel_id: -> Async::Task[Discorb::Snowflake]
|
47
|
+
|
48
|
+
# @return [Discorb::Snowflake] The ID of the channel.
|
49
|
+
attr_reader id: Discorb::Snowflake
|
50
|
+
|
51
|
+
# @return [String] The name of the channel.
|
52
|
+
attr_reader name: String
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Represents a channel in guild.
|
57
|
+
# @abstract
|
58
|
+
class GuildChannel < Discorb::Channel
|
59
|
+
include Comparable
|
60
|
+
|
61
|
+
#
|
62
|
+
# Compares position of two channels.
|
63
|
+
#
|
64
|
+
# @param [Discorb::GuildChannel] other The channel to compare.
|
65
|
+
#
|
66
|
+
# @return [-1, 0, 1] -1 if the channel is at lower than the other, 1 if the channel is at highter than the other.
|
67
|
+
def <=>: (Discorb::GuildChannel other) -> Integer?
|
68
|
+
|
69
|
+
#
|
70
|
+
# Checks if the channel is same as another.
|
71
|
+
#
|
72
|
+
# @param [Discorb::GuildChannel] other The channel to check.
|
73
|
+
#
|
74
|
+
# @return [Boolean] `true` if the channel is same as another.
|
75
|
+
def ==: (Discorb::GuildChannel other) -> bool
|
76
|
+
|
77
|
+
#
|
78
|
+
# Stringifies the channel.
|
79
|
+
#
|
80
|
+
# @return [String] The name of the channel with `#`.
|
81
|
+
def to_s: -> String
|
82
|
+
|
83
|
+
def mention: -> String
|
84
|
+
|
85
|
+
def parent: -> Discorb::CategoryChannel?
|
86
|
+
|
87
|
+
def guild: -> Discorb::Guild
|
88
|
+
|
89
|
+
def inspect: -> String
|
90
|
+
|
91
|
+
#
|
92
|
+
# Deletes the channel.
|
93
|
+
# @async
|
94
|
+
#
|
95
|
+
# @param [String] reason The reason of deleting the channel.
|
96
|
+
#
|
97
|
+
# @return [Async::Task<self>] The deleted channel.
|
98
|
+
def delete!: (?reason: String?) -> Async::Task[self]
|
99
|
+
|
100
|
+
#
|
101
|
+
# Moves the channel to another position.
|
102
|
+
# @async
|
103
|
+
#
|
104
|
+
# @param [Integer] position The position to move the channel.
|
105
|
+
# @param [Boolean] lock_permissions Whether to lock the permissions of the channel.
|
106
|
+
# @param [Discorb::CategoryChannel] parent The parent of channel.
|
107
|
+
# @param [String] reason The reason of moving the channel.
|
108
|
+
#
|
109
|
+
# @return [Async::Task<self>] The moved channel.
|
110
|
+
def move: (
|
111
|
+
Integer position,
|
112
|
+
?lock_permissions: bool,
|
113
|
+
?parent: Discorb::CategoryChannel,
|
114
|
+
?reason: String?
|
115
|
+
) -> Async::Task[self]
|
116
|
+
|
117
|
+
#
|
118
|
+
# Set the channel's permission overwrite.
|
119
|
+
# @async
|
120
|
+
#
|
121
|
+
# @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
|
122
|
+
# @param [String] reason The reason of setting the overwrite.
|
123
|
+
# @param [{Symbol => Boolean}] perms The permission overwrites to replace.
|
124
|
+
#
|
125
|
+
# @return [Async::Task<void>] The task.
|
126
|
+
def set_permissions: (
|
127
|
+
Discorb::Role | Discorb::Member target,
|
128
|
+
?reason: String?,
|
129
|
+
**bool perms
|
130
|
+
) -> Async::Task[void]
|
131
|
+
|
132
|
+
#
|
133
|
+
# Delete the channel's permission overwrite.
|
134
|
+
# @async
|
135
|
+
#
|
136
|
+
# @param [Discorb::Role, Discorb::Member] target The target of the overwrite.
|
137
|
+
# @param [String] reason The reason of deleting the overwrite.
|
138
|
+
#
|
139
|
+
# @return [Async::Task<void>] The task.
|
140
|
+
def delete_permissions: (
|
141
|
+
Discorb::Role | Discorb::Member target,
|
142
|
+
?reason: String?
|
143
|
+
) -> Async::Task[void]
|
144
|
+
|
145
|
+
#
|
146
|
+
# Fetch the channel's invites.
|
147
|
+
# @async
|
148
|
+
#
|
149
|
+
# @return [Async::Task<Array<Discorb::Invite>>] The invites in the channel.
|
150
|
+
def fetch_invites: -> Async::Task[::Array[Discorb::Invite]]
|
151
|
+
|
152
|
+
#
|
153
|
+
# Create an invite in the channel.
|
154
|
+
# @async
|
155
|
+
#
|
156
|
+
# @param [Integer] max_age The max age of the invite.
|
157
|
+
# @param [Integer] max_uses The max uses of the invite.
|
158
|
+
# @param [Boolean] temporary Whether the invite is temporary.
|
159
|
+
# @param [Boolean] unique Whether the invite is unique.
|
160
|
+
# @note if it's `false` it may return existing invite.
|
161
|
+
# @param [String] reason The reason of creating the invite.
|
162
|
+
#
|
163
|
+
# @return [Async::Task<Invite>] The created invite.
|
164
|
+
def create_invite: (
|
165
|
+
?max_age: Integer?,
|
166
|
+
?max_uses: Integer?,
|
167
|
+
?temporary: bool,
|
168
|
+
?unique: bool,
|
169
|
+
?reason: String?
|
170
|
+
) -> Async::Task[Invite]
|
171
|
+
|
172
|
+
# @return [Integer] The position of the channel as integer.
|
173
|
+
attr_reader position: Integer
|
174
|
+
|
175
|
+
# @return [Hash{Discorb::Role, Discorb::Member => PermissionOverwrite}] The permission overwrites of the channel.
|
176
|
+
attr_reader permission_overwrites: Hash[Discorb::Role
|
177
|
+
| Discorb::Member, Discorb::PermissionOverwrite]
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Discorb
|
2
|
+
#
|
3
|
+
# Represents a category in a guild.
|
4
|
+
class CategoryChannel < Discorb::GuildChannel
|
5
|
+
include Discorb::ChannelContainer
|
6
|
+
|
7
|
+
def channels: -> Array[Discorb::GuildChannel]
|
8
|
+
|
9
|
+
def create_text_channel: (
|
10
|
+
String name,
|
11
|
+
?topic: String?,
|
12
|
+
?rate_limit_per_user: Integer?,
|
13
|
+
?slowmode: Integer?,
|
14
|
+
?position: Integer?,
|
15
|
+
?nsfw: bool?,
|
16
|
+
?permission_overwrites: Hash[(Discorb::Role
|
17
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
18
|
+
?parent: Discorb::CategoryChannel?,
|
19
|
+
?reason: String?
|
20
|
+
) -> Async::Task[Discorb::TextChannel]
|
21
|
+
|
22
|
+
def create_voice_channel: (
|
23
|
+
String name,
|
24
|
+
?bitrate: Integer,
|
25
|
+
?user_limit: Integer?,
|
26
|
+
?position: Integer?,
|
27
|
+
?permission_overwrites: Hash[(Discorb::Role
|
28
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
29
|
+
?parent: Discorb::CategoryChannel?,
|
30
|
+
?reason: String?
|
31
|
+
) -> Async::Task[Discorb::VoiceChannel]
|
32
|
+
|
33
|
+
def create_news_channel: (
|
34
|
+
String name,
|
35
|
+
?topic: String?,
|
36
|
+
?rate_limit_per_user: Integer?,
|
37
|
+
?slowmode: Integer?,
|
38
|
+
?position: Integer?,
|
39
|
+
?nsfw: bool?,
|
40
|
+
?permission_overwrites: Hash[(Discorb::Role
|
41
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
42
|
+
?parent: Discorb::CategoryChannel?,
|
43
|
+
?reason: String?
|
44
|
+
) -> Async::Task[Discorb::NewsChannel]
|
45
|
+
|
46
|
+
def create_stage_channel: (
|
47
|
+
String name,
|
48
|
+
?bitrate: Integer,
|
49
|
+
?position: Integer?,
|
50
|
+
?permission_overwrites: Hash[(Discorb::Role
|
51
|
+
| Discorb::Member), Discorb::PermissionOverwrite]?,
|
52
|
+
?parent: Discorb::CategoryChannel?,
|
53
|
+
?reason: String?
|
54
|
+
) -> Async::Task[Discorb::StageChannel]
|
55
|
+
end
|
56
|
+
end
|