discorb 0.18.0 → 0.20.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/build_version.yml +2 -2
- data/.rubocop.yml +12 -75
- data/Changelog.md +25 -0
- data/Gemfile +4 -4
- data/README.md +2 -1
- data/Rakefile +482 -459
- data/Steepfile +8 -6
- data/docs/application_command.md +1 -0
- data/docs/events.md +2 -2
- data/docs/voice_events.md +6 -6
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -394
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -265
- data/lib/discorb/app_command.rb +5 -5
- data/lib/discorb/application.rb +198 -197
- data/lib/discorb/asset.rb +101 -101
- data/lib/discorb/attachment.rb +134 -119
- data/lib/discorb/audit_logs.rb +412 -385
- data/lib/discorb/automod.rb +279 -269
- data/lib/discorb/channel/base.rb +107 -108
- data/lib/discorb/channel/category.rb +32 -32
- data/lib/discorb/channel/container.rb +44 -44
- data/lib/discorb/channel/dm.rb +26 -28
- data/lib/discorb/channel/guild.rb +311 -246
- data/lib/discorb/channel/stage.rb +156 -140
- data/lib/discorb/channel/text.rb +430 -336
- data/lib/discorb/channel/thread.rb +374 -325
- data/lib/discorb/channel/voice.rb +85 -79
- data/lib/discorb/channel.rb +5 -5
- data/lib/discorb/client.rb +635 -623
- data/lib/discorb/color.rb +178 -182
- data/lib/discorb/common.rb +168 -164
- data/lib/discorb/components/button.rb +107 -106
- data/lib/discorb/components/select_menu.rb +157 -145
- data/lib/discorb/components/text_input.rb +103 -106
- data/lib/discorb/components.rb +68 -66
- data/lib/discorb/dictionary.rb +135 -135
- data/lib/discorb/embed.rb +404 -398
- data/lib/discorb/emoji.rb +309 -302
- data/lib/discorb/emoji_table.rb +16099 -8857
- data/lib/discorb/error.rb +131 -131
- data/lib/discorb/event.rb +360 -314
- data/lib/discorb/event_handler.rb +39 -39
- data/lib/discorb/exe/about.rb +17 -17
- data/lib/discorb/exe/irb.rb +72 -67
- data/lib/discorb/exe/new.rb +323 -315
- data/lib/discorb/exe/run.rb +69 -68
- data/lib/discorb/exe/setup.rb +57 -55
- data/lib/discorb/exe/show.rb +12 -12
- data/lib/discorb/extend.rb +25 -45
- data/lib/discorb/extension.rb +89 -83
- data/lib/discorb/flag.rb +126 -128
- data/lib/discorb/gateway.rb +984 -794
- data/lib/discorb/gateway_events.rb +670 -638
- data/lib/discorb/gateway_requests.rb +45 -48
- data/lib/discorb/guild.rb +2115 -1626
- data/lib/discorb/guild_template.rb +280 -241
- data/lib/discorb/http.rb +247 -232
- data/lib/discorb/image.rb +42 -42
- data/lib/discorb/integration.rb +169 -161
- data/lib/discorb/intents.rb +161 -163
- data/lib/discorb/interaction/autocomplete.rb +76 -62
- data/lib/discorb/interaction/command.rb +279 -224
- data/lib/discorb/interaction/components.rb +114 -104
- data/lib/discorb/interaction/modal.rb +36 -32
- data/lib/discorb/interaction/response.rb +379 -330
- data/lib/discorb/interaction/root.rb +271 -118
- data/lib/discorb/interaction.rb +5 -5
- data/lib/discorb/invite.rb +154 -153
- data/lib/discorb/member.rb +344 -311
- data/lib/discorb/message.rb +615 -544
- data/lib/discorb/message_meta.rb +197 -186
- data/lib/discorb/modules.rb +371 -290
- data/lib/discorb/permission.rb +305 -289
- data/lib/discorb/presence.rb +352 -346
- data/lib/discorb/rate_limit.rb +81 -76
- data/lib/discorb/reaction.rb +55 -54
- data/lib/discorb/role.rb +272 -240
- data/lib/discorb/shard.rb +76 -74
- data/lib/discorb/sticker.rb +193 -171
- data/lib/discorb/user.rb +205 -188
- data/lib/discorb/utils/colored_puts.rb +16 -16
- data/lib/discorb/utils.rb +12 -16
- data/lib/discorb/voice_state.rb +305 -281
- data/lib/discorb/webhook.rb +537 -507
- data/lib/discorb.rb +62 -56
- data/sig/discorb/activity.rbs +1 -0
- data/sig/discorb/allowed_mentions.rbs +1 -0
- data/sig/discorb/app_command/base.rbs +7 -1
- data/sig/discorb/application.rbs +6 -0
- data/sig/discorb/asset.rbs +2 -0
- data/sig/discorb/attachment.rbs +8 -0
- data/sig/discorb/audit_log.rbs +7 -0
- data/sig/discorb/automod.rbs +32 -6
- data/sig/discorb/avatar.rbs +1 -0
- data/sig/discorb/channel/base.rbs +8 -1
- data/sig/discorb/channel/category.rbs +1 -0
- data/sig/discorb/channel/container.rbs +4 -0
- data/sig/discorb/channel/stage.rbs +4 -0
- data/sig/discorb/channel/text.rbs +2 -2
- data/sig/discorb/channel/thread.rbs +11 -0
- data/sig/discorb/channel/voice.rbs +2 -0
- data/sig/discorb/client.rbs +21 -20
- data/sig/discorb/color.rbs +6 -0
- data/sig/discorb/component/base.rbs +1 -0
- data/sig/discorb/component/button.rbs +2 -0
- data/sig/discorb/component/select_menu.rbs +4 -0
- data/sig/discorb/component/text_input.rbs +1 -0
- data/sig/discorb/custom_emoji.rbs +5 -1
- data/sig/discorb/dictionary.rbs +2 -0
- data/sig/discorb/discord_model.rbs +2 -0
- data/sig/discorb/embed.rbs +7 -0
- data/sig/discorb/emoji.rbs +1 -0
- data/sig/discorb/event_handler.rbs +2 -1
- data/sig/discorb/extension.rbs +13 -12
- data/sig/discorb/flag.rbs +2 -0
- data/sig/discorb/gateway.rbs +5 -0
- data/sig/discorb/guild.rbs +8 -4
- data/sig/discorb/guild_template.rbs +1 -1
- data/sig/discorb/http.rbs +4 -1
- data/sig/discorb/image.rbs +2 -0
- data/sig/discorb/integration.rbs +1 -1
- data/sig/discorb/intents.rbs +4 -3
- data/sig/discorb/interaction/base.rbs +36 -0
- data/sig/discorb/interaction/message_component.rbs +1 -2
- data/sig/discorb/interaction/modal.rbs +1 -2
- data/sig/discorb/interaction/responder.rbs +49 -49
- data/sig/discorb/invite.rbs +1 -1
- data/sig/discorb/member.rbs +2 -0
- data/sig/discorb/message.rbs +8 -1
- data/sig/discorb/messageable.rbs +1 -4
- data/sig/discorb/partial_emoji.rbs +3 -0
- data/sig/discorb/permissions.rbs +7 -0
- data/sig/discorb/presence.rbs +2 -0
- data/sig/discorb/reaction.rbs +5 -1
- data/sig/discorb/role.rbs +7 -1
- data/sig/discorb/scheduled_event.rbs +2 -1
- data/sig/discorb/shard.rbs +2 -1
- data/sig/discorb/snowflake.rbs +2 -0
- data/sig/discorb/stage_instance.rbs +9 -3
- data/sig/discorb/sticker.rbs +1 -1
- data/sig/discorb/unicode_emoji.rbs +4 -0
- data/sig/discorb/user.rbs +24 -20
- data/sig/discorb/webhook.rbs +17 -6
- data/sig/discorb/welcome_screen.rbs +1 -0
- data/sig/override.rbs +2 -0
- metadata +3 -3
@@ -1,241 +1,280 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents a guild template.
|
6
|
-
#
|
7
|
-
class GuildTemplate < DiscordModel
|
8
|
-
# @return [String] The code of the template.
|
9
|
-
attr_reader :code
|
10
|
-
# @return [String] The name of the template.
|
11
|
-
attr_reader :name
|
12
|
-
# @return [String] The description of the template.
|
13
|
-
attr_reader :description
|
14
|
-
# @return [Integer] The number of times this template has been used.
|
15
|
-
attr_reader :usage_count
|
16
|
-
# @return [Discorb::User] The user who created this template.
|
17
|
-
attr_reader :creator
|
18
|
-
# @return [Time] The time this template was created.
|
19
|
-
attr_reader :created_at
|
20
|
-
# @return [Time] The time this template was last updated.
|
21
|
-
attr_reader :updated_at
|
22
|
-
# @return [Discorb::Snowflake] The ID of guild where the template was created.
|
23
|
-
attr_reader :source_guild_id
|
24
|
-
# @return [Discorb::GuildTemplate::TemplateGuild] The guild where the template was created.
|
25
|
-
attr_reader :serialized_source_guild
|
26
|
-
alias content serialized_source_guild
|
27
|
-
# @return [Boolean] Whether this template is dirty.
|
28
|
-
attr_reader :is_dirty
|
29
|
-
alias dirty? is_dirty
|
30
|
-
|
31
|
-
# @!attribute [r] source_guild
|
32
|
-
# @macro client_cache
|
33
|
-
# @return [Discorb::Guild] The guild this template is based on.
|
34
|
-
# @return [nil] Client wasn't able to find the guild this template is based on.
|
35
|
-
|
36
|
-
#
|
37
|
-
# Initialize a new template.
|
38
|
-
# @private
|
39
|
-
#
|
40
|
-
# @param [Discorb::Client] client The client.
|
41
|
-
# @param [Hash] data The data from Discord.
|
42
|
-
#
|
43
|
-
def initialize(client, data)
|
44
|
-
@client = client
|
45
|
-
_set_data(data)
|
46
|
-
end
|
47
|
-
|
48
|
-
def source_guild
|
49
|
-
@client.guilds[@source_guild_id]
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Edit the template.
|
54
|
-
# @async
|
55
|
-
# @macro edit
|
56
|
-
#
|
57
|
-
# @param [String] name The new name of the template.
|
58
|
-
# @param [String] description The new description of the template.
|
59
|
-
#
|
60
|
-
# @return [Async::Task<void>] The task.
|
61
|
-
#
|
62
|
-
def edit(name = nil, description = Discorb::Unset)
|
63
|
-
Async do
|
64
|
-
payload = {}
|
65
|
-
payload[:name] = name if name
|
66
|
-
payload[:description] = description if description != Discorb::Unset
|
67
|
-
@client
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
#
|
136
|
-
|
137
|
-
# @
|
138
|
-
|
139
|
-
# @
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
#
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# @return [
|
192
|
-
attr_reader :
|
193
|
-
# @return [
|
194
|
-
attr_reader :
|
195
|
-
# @return [
|
196
|
-
attr_reader :
|
197
|
-
|
198
|
-
|
199
|
-
#
|
200
|
-
|
201
|
-
|
202
|
-
#
|
203
|
-
#
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
@
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a guild template.
|
6
|
+
#
|
7
|
+
class GuildTemplate < DiscordModel
|
8
|
+
# @return [String] The code of the template.
|
9
|
+
attr_reader :code
|
10
|
+
# @return [String] The name of the template.
|
11
|
+
attr_reader :name
|
12
|
+
# @return [String] The description of the template.
|
13
|
+
attr_reader :description
|
14
|
+
# @return [Integer] The number of times this template has been used.
|
15
|
+
attr_reader :usage_count
|
16
|
+
# @return [Discorb::User] The user who created this template.
|
17
|
+
attr_reader :creator
|
18
|
+
# @return [Time] The time this template was created.
|
19
|
+
attr_reader :created_at
|
20
|
+
# @return [Time] The time this template was last updated.
|
21
|
+
attr_reader :updated_at
|
22
|
+
# @return [Discorb::Snowflake] The ID of guild where the template was created.
|
23
|
+
attr_reader :source_guild_id
|
24
|
+
# @return [Discorb::GuildTemplate::TemplateGuild] The guild where the template was created.
|
25
|
+
attr_reader :serialized_source_guild
|
26
|
+
alias content serialized_source_guild
|
27
|
+
# @return [Boolean] Whether this template is dirty.
|
28
|
+
attr_reader :is_dirty
|
29
|
+
alias dirty? is_dirty
|
30
|
+
|
31
|
+
# @!attribute [r] source_guild
|
32
|
+
# @macro client_cache
|
33
|
+
# @return [Discorb::Guild] The guild this template is based on.
|
34
|
+
# @return [nil] Client wasn't able to find the guild this template is based on.
|
35
|
+
|
36
|
+
#
|
37
|
+
# Initialize a new template.
|
38
|
+
# @private
|
39
|
+
#
|
40
|
+
# @param [Discorb::Client] client The client.
|
41
|
+
# @param [Hash] data The data from Discord.
|
42
|
+
#
|
43
|
+
def initialize(client, data)
|
44
|
+
@client = client
|
45
|
+
_set_data(data)
|
46
|
+
end
|
47
|
+
|
48
|
+
def source_guild
|
49
|
+
@client.guilds[@source_guild_id]
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Edit the template.
|
54
|
+
# @async
|
55
|
+
# @macro edit
|
56
|
+
#
|
57
|
+
# @param [String] name The new name of the template.
|
58
|
+
# @param [String] description The new description of the template.
|
59
|
+
#
|
60
|
+
# @return [Async::Task<void>] The task.
|
61
|
+
#
|
62
|
+
def edit(name = nil, description = Discorb::Unset)
|
63
|
+
Async do
|
64
|
+
payload = {}
|
65
|
+
payload[:name] = name if name
|
66
|
+
payload[:description] = description if description != Discorb::Unset
|
67
|
+
@client
|
68
|
+
.http
|
69
|
+
.request(
|
70
|
+
Route.new(
|
71
|
+
"/guilds/#{@source_guild_id}/templates/#{@code}",
|
72
|
+
"//guilds/:guild_id/templates/:code",
|
73
|
+
:patch
|
74
|
+
),
|
75
|
+
payload
|
76
|
+
)
|
77
|
+
.wait
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
alias modify edit
|
82
|
+
|
83
|
+
#
|
84
|
+
# Update the template.
|
85
|
+
# @async
|
86
|
+
#
|
87
|
+
# @return [Async::Task<void>] The task.
|
88
|
+
#
|
89
|
+
def update
|
90
|
+
Async do
|
91
|
+
_resp, data =
|
92
|
+
@client
|
93
|
+
.http
|
94
|
+
.request(
|
95
|
+
Route.new(
|
96
|
+
"/guilds/#{@source_guild_id}/templates/#{@code}",
|
97
|
+
"//guilds/:guild_id/templates/:code",
|
98
|
+
:put
|
99
|
+
)
|
100
|
+
)
|
101
|
+
.wait
|
102
|
+
_set_data(data)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Delete the template.
|
108
|
+
# @async
|
109
|
+
#
|
110
|
+
# @return [Async::Task<void>] The task.
|
111
|
+
#
|
112
|
+
def delete
|
113
|
+
Async do
|
114
|
+
@client
|
115
|
+
.http
|
116
|
+
.request(
|
117
|
+
Route.new(
|
118
|
+
"/guilds/#{@source_guild_id}/templates/#{@code}",
|
119
|
+
"//guilds/:guild_id/templates/:code",
|
120
|
+
:delete
|
121
|
+
)
|
122
|
+
)
|
123
|
+
.wait
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
alias destroy delete
|
128
|
+
|
129
|
+
#
|
130
|
+
# Represents a guild in guild template.
|
131
|
+
#
|
132
|
+
class TemplateGuild < DiscordModel
|
133
|
+
# @return [String] The name of the guild.
|
134
|
+
attr_reader :name
|
135
|
+
# @return [Integer] The AFK timeout of the guild.
|
136
|
+
attr_reader :afk_timeout
|
137
|
+
# @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::Role}] A dictionary of roles in the guild.
|
138
|
+
attr_reader :roles
|
139
|
+
# @return [Discorb::SystemChannelFlag] The flag for the system channel.
|
140
|
+
attr_reader :system_channel_flags
|
141
|
+
# @return [Discorb::Dictionary{Discorb::Snowflake => Discorb::GuildChannel}]
|
142
|
+
# A dictionary of channels in the guild.
|
143
|
+
attr_reader :channels
|
144
|
+
# @return [String] The description of the guild.
|
145
|
+
attr_reader :description
|
146
|
+
# @return [Symbol] The preffered language of the guild.
|
147
|
+
# @note This modifies the language code, `-` will be replaced with `_`.
|
148
|
+
attr_reader :preferred_locale
|
149
|
+
# @return [:none, :low, :medium, :high, :very_high] The verification level of the guild.
|
150
|
+
attr_reader :verification_level
|
151
|
+
# @return [:all_messages, :only_mentions] The default message notification level of the guild.
|
152
|
+
attr_reader :default_message_notifications
|
153
|
+
# @return [:disabled_in_text, :members_without_roles, :all_members] The explict content filter level of the guild.
|
154
|
+
attr_reader :explicit_content_filter
|
155
|
+
# @return [Boolean] Whether the guild enabled the widget.
|
156
|
+
attr_reader :widget_enabled
|
157
|
+
alias widget_enabled? widget_enabled
|
158
|
+
|
159
|
+
#
|
160
|
+
# Initialize a new guild in guild template.
|
161
|
+
# @private
|
162
|
+
#
|
163
|
+
# @param [Hash] data The data from Discord.
|
164
|
+
#
|
165
|
+
def initialize(data)
|
166
|
+
@name = data[:name]
|
167
|
+
@description = data[:description]
|
168
|
+
@region = data[:region]
|
169
|
+
@verification_level =
|
170
|
+
Discorb::Guild::MFA_LEVELS[data[:verification_level]]
|
171
|
+
@default_message_notifications =
|
172
|
+
Discorb::Guild::NOTIFICATION_LEVELS[
|
173
|
+
data[:default_message_notifications]
|
174
|
+
]
|
175
|
+
@explicit_content_filter =
|
176
|
+
Discorb::Guild::EXPLICIT_CONTENT_FILTERS[
|
177
|
+
data[:explicit_content_filter]
|
178
|
+
]
|
179
|
+
@preferred_locale = data[:preferred_locale]
|
180
|
+
@afk_timeout = data[:afk_timeout]
|
181
|
+
@roles = data[:roles].map { |r| Role.new(r) }
|
182
|
+
@channels = data[:channels].map { |c| Channel.new(c) }
|
183
|
+
@system_channel_flags =
|
184
|
+
Discorb::SystemChannelFlag.new(data[:system_channel_flags])
|
185
|
+
end
|
186
|
+
|
187
|
+
#
|
188
|
+
# Represents a role in guild template.
|
189
|
+
#
|
190
|
+
class Role < DiscordModel
|
191
|
+
# @return [String] The name of the role.
|
192
|
+
attr_reader :name
|
193
|
+
# @return [Discorb::Permission] The permissions of the role.
|
194
|
+
attr_reader :permissions
|
195
|
+
# @return [Discorb::Color] The color of the role.
|
196
|
+
attr_reader :color
|
197
|
+
|
198
|
+
#
|
199
|
+
# Initialize a new role in guild template.
|
200
|
+
# @private
|
201
|
+
#
|
202
|
+
# @param [Hash] data The data from Discord.
|
203
|
+
#
|
204
|
+
def initialize(data)
|
205
|
+
@name = data[:name]
|
206
|
+
@permissions = Permission.new(data[:permissions])
|
207
|
+
@color = Color.new(data[:color])
|
208
|
+
@hoist = data[:hoist]
|
209
|
+
@mentionable = data[:mentionable]
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
#
|
214
|
+
# Represents a channel in guild template.
|
215
|
+
#
|
216
|
+
class Channel < DiscordModel
|
217
|
+
# @return [String] The name of the channel.
|
218
|
+
attr_reader :name
|
219
|
+
# @return [Integer] The position of the channel.
|
220
|
+
attr_reader :position
|
221
|
+
# @return [String] The type of the channel.
|
222
|
+
attr_reader :topic
|
223
|
+
# @return [Integer] The bitrate of the channel.
|
224
|
+
attr_reader :bitrate
|
225
|
+
# @return [Integer] The user limit of the channel.
|
226
|
+
attr_reader :user_limit
|
227
|
+
# @return [Boolean] Whether the channel is nsfw.
|
228
|
+
attr_reader :nsfw
|
229
|
+
# @return [Integer] The rate limit of the channel.
|
230
|
+
attr_reader :rate_limit_per_user
|
231
|
+
# @return [Class] The class of the channel.
|
232
|
+
attr_reader :type
|
233
|
+
|
234
|
+
#
|
235
|
+
# Initialize a new channel in guild template.
|
236
|
+
# @private
|
237
|
+
#
|
238
|
+
# @param [Hash] data The data from Discord.
|
239
|
+
#
|
240
|
+
def initialize(data)
|
241
|
+
@name = data[:name]
|
242
|
+
@position = data[:position]
|
243
|
+
@topic = data[:topic]
|
244
|
+
@bitrate = data[:bitrate]
|
245
|
+
@user_limit = data[:user_limit]
|
246
|
+
@nsfw = data[:nsfw]
|
247
|
+
@rate_limit_per_user = data[:rate_limit_per_user]
|
248
|
+
@parent_id = data[:parent_id]
|
249
|
+
@permission_overwrites =
|
250
|
+
data[:permission_overwrites].to_h do |ow|
|
251
|
+
[
|
252
|
+
Snowflake.new(ow[:id]),
|
253
|
+
PermissionOverwrite.new(ow[:allow], ow[:deny])
|
254
|
+
]
|
255
|
+
end
|
256
|
+
@type =
|
257
|
+
Discorb::Channel.descendants.find do |c|
|
258
|
+
c.channel_type == data[:type]
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
private
|
265
|
+
|
266
|
+
def _set_data(data)
|
267
|
+
@code = data[:code]
|
268
|
+
@name = data[:name]
|
269
|
+
@description = data[:description]
|
270
|
+
@usage_count = data[:usage_count]
|
271
|
+
@creator_id = Snowflake.new(data[:creator_id])
|
272
|
+
@creator = @client.users[@creator_id] || User.new(@client, data[:creator])
|
273
|
+
@created_at = Time.iso8601(data[:created_at])
|
274
|
+
@updated_at = Time.iso8601(data[:updated_at])
|
275
|
+
@source_guild_id = Snowflake.new(data[:source_guild_id])
|
276
|
+
@serialized_source_guild = data[:serialized_source_guild]
|
277
|
+
@is_dirty = data[:is_dirty]
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|