Method: Discorb::Guild#create_emoji

Defined in:
lib/discorb/guild.rb

#create_emoji(name, image, roles: []) ⇒ Async::Task<Discorb::CustomEmoji>

Create a custom emoji.

Parameters:

  • name (#to_s)

    The name of the emoji.

  • image (Discorb::Image)

    The image of the emoji.

  • roles (Array<Discorb::Role>) (defaults to: [])

    A list of roles to give the emoji.

Returns:



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/discorb/guild.rb', line 425

def create_emoji(name, image, roles: [])
  Async do
    _resp, data =
      @client
        .http
        .request(
          Route.new(
            "/guilds/#{@id}/emojis",
            "//guilds/:guild_id/emojis",
            :post
          ),
          {
            name: name,
            image: image.to_s,
            roles: roles.map { |r| Discorb::Utils.try(r, :id) }
          }
        )
        .wait
    @emojis[data[:id]] = CustomEmoji.new(@client, self, data)
  end
end