Module: Vox::HTTP::Routes::Emoji
- Defined in:
- lib/vox/http/routes/emoji.rb
Overview
Mixin for emoji routes.
Instance Method Summary collapse
-
#create_guild_emoji(guild_id, image:, name: :undef, roles: :undef) ⇒ Hash<Symbol, Object>
Create an emoji in a target guild.
-
#delete_guild_emoji(guild_id, emoji_id, reason: nil) ⇒ nil
Delete an emoji by its ID.
-
#get_guild_emoji(guild_id, emoji_id) ⇒ Hash<Symbol, Object>
Get an emoji object by ID.
-
#list_guild_emojis(guild_id) ⇒ Array<Hash<Symbol, Object>>
Fetch a list of emojis for a given guild.
-
#modify_guild_emoji(guild_id, emoji_id, name: :undef, roles: :undef, reason: nil) ⇒ Hash<Symbol, Object>
Modify a guild emoji.
Instance Method Details
#create_guild_emoji(guild_id, image:, name: :undef, roles: :undef) ⇒ Hash<Symbol, Object>
Note:
Attempting to upload an emoji image larger than 256kb will result in a Error::BadRequest with no JSON status code.
Create an emoji in a target guild.
46 47 48 49 50 51 52 53 |
# File 'lib/vox/http/routes/emoji.rb', line 46 def create_guild_emoji(guild_id, image:, name: :undef, roles: :undef) image_data = image.io.read json = filter_undef({ name: name, roles: roles, image: "data:#{image.content_type};base64,#{Base64.encode64(image_data)}" }) route = Route.new(:POST, '/guilds/%{guild_id}/emojis', guild_id: guild_id) request(route, json: json) end |
#delete_guild_emoji(guild_id, emoji_id, reason: nil) ⇒ nil
Delete an emoji by its ID.
79 80 81 82 83 |
# File 'lib/vox/http/routes/emoji.rb', line 79 def delete_guild_emoji(guild_id, emoji_id, reason: nil) route = Route.new(:DELETE, '/guilds/%{guild_id}/emojis/%{emoji_id}', guild_id: guild_id, emoji_id: emoji_id) request(route, reason: reason) end |
#get_guild_emoji(guild_id, emoji_id) ⇒ Hash<Symbol, Object>
Get an emoji object by ID.
30 31 32 33 |
# File 'lib/vox/http/routes/emoji.rb', line 30 def get_guild_emoji(guild_id, emoji_id) route = Route.new(:GET, '/guilds/%{guild_id}/emojis/%{emoji_id}', guild_id: guild_id, emoji_id: emoji_id) request(route) end |
#list_guild_emojis(guild_id) ⇒ Array<Hash<Symbol, Object>>
Fetch a list of emojis for a given guild.
19 20 21 22 |
# File 'lib/vox/http/routes/emoji.rb', line 19 def list_guild_emojis(guild_id) route = Route.new(:GET, '/guilds/%{guild_id}/emojis', guild_id: guild_id) request(route) end |
#modify_guild_emoji(guild_id, emoji_id, name: :undef, roles: :undef, reason: nil) ⇒ Hash<Symbol, Object>
Modify a guild emoji.
65 66 67 68 69 70 |
# File 'lib/vox/http/routes/emoji.rb', line 65 def modify_guild_emoji(guild_id, emoji_id, name: :undef, roles: :undef, reason: nil) json = filter_undef({ name: name, roles: roles }) route = Route.new(:PATCH, '/guilds/%{guild_id}/emojis/%{emoji_id}', guild_id: guild_id, emoji_id: emoji_id) request(route, json: json, reason: reason) end |