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(hide: false) -> Object
Response with
DEFERRED_UPDATE_MESSAGE
(6
). -
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, hide: false) -> Object
Response with
UPDATE_MESSAGE
(7
).
Instance Method Details
#defer_update(hide: false) -> Object
Response with DEFERRED_UPDATE_MESSAGE
(6
).
175 176 177 178 179 180 181 182 183 184 |
# File 'lib/discorb/interaction.rb', line 175 def defer_update(hide: false) Async do @client.internet.post("/interactions/#{@id}/#{@token}/callback", { type: 7, data: { flags: (hide ? 1 << 6 : 0), }, }).wait end end |
#edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, hide: false) -> Object
Response with UPDATE_MESSAGE
(7
).
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/discorb/interaction.rb', line 197 def edit(content, tts: false, embed: nil, embeds: nil, allowed_mentions: nil, components: nil, hide: false) 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] = (hide ? 1 << 6 : 0) @client.internet.post("/interactions/#{@id}/#{@token}/callback", { type: 6, data: payload }).wait end |