Module: Discorb::Interaction::UpdateResponder
- Included in:
- MessageComponentInteraction
- Defined in:
- lib/discorb/interaction/response.rb
Overview
A module for response with update.
Instance Method Summary collapse
-
#defer_update(ephemeral: false) ⇒ Async::Task<void>
Response with
DEFERRED_UPDATE_MESSAGE
(6
). -
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, attachment: nil, attachments: nil, components: nil, ephemeral: false) ⇒ Async::Task<void>
Response with
UPDATE_MESSAGE
(7
).
Instance Method Details
#defer_update(ephemeral: false) ⇒ Async::Task<void>
Response with DEFERRED_UPDATE_MESSAGE
(6
).
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/discorb/interaction/response.rb', line 252 def defer_update(ephemeral: false) Async do @client .http .request( Route.new( "/interactions/#{@id}/#{@token}/callback", "//interactions/:interaction_id/:token/callback", :post ), { type: 6, data: { flags: (ephemeral ? 1 << 6 : 0) } } ) .wait end end |
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, attachment: nil, attachments: nil, components: nil, ephemeral: false) ⇒ Async::Task<void>
Response with UPDATE_MESSAGE
(7
).
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 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/discorb/interaction/response.rb', line 285 def edit( content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, attachment: nil, attachments: 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] = ( if allowed_mentions allowed_mentions.to_hash(@client.allowed_mentions) else @client.allowed_mentions.to_hash end ) payload[:components] = Component.to_payload(components) if components payload[:flags] = (ephemeral ? 1 << 6 : 0) ||= [] if payload[:attachments] = .map.with_index do |a, i| { id: i, filename: a.filename, description: a.description } end @client .http .multipart_request( Route.new( "/interactions/#{@id}/#{@token}/callback", "//interactions/:interaction_id/:token/callback", :post ), { type: 7, data: payload }, ) .wait end end |