You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add global_name to User after new usernames system
+ Add User#display_name
+ Change User#distinct to use discriminator or not, depend to the context (Maybe need change method later, next API versions may remove the discriminator field)
+ Change Discordrb::API::User#default_avatar & User#avatar_url to use old method to calculate index or not, depend to legacy or not (Maybe need change method later, next API versions may remove the discriminator field)
+ Change Member#display_name to select global_name before username, but after server nickname
+ Change Webhook#avatar_url to use new method to calculate index (After testing the webhook creation, the ID already seems to be used for the default avatar instead of the discriminator at 0000)
* Modification to allow to determine if User is a Webhook
+ Without relying on a 0000 discrimator, since it is very likely that this field will disappear completely, sooner or later
* Add missing flag
+ As I saw that the 'ACTIVE_DEVELOPER' flag was missing in the documentation, I added it in the process.
* Rubocop friendly
* Addition of missing cache edit
Copy file name to clipboardExpand all lines: lib/discordrb/data/user.rb
+40-9
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,18 @@ module UserAttributes
18
18
verified_bot: 1 << 16,
19
19
verified_developer: 1 << 17,
20
20
certified_moderator: 1 << 18,
21
-
bot_http_interactions: 1 << 19
21
+
bot_http_interactions: 1 << 19,
22
+
active_developer: 1 << 22
22
23
}.freeze
23
24
# rubocop:enable Naming/VariableNumber
24
25
25
26
# @return [String] this user's username
26
27
attr_reader:username
27
28
alias_method:name,:username
28
29
30
+
# @return [String, nil] this user's global name
31
+
attr_reader:global_name
32
+
29
33
# @return [String] this user's discriminator which is used internally to identify users with identical usernames.
30
34
attr_reader:discriminator
31
35
alias_method:discrim,:discriminator
@@ -36,10 +40,21 @@ module UserAttributes
36
40
attr_reader:bot_account
37
41
alias_method:bot_account?,:bot_account
38
42
43
+
# @return [true, false] whether this is fake user for a webhook message
44
+
attr_reader:webhook_account
45
+
alias_method:webhook_account?,:webhook_account
46
+
alias_method:webhook?,:webhook_account
47
+
39
48
# @return [String] the ID of this user's current avatar, can be used to generate an avatar URL.
40
49
# @see #avatar_url
41
50
attr_accessor:avatar_id
42
51
52
+
# Utility function to get Discord's display name of a user not in server
53
+
# @return [String] the name the user displays as (global_name if they have one, username otherwise)
54
+
defdisplay_name
55
+
global_name || username
56
+
end
57
+
43
58
# Utility function to mention users in messages
44
59
# @return [String] the mention code in the form of <@id>
45
60
defmention
@@ -48,15 +63,25 @@ def mention
48
63
49
64
# Utility function to get Discord's distinct representation of a user, i.e. username + discriminator
50
65
# @return [String] distinct representation of user
66
+
# TODO: Maybe change this method again after discriminator removal ?
51
67
defdistinct
52
-
"#{@username}##{@discriminator}"
68
+
if@discriminator && @discriminator != '0'
69
+
"#{@username}##{@discriminator}"
70
+
else
71
+
@username.to_s
72
+
end
53
73
end
54
74
55
75
# Utility function to get a user's avatar URL.
56
76
# @param format [String, nil] If `nil`, the URL will default to `webp` for static avatars, and will detect if the user has a `gif` avatar. You can otherwise specify one of `webp`, `jpg`, `png`, or `gif` to override this. Will always be PNG for default avatars.
57
77
# @return [String] the URL to the avatar image.
78
+
# TODO: Maybe change this method again after discriminator removal ?
0 commit comments