Skip to content
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: application emojis #282

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Droid00000
Copy link
Contributor

@Droid00000 Droid00000 commented Oct 25, 2024

Summary

Add support for CRUD operations on application emojis via the REST API, among a few other things.

Added

API calls for application emojis.
API::Application.list_application_emojis
API::Application.get_application_emoji
API::Application.create_application_emoji
API::Application.edit_application_emoji
API::Application.delete_application_emoji

Abstractions for application emojis.
Bot#application_emojis
Bot#get_application_emoji
Bot#create_application_emoji
Bot#edit_application_emoji
Bot#delete_application_emoji

New emoji object fields.
Emoji#user
Emoji#managed
Emoji#available
Emoji#require_colons

icon: parameter for Server#create_role

Discordrb#encode_file Helper method to base64 encode a file.

intents = [intents] unless intents.is_a? Array in calculate intents.

User#banner= Method to set the banner and corresponding methods.

Removed

Removal of all user account methods.
API::login
API::logout
API::validate_token
Gateway::VOICE_PING
API::acknowledge_message
User#change_status_setting

Fixed

Fixed a bug where parsed emojis would provide the wrong value for animated.

Fixed the route for API::User.change_own_nickname. /members/@me/nick has been deprecated in favor of /members/@me.

Make Channel#bulk_delete return immediately if there aren't enough messages to delete.

@vStone
Copy link

vStone commented Oct 30, 2024

Should it not be image/jpeg as per the docs? https://discord.com/developers/docs/reference#image-data

Also, maybe support for gif and png image uploads (by file name extension) could be useful

@swarley
Copy link
Member

swarley commented Oct 30, 2024

Looks like this logic was pulled from the standard emoji flow which does this poorly. We do already have a MIME type gem which is used for role icons

      mime_type = MIME::Types.type_for(icon.__send__(path_method)).first&.to_s || 'image/jpeg'

@Droid00000
Copy link
Contributor Author

I will update the emoji flow to use MIME types.

@Droid00000
Copy link
Contributor Author

Looks like this logic was pulled from the standard emoji flow which does this poorly. We do already have a MIME type gem which is used for role icons

      mime_type = MIME::Types.type_for(icon.__send__(path_method)).first&.to_s || 'image/jpeg'

I have pushed a commit to make the Bot#create_application_emoji method utilize MIME types.

@vStone
Copy link

vStone commented Nov 2, 2024

For documentation purposes, if you need to resize before uploading:

ImageWrapper = Struct.new(:blob, :original_filename_value) do
  def read
    blob
  end

  def original_filename
    original_filename_value
  end
end
image = MiniMagick::Image.open(file_path)
image.resize('256x256')
image_wrapper = ImageWrapper.new(image.to_blob, file_path)
emoji = @bot.create_application_emoji(emoji_name, image_wrapper)

@Droid00000
Copy link
Contributor Author

For documentation purposes, if you need to resize before uploading:

ImageWrapper = Struct.new(:blob, :original_filename_value) do

  def read

    blob

  end



  def original_filename

    original_filename_value

  end

end
image = MiniMagick::Image.open(file_path)

image.resize('256x256')

image_wrapper = ImageWrapper.new(image.to_blob, file_path)

emoji = @bot.create_application_emoji(emoji_name, image_wrapper)

Is this a request for an addition to the docs or is this comment meant to serve as the documentation itself.

@vStone
Copy link

vStone commented Nov 4, 2024

I needed to brain-dump this somewhere for future-self. You could add it to the docs or throw it in an example perhaps?

@Droid00000
Copy link
Contributor Author

I needed to brain-dump this somewhere for future-self. You could add it to the docs or throw it in an example perhaps?

Ah, alright, that's cool by me. I won't be adding this to the docs or making an example out of it, though. It would be better to just point people to your comment, imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants