Class: Discordrb::PrimaryServer

Inherits:
Object
  • Object
show all
Defined in:
lib/discordrb/data/primary_server.rb

Overview

A server tag that a user has chosen to display on their profile.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#badge_idString (readonly)

Returns the ID of the server tag's badge. can be used to generate a badge URL.

Returns:

  • (String)

    the ID of the server tag's badge. can be used to generate a badge URL.

See Also:



19
20
21
# File 'lib/discordrb/data/primary_server.rb', line 19

def badge_id
  @badge_id
end

#enabledBoolean (readonly) Also known as: enabled?

Returns if the user is displaying the primary server's tag.

Returns:

  • (Boolean)

    if the user is displaying the primary server's tag.



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

def enabled
  @enabled
end

#nameString (readonly) Also known as: text

Returns the text of the primary server's tag. Limited to four characters.

Returns:

  • (String)

    the text of the primary server's tag. Limited to four characters.



14
15
16
# File 'lib/discordrb/data/primary_server.rb', line 14

def name
  @name
end

#server_idInteger (readonly)

Returns the ID of the server this primary server is for.

Returns:

  • (Integer)

    the ID of the server this primary server is for.



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

def server_id
  @server_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

Comparison based off of server ID.



45
46
47
48
49
# File 'lib/discordrb/data/primary_server.rb', line 45

def ==(other)
  return false unless other.is_a?(PrimaryServer)

  Discordrb.id_compare(other.server_id, @server_id)
end

#badge_url(format = 'webp') ⇒ String

Utility method to get a server tag's badge 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)

    the URL to the server tag's badge image.



40
41
42
# File 'lib/discordrb/data/primary_server.rb', line 40

def badge_url(format = 'webp')
  API.server_tag_badge_url(@server_id, @badge_id, format)
end

#serverServer

Get the server associated with this primary server.

Returns:

  • (Server)

    the server associated with this primary server.

Raises:



33
34
35
# File 'lib/discordrb/data/primary_server.rb', line 33

def server
  @bot.server(@server_id)
end