Class: ListCordRB::Bot

Inherits:
Object
  • Object
show all
Defined in:
lib/listcordrb/bot.rb

Overview

Find information about bots.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Bot

Initialize the bot

Parameters:

  • id (Integer, String)

    Integer/String ID of bot you’re requesting.



5
6
7
8
# File 'lib/listcordrb/bot.rb', line 5

def initialize(id)
  url = "https://listcord.com/api/bot/#{id}"
  @data = JSON.parse(RestClient.get(url))
end

Instance Attribute Details

#dataObject (readonly) Also known as: to_s

Returns data in raw json form.

Returns:

  • data in raw json form.



11
12
13
# File 'lib/listcordrb/bot.rb', line 11

def data
  @data
end

Instance Method Details

#avatarString

The avatar hash of the bot’s avatar.

Returns:

  • (String)

    the bot’s avatar.



55
56
57
# File 'lib/listcordrb/bot.rb', line 55

def avatar
  @data['avatar']
end

#avatar_imgString

Get’s the bot’s avatar as an img, ready to be used in image linking.

Returns:

  • (String)

    the bot’s avatar image url.



61
62
63
# File 'lib/listcordrb/bot.rb', line 61

def avatar_img
  "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024"
end

#certified?true, false

The certified status of the bot.

Returns:

  • (true, false)

    the bot’s certified status.



128
129
130
# File 'lib/listcordrb/bot.rb', line 128

def certified?
  @data['certified']
end

#descriptionString

The description of the bot.

Returns:

  • (String)

    the bot’s Description.



41
42
43
# File 'lib/listcordrb/bot.rb', line 41

def description
  @data['description']
end

#discriminatorInteger Also known as: discrim, tag

The discriminator of the bot.

Returns:

  • (Integer)

    the bot’s discriminator without the #.



67
68
69
# File 'lib/listcordrb/bot.rb', line 67

def discriminator
  @data['discriminator'].to_i
end

#distinctString

Returns the bot’s distinct, which is the Username and Discriminator.

Returns:

  • (String)

    the bot’s distinct.



82
83
84
# File 'lib/listcordrb/bot.rb', line 82

def distinct
  "#{username}\##{tag}"
end

#errorString?

Return the error message if there is one, nil otherwise.

Returns:

  • (String, nil)

    the error message.



17
18
19
# File 'lib/listcordrb/bot.rb', line 17

def error
  @data['message']
end

#error?true, false

Return true if there is an error, false otherwise.

Returns:

  • (true, false)

    if there is an error.



23
24
25
# File 'lib/listcordrb/bot.rb', line 23

def error?
  !@data['message'].nil?
end

#idInteger Also known as: clientid

Get the bot’s ID.

Returns:

  • (Integer)

    the bot’s id.



47
48
49
# File 'lib/listcordrb/bot.rb', line 47

def id
  @data['id'].to_i
end

#inviteString

The custom bot invite url of the bot.

Returns:

  • (String)

    the bot’s invite link.



29
30
31
# File 'lib/listcordrb/bot.rb', line 29

def invite
  @data['invite']
end

#invitesInteger

The amount of times the invite button has been clicked for the bot.

Returns:

  • (Integer)

    the amount of times the bot has been invited.



156
157
158
# File 'lib/listcordrb/bot.rb', line 156

def invites
  @data['invites']
end

#online?true, false Also known as: online

Is the bot online or not?.

Returns:

  • (true, false)

    the bot’s online status.



148
149
150
# File 'lib/listcordrb/bot.rb', line 148

def online?
  @data['online']
end

#ownersArray<String>

The owners of the bot. First one in the array is the main owner.

Returns:

  • (Array<String>)

    the bot’s owners in an array.



142
143
144
# File 'lib/listcordrb/bot.rb', line 142

def owners
  @data['owners']
end

#prefixInteger

Get the bot’s prefix

Returns:

  • (Integer)

    the bot’s prefix.



110
111
112
# File 'lib/listcordrb/bot.rb', line 110

def prefix
  @data['prefix']
end

#premium?true, false Also known as: premium

The premium status of the bot.

Returns:

  • (true, false)

    the bot’s premium status.



134
135
136
# File 'lib/listcordrb/bot.rb', line 134

def premium?
  @data['premium']
end

#serversInteger Also known as: guilds, guild, server

Get the bot’s server count

Returns:

  • (Integer)

    the bot’s server count.



100
101
102
# File 'lib/listcordrb/bot.rb', line 100

def servers
  @data['servers'].to_i
end

#supportString

The support server invite code of the bot.

Returns:

  • (String)

    the bot’s support server code.



88
89
90
# File 'lib/listcordrb/bot.rb', line 88

def support
  @data['support']
end

The bot’s support server link, ready for clicking.

Returns:

  • (String)

    the bot’s support server link.



94
95
96
# File 'lib/listcordrb/bot.rb', line 94

def support_link
  "https://discord.gg/#{support}"
end

#usernameString

The username of the bot.

Returns:

  • (String)

    the bot’s username.



76
77
78
# File 'lib/listcordrb/bot.rb', line 76

def username
  @data['username']
end

#verified?true, false

The verified status of the bot.

Returns:

  • (true, false)

    the bot’s verified status.



122
123
124
# File 'lib/listcordrb/bot.rb', line 122

def verified?
  @data['verified']
end

#votesInteger

The amount of upvotes the bot has.

Returns:

  • (Integer)

    the bot’s total votes.



116
117
118
# File 'lib/listcordrb/bot.rb', line 116

def votes
  @data['votes'].to_i
end

#websiteString

The website url of the bot.

Returns:

  • (String)

    the bot’s website link.



35
36
37
# File 'lib/listcordrb/bot.rb', line 35

def website
  @data['website']
end