Class: Discorb::Sticker::GuildSticker

Inherits:
Discorb::Sticker show all
Defined in:
lib/discorb/sticker.rb

Overview

Represents a sticker of guilds.

Instance Attribute Summary collapse

Attributes inherited from Discorb::Sticker

#available, #description, #format, #guild_id, #id, #name, #pack_id, #sort_value, #tags, #type, #user

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #hash

Instance Attribute Details

#guild -> Object (readonly)



55
56
57
# File 'lib/discorb/sticker.rb', line 55

def guild
  @client.guilds[@guild_id]
end

Instance Method Details

#delete!(reason: nil) -> Object Also known as: destroy!

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Deletes the sticker.

Parameters:

  • reason (String) (defaults to: nil)

    The reason for the deletion.

Raises:



89
90
91
92
93
# File 'lib/discorb/sticker.rb', line 89

def delete!(reason: nil)
  Async do
    @client.http.delete("/guilds/#{@guild_id}/stickers/#{@id}", audit_log_reason: reason).wait
  end
end

#edit(name: :unset, description: :unset, tag: :unset, reason: :unset) -> Object Also known as: modify

Note:

This is an asynchronous method, it will return a Async::Task object. Use Async::Task#wait to get the result.

Note:

This method calls HTTP request.

Note:

The arguments of this method are defaultly set to :unset. Specify value to set the value, if not don't specify or specify :unset.

Edits the sticker.

Parameters:

  • name (String) (defaults to: :unset)

    The new name of the sticker.

  • description (String) (defaults to: :unset)

    The new description of the sticker.

  • tag (Discorb::Emoji) (defaults to: :unset)

    The new tags of the sticker.

  • reason (String) (defaults to: :unset)

    The reason for the edit.

Raises:



70
71
72
73
74
75
76
77
78
# File 'lib/discorb/sticker.rb', line 70

def edit(name: :unset, description: :unset, tag: :unset, reason: :unset)
  Async do
    payload = {}
    payload[:name] = name unless name == :unset
    payload[:description] = description unless description == :unset
    payload[:tags] = tag.name unless tag == :unset
    @client.http.patch("/guilds/#{@guild_id}/stickers/#{@id}", payload, audit_log_reason: reason).wait
  end
end