Skip to content

Commit 3d2fe7f

Browse files
committed
feat: add Profile#bio and Profile#bio=
1 parent fbcffca commit 3d2fe7f

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

lib/discordrb/api/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def update_current_application(token, custom_install_url: :undef, description: :
284284
nil,
285285
:patch,
286286
"#{Discordrb::API.api_base}/applications/@me",
287-
{ custom_install_url: custom_install_url, description: description, role_connections_verification_url: role_connections_verification_url, install_params: install_params, integration_types_config: integration_types_config, flags: flags, interactions_endpoint_url: interactions_endpoint_url, tags: tags, event_webhooks_url: event_webhooks_url, event_webhooks_status: event_webhooks_status, event_webhooks_types: event_webhooks_types, icon: icon, cover_image: cover_image }.reject { |_, value| value == :undef }.to_json,
287+
{ custom_install_url:, description:, role_connections_verification_url:, install_params:, integration_types_config:, flags:, interactions_endpoint_url:, tags:, event_webhooks_url:, event_webhooks_status:, event_webhooks_types:, icon:, cover_image: }.reject { |_, value| value == :undef }.to_json,
288288
Authorization: token,
289289
content_type: :json
290290
)

lib/discordrb/data/application.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Application
2222
# @return [String] the application's name.
2323
attr_reader :name
2424

25-
# @return [String] the application's description.
25+
# @return [String] the application's description, or an empty string if the application doesn't have a description.
2626
attr_reader :description
2727

2828
# @return [Array<String>] the application's origins permitted to use RPC.
@@ -42,10 +42,6 @@ class Application
4242
attr_reader :public
4343
alias_method :public?, :public
4444

45-
# @return [Profile] the user object of the associated bot for this application.
46-
attr_reader :profile
47-
alias_method :bot, :profile
48-
4945
# @return [true, false] whether the bot requires the full OAuth2 code grant in order to join servers.
5046
attr_reader :requires_code_grant
5147
alias_method :requires_code_grant?, :requires_code_grant
@@ -170,7 +166,7 @@ def add_integration_type(type:, scopes: nil, permissions: nil)
170166
# Update the flags of this application. I recommend using this instead of {#flags=}.
171167
# @param add [Array<Integer, Symbol> Integer, Symbol] The flags to add to the application.
172168
# @param remove [Array<Integer, Symbol> Integer, Symbol] The flags to remove from the application.
173-
# @note The flags will be removed first, then added. Only limited intent flags can be updated.
169+
# @note The flags will be removed first, and then added. Only limited intent flags can be updated.
174170
def update_flags(add: 0, remove: 0)
175171
flags = lambda do |value|
176172
[*value].map { |flag_bit| FLAGS[flag_bit] || flag_bit.to_i }.reduce(&:|)
@@ -301,7 +297,6 @@ def update_data(new_data)
301297
@owner = new_data['owner'] ? @bot.ensure_user(new_data['owner']) : nil
302298

303299
@public = new_data['bot_public']
304-
@profile = new_data['bot'] ? Profile.new(new_data['bot'], @bot) : nil
305300
@requires_code_grant = new_data['bot_require_code_grant']
306301
@terms_of_service_url = new_data['terms_of_service_url']
307302
@privacy_policy_url = new_data['privacy_policy_url']

lib/discordrb/data/profile.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ def banner=(banner)
4040
end
4141
end
4242

43+
# Get the bot's global bio.
44+
# @return [String] The bot's global bio, or an empty string if it doesn't have one set.
45+
def bio
46+
@bot.application.description
47+
end
48+
49+
# Set the bot's global bio.
50+
# @param bio [String, nil] The bot's new global bio, or `nil` to remove the current bio.
51+
def bio=(bio)
52+
@bot.application.description = bio
53+
end
54+
4355
# Updates the cached profile data with the new one.
4456
# @note For internal use only.
4557
# @!visibility private

0 commit comments

Comments
 (0)