Class: Discordrb::ServerPreview

Inherits:
Object
  • Object
show all
Includes:
IDObject, ServerAttributes
Defined in:
lib/discordrb/data/server_preview.rb

Overview

Publicly accessible information about a discoverable server.

Instance Attribute Summary collapse

Attributes included from ServerAttributes

#icon_id, #name

Attributes included from IDObject

#id

Instance Method Summary collapse

Methods included from ServerAttributes

#icon_url

Methods included from IDObject

#==, #creation_time, synthesise

Instance Attribute Details

#descriptionString? (readonly)

Returns the description of this server that's shown in the discovery tab.

Returns:

  • (String, nil)

    the description of this server that's shown in the discovery tab.



30
31
32
# File 'lib/discordrb/data/server_preview.rb', line 30

def description
  @description
end

#discovery_splash_idString? (readonly)

Returns the ID of the server's discovery splash screen.

Returns:

  • (String, nil)

    the ID of the server's discovery splash screen.

See Also:



15
16
17
# File 'lib/discordrb/data/server_preview.rb', line 15

def discovery_splash_id
  @discovery_splash_id
end

#emojisHash<Integer => Emoji> (readonly)

Returns a hash of all the emojis usable on this server.

Returns:

  • (Hash<Integer => Emoji>)

    a hash of all the emojis usable on this server.



18
19
20
# File 'lib/discordrb/data/server_preview.rb', line 18

def emojis
  @emojis
end

#featuresArray<Symbol> (readonly)

Returns the features of this server, e.g. :banner or :verified.

Returns:

  • (Array<Symbol>)

    the features of this server, e.g. :banner or :verified.



21
22
23
# File 'lib/discordrb/data/server_preview.rb', line 21

def features
  @features
end

#member_countInteger (readonly)

Returns the approximate number of members on this server, offline or not.

Returns:

  • (Integer)

    the approximate number of members on this server, offline or not.



24
25
26
# File 'lib/discordrb/data/server_preview.rb', line 24

def member_count
  @member_count
end

#presence_countInteger (readonly)

Returns the approximate number of members that aren't offline on this server.

Returns:

  • (Integer)

    the approximate number of members that aren't offline on this server.



27
28
29
# File 'lib/discordrb/data/server_preview.rb', line 27

def presence_count
  @presence_count
end

#splash_idString? (readonly)

Returns the ID of the server's invite splash screen.

Returns:

  • (String, nil)

    the ID of the server's invite splash screen.

See Also:



11
12
13
# File 'lib/discordrb/data/server_preview.rb', line 11

def splash_id
  @splash_id
end

Instance Method Details

#discovery_splash_url(format = 'webp') ⇒ String?

Utility method to get a server preview's discovery splash 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 discovery splash image, or nil if the server doesn't have a discovery splash image.



63
64
65
# File 'lib/discordrb/data/server_preview.rb', line 63

def discovery_splash_url(format = 'webp')
  API.discovery_splash_url(@id, @discovery_splash_id, format) if @discovery_splash_id
end

#serverServer

Get the server associated with this server preview.

Returns:

  • (Server)

    the server associated with this server preview.

Raises:



49
50
51
# File 'lib/discordrb/data/server_preview.rb', line 49

def server
  @bot.server(@id)
end

#splash_url(format = 'webp') ⇒ String?

Utility method to get a server preview's splash 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 splash image, or nil if the server doesn't have a splash image.



56
57
58
# File 'lib/discordrb/data/server_preview.rb', line 56

def splash_url(format = 'webp')
  API.splash_url(@id, @splash_id, format) if @splash_id
end