Class: RubyCord::Interaction::CallbackMessage

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

Overview

Represents of a callback message of interaction.

Instance Method Summary collapse

Instance Method Details

#deleteAsync::Task<void>

Note:

This will fail if the message is ephemeral.

Deletes the callback message.

Returns:

  • (Async::Task<void>)

    The task.



214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/rubycord/interaction/response.rb', line 214

def delete
  Async do
    @client
      .http
      .request(
        RubyCord::Internal::Route.new(
          "/webhooks/#{@application_id}/#{@token}/messages/@original",
          "//webhooks/:webhook_id/:token/messages/@original",
          :delete
        )
      )
      .wait
  end
end

#edit(content = RubyCord::Unset, embed: RubyCord::Unset, embeds: RubyCord::Unset, file: RubyCord::Unset, files: RubyCord::Unset, attachments: 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 callback message.

Parameters:

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

    The new content of the message.

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

    The new embed of the message.

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

    The new embeds of the message.

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

    The attachments to remain.

  • file (RubyCord::Attachment) (defaults to: RubyCord::Unset)

    The file to send.

  • files (Array<RubyCord::Attachment>) (defaults to: RubyCord::Unset)

    The files to send.

Returns:

  • (Async::Task<void>)

    The task.



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rubycord/interaction/response.rb', line 172

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

#inspectObject



229
230
231
# File 'lib/rubycord/interaction/response.rb', line 229

def inspect
  "#<#{self.class.name} application_id=#{@application_id}"
end