Class: Discorb::CustomEmoji
Overview
Represents a custom emoji in discord.
Instance Attribute Summary collapse
- 
  
    
      #available -> Boolean 
    
    
      (also: #available?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the emoji is available.
 - 
  
    
      #guild -> Boolean 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the emoji requires colons.
 - 
  
    
      #id -> Discorb::Snowflake 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The ID of the emoji.
 - 
  
    
      #managed -> Boolean 
    
    
      (also: #managed?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the emoji is managed by integration (ex: Twitch).
 - 
  
    
      #name -> String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The name of the emoji.
 - 
  
    
      #require_colons -> Boolean 
    
    
      (also: #require_colons?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether the emoji requires colons.
 - 
  
    
      #roles -> Array<Discorb::Role> 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The roles that can use this emoji.
 - 
  
    
      #roles? -> Boolean 
    
    
      (also: #role?)
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Whether or not this emoji is restricted to certain roles.
 - 
  
    
      #user -> Discorb::User 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The user that created this emoji.
 
Instance Method Summary collapse
- 
  
    
      #delete!(reason: nil) -> self 
    
    
      (also: #destroy!)
    
  
  
  
  
  
  
  
  
  
    
Delete the emoji.
 - 
  
    
      #edit(name: :unset, roles: :unset, reason: nil) -> self 
    
    
      (also: #modify)
    
  
  
  
  
  
  
  
  
  
    
Edit the emoji.
 - #inspect -> Object
 - 
  
    
      #to_s -> String 
    
    
  
  
  
  
  
  
  
  
  
    
Format the emoji for sending.
 - 
  
    
      #to_uri -> String 
    
    
  
  
  
  
  
  
  
  
  
    
Format the emoji for URI.
 
Instance Attribute Details
#available -> Boolean (readonly) Also known as: available?
Returns whether the emoji is available.
      30 31 32  | 
    
      # File 'lib/discorb/emoji.rb', line 30 def available @available end  | 
  
#guild -> Boolean (readonly)
Returns Whether the emoji requires colons.
      22 23 24  | 
    
      # File 'lib/discorb/emoji.rb', line 22 def guild @guild end  | 
  
#id -> Discorb::Snowflake (readonly)
Returns The ID of the emoji.
      14 15 16  | 
    
      # File 'lib/discorb/emoji.rb', line 14 def id @id end  | 
  
#managed -> Boolean (readonly) Also known as: managed?
Returns whether the emoji is managed by integration (ex: Twitch).
      24 25 26  | 
    
      # File 'lib/discorb/emoji.rb', line 24 def managed @managed end  | 
  
#name -> String (readonly)
Returns The name of the emoji.
      16 17 18  | 
    
      # File 'lib/discorb/emoji.rb', line 16 def name @name end  | 
  
#require_colons -> Boolean (readonly) Also known as: require_colons?
Returns whether the emoji requires colons.
      27 28 29  | 
    
      # File 'lib/discorb/emoji.rb', line 27 def require_colons @require_colons end  | 
  
#roles -> Array<Discorb::Role> (readonly)
Returns The roles that can use this emoji.
      18 19 20  | 
    
      # File 'lib/discorb/emoji.rb', line 18 def roles @roles end  | 
  
#roles? -> Boolean (readonly) Also known as: role?
Returns whether or not this emoji is restricted to certain roles.
| 
       | 
    
      # File 'lib/discorb/emoji.rb', line 33
     | 
  
#user -> Discorb::User (readonly)
Returns The user that created this emoji.
      20 21 22  | 
    
      # File 'lib/discorb/emoji.rb', line 20 def user @user end  | 
  
Instance Method Details
#delete!(reason: nil) -> self Also known as: destroy!
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
This method calls HTTP request.
Delete the emoji.
      105 106 107 108 109 110 111  | 
    
      # File 'lib/discorb/emoji.rb', line 105 def delete!(reason: nil) Async do @client.http.delete("/guilds/#{@guild.id}/emojis/#{@id}", audit_log_reason: reason).wait @available = false self end end  | 
  
#edit(name: :unset, roles: :unset, reason: nil) -> self Also known as: modify
This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.
This method calls HTTP request.
The arguments of this method are defaultly set to :unset. Specify value to set the value, if not don't specify or specify :unset.
Edit the emoji.
      84 85 86 87 88 89 90 91 92  | 
    
      # File 'lib/discorb/emoji.rb', line 84 def edit(name: :unset, roles: :unset, reason: nil) Async do payload = {} payload[:name] = name if name != :unset payload[:roles] = roles.map { |r| Discorb::Utils.try(r, :id) } if roles != :unset @client.http.patch("/guilds/#{@guild.id}/emojis/#{@id}", payload, audit_log_reason: reason) self end end  | 
  
#inspect -> Object
      68 69 70  | 
    
      # File 'lib/discorb/emoji.rb', line 68 def inspect "#<#{self.class} id=#{@id} :#{@name}:>" end  | 
  
#to_s -> String
Format the emoji for sending.
      49 50 51  | 
    
      # File 'lib/discorb/emoji.rb', line 49 def to_s "<#{@animated ? "a" : ""}:#{@name}:#{id}>" end  | 
  
#to_uri -> String
Format the emoji for URI.
      58 59 60  | 
    
      # File 'lib/discorb/emoji.rb', line 58 def to_uri "#{@name}:#{@id}" end  |