Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond with image for slash command #227

Open
OnlyReFLeX opened this issue Jun 19, 2023 · 2 comments
Open

Respond with image for slash command #227

OnlyReFLeX opened this issue Jun 19, 2023 · 2 comments

Comments

@OnlyReFLeX
Copy link

OnlyReFLeX commented Jun 19, 2023

Trying to reply with image for slash command

# example
bot.application_command(:profile) do |event|
  event.respond(content: 'test') do |builder|
    builder.file = File.open('./test.png') # doesn't work (no error)
    builder.attachments = [File.open('./test.png')] # error (undefined method)
  end

  event.send_file # doesn't exist
end 

But there is no functional for that, Is there any way to do this?

@anna328p
Copy link

Interaction response API endpoint allows attachments.

@joshbuker
Copy link
Contributor

This is a workaround that may suit your needs.

base64_image_content = '...'
image = StringIO.new(Base64.decode64(base64_image_content))
# OR
image = File.open('./test.png', 'r')
@event.channel.send_file(
  image,
  caption: caption,
  filename: filename
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants