Class: Discorb::Interaction::SourceResponse::CallbackMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/discorb/interaction/response.rb

Instance Method Summary collapse

Instance Method Details

#delete! -> Async::Task<void>

Note:

This will fail if the message is ephemeral.

Deletes the callback message.

Returns:

  • (Async::Task<void>)

    The task.



119
120
121
122
123
# File 'lib/discorb/interaction/response.rb', line 119

def delete!
  Async do
    @client.http.delete("/webhooks/#{@application_id}/#{@token}/messages/@original").wait
  end
end

#edit(content = Discorb::Unset, embed: Discorb::Unset, embeds: Discorb::Unset, file: Discorb::Unset, files: Discorb::Unset, attachments: Discorb::Unset) -> Async::Task<void> Also known as: modify

Note:

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

Edits the callback message.

Parameters:

  • content (String) (defaults to: Discorb::Unset)

    The new content of the message.

  • embed (Discorb::Embed) (defaults to: Discorb::Unset)

    The new embed of the message.

  • embeds (Array<Discorb::Embed>) (defaults to: Discorb::Unset)

    The new embeds of the message.

  • attachments (Array<Discorb::Attachment>) (defaults to: Discorb::Unset)

    The attachments to remain.

  • file (Discorb::File) (defaults to: Discorb::Unset)

    The file to send.

  • files (Array<Discorb::File>) (defaults to: Discorb::Unset)

    The files to send.

Returns:

  • (Async::Task<void>)

    The task.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/discorb/interaction/response.rb', line 92

def edit(
  content = Discorb::Unset,
  embed: Discorb::Unset, embeds: Discorb::Unset,
  file: Discorb::Unset, files: Discorb::Unset,
  attachments: Discorb::Unset
)
  Async do
    payload = {}
    payload[:content] = content if content != Discorb::Unset
    payload[:embeds] = embed ? [embed.to_hash] : [] if embed != Discorb::Unset
    payload[:embeds] = embeds.map(&:to_hash) if embeds != Discorb::Unset
    payload[:attachments] = attachments.map(&:to_hash) if attachments != Discorb::Unset
    files = [file] if file != Discorb::Unset
    files = [] if files == Discorb::Unset
    @client.http.multipart_patch("/webhooks/#{@application_id}/#{@token}/messages/@original", payload, files, headers: headers).wait
  end
end