Class: RubyCord::Sticker::GuildSticker

Inherits:
RubyCord::Sticker show all
Defined in:
lib/rubycord/sticker.rb

Overview

Represents a sticker of guilds.

Instance Attribute Summary collapse

Attributes inherited from RubyCord::Sticker

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

Instance Method Summary collapse

Methods inherited from DiscordModel

#==, #eql?, #inspect

Instance Attribute Details

#guildObject (readonly)



60
61
62
# File 'lib/rubycord/sticker.rb', line 60

def guild
  @client.guilds[@guild_id]
end

Instance Method Details

#delete(reason: nil) ⇒ Object Also known as: destroy

Deletes the sticker.

Parameters:

  • reason (String) (defaults to: nil)

    The reason for the deletion.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/rubycord/sticker.rb', line 111

def delete(reason: nil)
  Async do
    @client
      .http
      .request(
        RubyCord::Internal::Route.new(
          "/guilds/#{@guild_id}/stickers/#{@id}",
          "//guilds/:guild_id/stickers/:sticker_id",
          :delete
        ),
        {},
        audit_log_reason: reason
      )
      .wait
  end
end

#edit(name: RubyCord::Unset, description: RubyCord::Unset, tag: RubyCord::Unset, reason: RubyCord::Unset) ⇒ Async::Task<void> Also known as: modify

Note:

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

Edits the sticker.

Parameters:

  • name (String) (defaults to: RubyCord::Unset)

    The new name of the sticker.

  • description (String) (defaults to: RubyCord::Unset)

    The new description of the sticker.

  • tag (RubyCord::Emoji) (defaults to: RubyCord::Unset)

    The new tags of the sticker.

  • reason (String) (defaults to: RubyCord::Unset)

    The reason for the edit.

Returns:

  • (Async::Task<void>)

    The task.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/rubycord/sticker.rb', line 76

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