class Discordrb::Attachment
An attachment to a message
Attributes
@return [String, nil] the attachment’s media type.
@return [String, nil] the attachment’s description.
@return [true, false] whether this attachment is ephemeral.
@return [true, false] whether this attachment is ephemeral.
@return [String] the attachment’s filename.
@return [Integer, nil] the height of an image file, in pixels, or ‘nil` if the file is not an image.
@return [Message] the message this attachment belongs to.
@return [String] the attachment’s proxy URL - I’m not sure what exactly this does, but I think it has something to
do with CDNs.
@return [Integer] the attachment’s file size in bytes.
@return [String] the CDN URL this attachment can be downloaded at.
@return [Integer, nil] the width of an image file, in pixels, or ‘nil` if the file is not an image.
Public Class Methods
@!visibility private
# File lib/discordrb/data/attachment.rb, line 41 def initialize(data, message, bot) @bot = bot @message = message @id = data['id'].to_i @url = data['url'] @proxy_url = data['proxy_url'] @filename = data['filename'] @size = data['size'] @width = data['width'] @height = data['height'] @description = data['description'] @content_type = data['content_type'] @ephemeral = data['ephemeral'] end
Public Instance Methods
@return [true, false] whether this file is an image file.
# File lib/discordrb/data/attachment.rb, line 62 def image? !(@width.nil? || @height.nil?) end
@return [true, false] whether this file is tagged as a spoiler.
# File lib/discordrb/data/attachment.rb, line 67 def spoiler? @filename.start_with? 'SPOILER_' end