Module: Discorb::Interaction::UpdateResponse
- Included in:
- MessageComponentInteraction
- Defined in:
- lib/discorb/interaction.rb
Overview
A module for response with update.
Instance Method Summary collapse
-
#defer_update(ephemeral: false) -> Object
Response with
DEFERRED_UPDATE_MESSAGE
(6
). -
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, ephemeral: false) -> Object
Response with
UPDATE_MESSAGE
(7
).
Instance Method Details
#defer_update(ephemeral: false) -> Object
Response with DEFERRED_UPDATE_MESSAGE
(6
).
255 256 257 258 259 260 261 262 263 264 |
# File 'lib/discorb/interaction.rb', line 255 def defer_update(ephemeral: false) Async do @client.http.post("/interactions/#{@id}/#{@token}/callback", { type: 6, data: { flags: (ephemeral ? 1 << 6 : 0), }, }).wait end end |
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, ephemeral: false) -> Object
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.
Response with UPDATE_MESSAGE
(7
).
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/discorb/interaction.rb', line 280 def edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, ephemeral: false) Async do payload = {} payload[:content] = content if content payload[:tts] = tts = if [] elsif end payload[:embeds] = .map(&:to_hash) if payload[:allowed_mentions] = allowed_mentions ? allowed_mentions.to_hash(@client.allowed_mentions) : @client.allowed_mentions.to_hash if components tmp_components = [] tmp_row = [] components.each do |c| case c when Array tmp_components << tmp_row tmp_row = [] tmp_components << c when SelectMenu tmp_components << tmp_row tmp_row = [] tmp_components << [c] else tmp_row << c end end tmp_components << tmp_row payload[:components] = tmp_components.filter { |c| c.length.positive? }.map { |c| { type: 1, components: c.map(&:to_hash) } } end payload[:flags] = (ephemeral ? 1 << 6 : 0) @client.http.post("/interactions/#{@id}/#{@token}/callback", { type: 7, data: payload }).wait end end |