class Discordrb::Attachment

An attachment to a message

Attributes

filename[R]

@return [String] the attachment's filename.

height[R]

@return [Integer, nil] the height of an image file, in pixels, or `nil` if the file is not an image.

message[R]

@return [Message] the message this attachment belongs to.

proxy_url[R]

@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.
size[R]

@return [Integer] the attachment's file size in bytes.

url[R]

@return [String] the CDN URL this attachment can be downloaded at.

width[R]

@return [Integer, nil] the width of an image file, in pixels, or `nil` if the file is not an image.

Public Class Methods

new(data, message, bot) click to toggle source

@!visibility private

# File lib/discordrb/data.rb, line 2373
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']
end

Public Instance Methods

image?() click to toggle source

@return [true, false] whether this file is an image file.

# File lib/discordrb/data.rb, line 2389
def image?
  !(@width.nil? || @height.nil?)
end