-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add server avatar #146
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,13 @@ module MemberAttributes | |
# @return [Time] When the user's timeout will expire. | ||
attr_reader :communication_disabled_until | ||
alias_method :timeout, :communication_disabled_until | ||
|
||
# @!attribute [r] avatar_id | ||
# @return [String, nil] the ID of this member's current avatar, can be used to generate an avatar URL. | ||
# @see Member#avatar_url | ||
def avatar_id | ||
@avatar || @user.avatar_id | ||
end | ||
end | ||
|
||
# A member is a user on a server. It differs from regular users in that it has roles, voice statuses and things like | ||
|
@@ -77,6 +84,7 @@ def initialize(data, server, bot) | |
timeout_until = data['communication_disabled_until'] | ||
@communication_disabled_until = timeout_until ? Time.parse(timeout_until) : nil | ||
@permissions = Permissions.new(data['permissions']) if data['permissions'] | ||
@avatar_id = data['avatar'] | ||
end | ||
|
||
# @return [Server] the server this member is on. | ||
|
@@ -294,6 +302,13 @@ def display_name | |
nickname || username | ||
end | ||
|
||
# (See User#avatar_url) | ||
def avatar_url(format = nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include a parameter to get the global avatar_url, regardless of a Member's avatar_id, since the Member doesn't provide easy access to the underlying Also, would be more appropriate on MemberAttributes for consistency (#avatar_url is on UserAttributes) before the v4 rework |
||
return @user.avatar_url(format) unless @avatar_id | ||
|
||
API::Server.avatar_url(@server_id, @user.id, @avatar_id, format) | ||
end | ||
|
||
# Update this member's roles | ||
# @note For internal use only. | ||
# @!visibility private | ||
|
@@ -335,6 +350,7 @@ def update_data(data) | |
update_nick(data['nick']) if data.key?('nick') | ||
@mute = data['mute'] if data.key?('mute') | ||
@deaf = data['deaf'] if data.key?('deaf') | ||
@avatar_id = data['avatar'] if data.key?('avatar') | ||
|
||
@joined_at = Time.parse(data['joined_at']) if data['joined_at'] | ||
timeout_until = data['communication_disabled_until'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.