discordrb 3.7.1 → 3.7.2
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +15 -4
- data/lib/discordrb/api/server.rb +3 -2
- data/lib/discordrb/data/role.rb +72 -19
- data/lib/discordrb/data/server.rb +3 -3
- data/lib/discordrb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2229818c42fe455f937dceb0463ddb7489cd79058d6d617f0483ad8c287309ac
|
|
4
|
+
data.tar.gz: a0e966d6f85306b413cd8d7aad14f7746517fe4f241621c7ee84c0ac676e66f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c535560deb7c130f75292caa6dd31cbfeefcf553ac2b584de7e6346a1e6d84a09252990a4a46e21162e4fc6600eb31402abaea8985ecdfc317b700b819aa72b8
|
|
7
|
+
data.tar.gz: 2ba9ec20ad47028f5137fe025f443e6dd6b64d36ed85a996de499372179897ce75cf8c446c3eb7d5a6181d645dc948285606ef133a55e5d33ea7ad667d963848
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -5,17 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [3.7.
|
|
8
|
+
## [3.7.2] 2025-12-24
|
|
9
|
+
|
|
10
|
+
[View diff for this release](https://github.com/shardlab/discordrb/compare/v3.7.1...v3.7.2)
|
|
11
|
+
|
|
12
|
+
### Summary
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
#### What's Changed
|
|
15
|
+
|
|
16
|
+
- feat: role move interface by @Droid00000 in https://github.com/shardlab/discordrb/pull/377
|
|
17
|
+
- fix: condition to check components presence by @Droid00000 in https://github.com/shardlab/discordrb/pull/391
|
|
18
|
+
- fix: handle pre-existing thread-ids in WH URLs by @Droid00000 in https://github.com/shardlab/discordrb/pull/406
|
|
19
|
+
- fix: handle existing params in webhook urls by @swarley in https://github.com/shardlab/discordrb/pull/396
|
|
20
|
+
|
|
21
|
+
## [3.7.1] - 2025-11-24
|
|
11
22
|
|
|
12
|
-
[View diff for this release
|
|
23
|
+
[View diff for this release](https://github.com/shardlab/discordrb/compare/v3.7.0...v3.7.1)
|
|
13
24
|
|
|
14
25
|
### Summary
|
|
15
26
|
|
|
16
27
|
#### What's Changed
|
|
17
28
|
|
|
18
|
-
-
|
|
29
|
+
- fix: condition to check components presence by @Droid00000 #391
|
|
19
30
|
|
|
20
31
|
## [3.7.0] - 2025-10-22
|
|
21
32
|
|
data/lib/discordrb/api/server.rb
CHANGED
|
@@ -280,7 +280,7 @@ module Discordrb::API::Server
|
|
|
280
280
|
|
|
281
281
|
# Update role positions
|
|
282
282
|
# https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
|
|
283
|
-
def update_role_positions(token, server_id, roles)
|
|
283
|
+
def update_role_positions(token, server_id, roles, reason = nil)
|
|
284
284
|
Discordrb::API.request(
|
|
285
285
|
:guilds_sid_roles,
|
|
286
286
|
server_id,
|
|
@@ -288,7 +288,8 @@ module Discordrb::API::Server
|
|
|
288
288
|
"#{Discordrb::API.api_base}/guilds/#{server_id}/roles",
|
|
289
289
|
roles.to_json,
|
|
290
290
|
Authorization: token,
|
|
291
|
-
content_type: :json
|
|
291
|
+
content_type: :json,
|
|
292
|
+
'X-Audit-Log-Reason': reason
|
|
292
293
|
)
|
|
293
294
|
end
|
|
294
295
|
|
data/lib/discordrb/data/role.rb
CHANGED
|
@@ -165,6 +165,8 @@ module Discordrb
|
|
|
165
165
|
@unicode_emoji = other.unicode_emoji
|
|
166
166
|
@secondary_colour = other.secondary_colour
|
|
167
167
|
@tertiary_colour = other.tertiary_colour
|
|
168
|
+
@mentionable = other.mentionable?
|
|
169
|
+
@tags = other.tags
|
|
168
170
|
end
|
|
169
171
|
|
|
170
172
|
# Updates the data cache from a hash containing data
|
|
@@ -179,14 +181,16 @@ module Discordrb
|
|
|
179
181
|
@mentionable = new_data['mentionable']
|
|
180
182
|
@flags = new_data['flags']
|
|
181
183
|
colours = new_data['colors']
|
|
184
|
+
@managed = new_data['managed']
|
|
182
185
|
@permissions.bits = new_data['permissions'].to_i
|
|
183
186
|
@colour = ColourRGB.new(colours['primary_color'])
|
|
187
|
+
@tags = Tags.new(new_data['tags']) if new_data['tags']
|
|
184
188
|
@secondary_color = ColourRGB.new(colours['secondary_color']) if colours['secondary_color']
|
|
185
189
|
@tertiary_colour = ColourRGB.new(colours['tertiary_color']) if colours['tertiary_color']
|
|
186
190
|
end
|
|
187
191
|
|
|
188
192
|
# Sets the role name to something new
|
|
189
|
-
# @param name [String] The name that should be set
|
|
193
|
+
# @param name [String, nil] The name that should be set.
|
|
190
194
|
def name=(name)
|
|
191
195
|
update_role_data(name: name)
|
|
192
196
|
end
|
|
@@ -206,7 +210,7 @@ module Discordrb
|
|
|
206
210
|
# Sets the primary role colour to something new.
|
|
207
211
|
# @param colour [ColourRGB, Integer, nil] The new colour.
|
|
208
212
|
def colour=(colour)
|
|
209
|
-
|
|
213
|
+
update_colours(primary: colour)
|
|
210
214
|
end
|
|
211
215
|
|
|
212
216
|
# Sets the secondary role colour to something new.
|
|
@@ -293,7 +297,7 @@ module Discordrb
|
|
|
293
297
|
# https://discord.com/developers/docs/topics/permissions.
|
|
294
298
|
# @example Remove all permissions from a role
|
|
295
299
|
# role.packed = 0
|
|
296
|
-
# @param packed [Integer] A bitfield with the desired permissions value.
|
|
300
|
+
# @param packed [Integer, nil] A bitfield with the desired permissions value.
|
|
297
301
|
# @param update_perms [true, false] Whether the internal data should also be updated. This should always be true
|
|
298
302
|
# when calling externally.
|
|
299
303
|
def packed=(packed, update_perms = true)
|
|
@@ -305,17 +309,9 @@ module Discordrb
|
|
|
305
309
|
# @param other [Role, String, Integer, nil] The role, or its ID, above which this role should be moved. If it is `nil`,
|
|
306
310
|
# the role will be moved above the @everyone role.
|
|
307
311
|
# @return [Integer] the new position of this role
|
|
312
|
+
# @deprecated Please migrate to using {#move} with the `above` or `below` KWARGS.
|
|
308
313
|
def sort_above(other = nil)
|
|
309
|
-
other
|
|
310
|
-
roles = @server.roles.sort_by(&:position)
|
|
311
|
-
roles.delete_at(@position)
|
|
312
|
-
|
|
313
|
-
index = other ? roles.index { |role| role.id == other.id } + 1 : 1
|
|
314
|
-
roles.insert(index, self)
|
|
315
|
-
|
|
316
|
-
updated_roles = roles.map.with_index { |role, position| { id: role.id, position: position } }
|
|
317
|
-
@server.update_role_positions(updated_roles)
|
|
318
|
-
index
|
|
314
|
+
other ? move(above: other) : move(bottom: true)
|
|
319
315
|
end
|
|
320
316
|
|
|
321
317
|
alias_method :move_above, :sort_above
|
|
@@ -327,13 +323,69 @@ module Discordrb
|
|
|
327
323
|
@server.delete_role(@id)
|
|
328
324
|
end
|
|
329
325
|
|
|
326
|
+
# Move the position of this role in the roles list.
|
|
327
|
+
# @example This will move the role 2 places above the `@everyone` role.
|
|
328
|
+
# role.move(bottom: true, offset: 2)
|
|
329
|
+
# @example This will move the role above the `@muted` role.
|
|
330
|
+
# role.move(above: 257017090932867072)
|
|
331
|
+
# @example This will move the role 3 spots below the `No Images` role.
|
|
332
|
+
# roles.move(below: 254077236989132800, offset: -3)
|
|
333
|
+
# @param bottom [true, false, nil] Whether to move the roles to the bottom of the role list.
|
|
334
|
+
# @param above [Integer, String, Role, nil] The role that this role should be moved above.
|
|
335
|
+
# @param below [Integer, String, Role, nil] The role that this role should be moved below.
|
|
336
|
+
# @param offset [Integer, nil] The number of roles to offset the new position by. A positive number will
|
|
337
|
+
# move the role above, and a negative number will move the role below. This parameter is relative and
|
|
338
|
+
# calculated after the `bottom`, `above`, and `below` parameters.
|
|
339
|
+
# @param reason [String, nil] The audit log reason to show for moving the role.
|
|
340
|
+
# @return [Integer] the new position of the role.
|
|
341
|
+
def move(bottom: nil, above: nil, below: nil, offset: 0, reason: nil)
|
|
342
|
+
# rubocop:disable Style/IfUnlessModifier
|
|
343
|
+
if [bottom, above, below].count(&:itself) > 1
|
|
344
|
+
raise ArgumentError, "'bottom', 'above', and 'below' are mutually exclusive"
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
if (above || below) && !(target = @server.role(above || below))
|
|
348
|
+
raise ArgumentError, "The given 'above' or 'below' options are not valid"
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
if (below && target&.id == @server.id) || (@id == target&.id)
|
|
352
|
+
raise ArgumentError, 'The target role that was provded is not valid'
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# rubocop:enable Style/IfUnlessModifier
|
|
356
|
+
roles = @server.roles.uniq.sort_by { |role| [role.position, role.id] }
|
|
357
|
+
|
|
358
|
+
# Make sure we remove the current role.
|
|
359
|
+
myself = roles.rindex(self).tap { |index| roles.delete_at(index) }
|
|
360
|
+
|
|
361
|
+
index = if bottom
|
|
362
|
+
1
|
|
363
|
+
elsif below
|
|
364
|
+
roles.rindex(target)
|
|
365
|
+
elsif above
|
|
366
|
+
roles.rindex(target) + 1
|
|
367
|
+
else
|
|
368
|
+
myself
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
roles.insert([index + (offset || 0), 1].max, self)
|
|
372
|
+
|
|
373
|
+
roles = roles.map.with_index do |role, new_position|
|
|
374
|
+
{ id: role.resolve_id, position: new_position }
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
@server.update_role_positions(roles, reason: reason)
|
|
378
|
+
@position
|
|
379
|
+
end
|
|
380
|
+
|
|
330
381
|
# A rich interface designed to make working with role colours simple.
|
|
331
382
|
# @param primary [ColourRGB, Integer, nil] The new primary/base colour of this role, or nil to clear the primary colour.
|
|
332
383
|
# @param secondary [ColourRGB, Integer, nil] The new secondary colour of this role, or nil to clear the secondary colour.
|
|
333
384
|
# @param tertiary [ColourRGB, Integer,nil] The new tertiary colour of this role, or nil to clear the tertiary colour.
|
|
334
385
|
# @param holographic [true, false] Whether to apply or remove the holographic style to the role colour, overriding any other
|
|
335
386
|
# arguments that were passed. Using this argument is recommended over passing individual colours.
|
|
336
|
-
|
|
387
|
+
# @param reason [String, nil] The audit log reason to show for updating the role's colours.
|
|
388
|
+
def update_colours(primary: :undef, secondary: :undef, tertiary: :undef, holographic: :undef, reason: nil)
|
|
337
389
|
colours = {
|
|
338
390
|
primary_color: (primary == :undef ? @colour : primary)&.to_i,
|
|
339
391
|
tertiary_color: (tertiary == :undef ? @tertiary_colour : tertiary)&.to_i,
|
|
@@ -347,9 +399,9 @@ module Discordrb
|
|
|
347
399
|
}
|
|
348
400
|
|
|
349
401
|
# Only set the tertiary_color to `nil` if holographic is explicitly set to false.
|
|
350
|
-
colours[:tertiary_color] = nil if holographic.is_a?(FalseClass)
|
|
402
|
+
(colours[:tertiary_color] = nil) if holographic.is_a?(FalseClass)
|
|
351
403
|
|
|
352
|
-
update_role_data(colours: holographic == true ? holographic_colours : colours)
|
|
404
|
+
update_role_data(colours: holographic == true ? holographic_colours : colours, reason: reason)
|
|
353
405
|
end
|
|
354
406
|
|
|
355
407
|
alias_method :update_colors, :update_colours
|
|
@@ -361,14 +413,15 @@ module Discordrb
|
|
|
361
413
|
|
|
362
414
|
private
|
|
363
415
|
|
|
416
|
+
# @!visibility private
|
|
364
417
|
def update_role_data(new_data)
|
|
365
418
|
update_data(JSON.parse(API::Server.update_role(@bot.token, @server.id, @id,
|
|
366
|
-
new_data[:name]
|
|
419
|
+
new_data.key?(:name) ? new_data[:name] : :undef,
|
|
367
420
|
:undef,
|
|
368
421
|
new_data.key?(:hoist) ? new_data[:hoist] : :undef,
|
|
369
422
|
new_data.key?(:mentionable) ? new_data[:mentionable] : :undef,
|
|
370
|
-
new_data[:permissions]
|
|
371
|
-
|
|
423
|
+
new_data.key?(:permissions) ? new_data[:permissions] : :undef,
|
|
424
|
+
new_data[:reason],
|
|
372
425
|
new_data.key?(:icon) ? new_data[:icon] : :undef,
|
|
373
426
|
new_data.key?(:unicode_emoji) ? new_data[:unicode_emoji] : :undef,
|
|
374
427
|
new_data.key?(:colours) ? new_data[:colours] : :undef)))
|
|
@@ -412,11 +412,11 @@ module Discordrb
|
|
|
412
412
|
# Updates the positions of all roles on the server
|
|
413
413
|
# @note For internal use only
|
|
414
414
|
# @!visibility private
|
|
415
|
-
def update_role_positions(role_positions)
|
|
416
|
-
response = JSON.parse(API::Server.update_role_positions(@bot.token, @id, role_positions))
|
|
415
|
+
def update_role_positions(role_positions, reason: nil)
|
|
416
|
+
response = JSON.parse(API::Server.update_role_positions(@bot.token, @id, role_positions, reason))
|
|
417
417
|
response.each do |data|
|
|
418
418
|
updated_role = Role.new(data, @bot, self)
|
|
419
|
-
role(updated_role.id)
|
|
419
|
+
role(updated_role.id)&.update_from(updated_role)
|
|
420
420
|
end
|
|
421
421
|
end
|
|
422
422
|
|
data/lib/discordrb/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: discordrb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- meew0
|
|
@@ -86,14 +86,14 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 3.7.
|
|
89
|
+
version: 3.7.2
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 3.7.
|
|
96
|
+
version: 3.7.2
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: bundler
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|