Module: Discordrb::ServerAttributes

Included in:
Light::UltraLightServer, Server, ServerPreview
Defined in:
lib/discordrb/data/server.rb

Overview

Basic attributes a server should have

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#icon_idString (readonly)

Returns the hexadecimal ID used to identify this server's icon.

Returns:

  • (String)

    the hexadecimal ID used to identify this server's icon.



10
11
12
# File 'lib/discordrb/data/server.rb', line 10

def icon_id
  @icon_id
end

#nameString (readonly)

Returns this server's name.

Returns:

  • (String)

    this server's name.



7
8
9
# File 'lib/discordrb/data/server.rb', line 7

def name
  @name
end

Instance Method Details

#icon_url(format: 'webp') ⇒ String?

Utility method to get a server's icon URL.

Parameters:

  • format (String) (defaults to: 'webp')

    The URL will default to webp. You can otherwise specify one of jpg or png to override this.

Returns:

  • (String, nil)

    The URL to the server's icon, or nil if the server hasn't set an icon.



16
17
18
# File 'lib/discordrb/data/server.rb', line 16

def icon_url(format: 'webp')
  API.icon_url(@id, @icon_id, format) if @icon_id
end