Class: DBLRuby::Bot
- Inherits:
-
Object
- Object
- DBLRuby::Bot
- Defined in:
- lib/dblruby/bot.rb
Overview
Find information about bots.
Instance Attribute Summary collapse
-
#data ⇒ Object
(also: #to_s)
readonly
Data in raw json form.
Instance Method Summary collapse
-
#avatar ⇒ String
The avatar hash of the bot’s avatar.
-
#avatar_img ⇒ String
Get’s the bot’s avatar as an img, ready to be used in image linking.
-
#certified? ⇒ true, false
(also: #certifiedbot, #certified, #certifiedbot?)
The certified status of the bot.
-
#clientid ⇒ Integer
Get the bot’s Client ID.
-
#date ⇒ Date
The date when the bot was approved.
-
#defavatar ⇒ String
The cdn hash of the bot’s avatar if the bot has none.
-
#discriminator ⇒ String
(also: #discrim, #tag)
The discriminator of the bot.
-
#distinct ⇒ String
Returns the bot’s distinct, which is the Username and Discriminator.
-
#donatebotguildid ⇒ String
(also: #donatebotserverid)
Get the bot’s donate bot guild ID.
-
#error ⇒ String?
Return the error if there is one, nil otherwise.
-
#error? ⇒ true, false
Return true if there is an error, false otherwise.
-
#github ⇒ String
The link to the github repo of the bot.
-
#guilds ⇒ Array<String>
(also: #servers)
Get the bot’s “This Bot Powers the following Servers”.
-
#id ⇒ Integer
The id of the bot.
-
#initialize(id: nil, data: nil) ⇒ Bot
constructor
Initialize the bot.
-
#invite ⇒ String
The custom bot invite url of the bot.
-
#lib ⇒ String
The library of the bot.
-
#longdesc ⇒ String
The long description of the bot.
-
#monthlypoints ⇒ Integer
(also: #monthlyvotes)
The amount of upvotes the bot has this month.
-
#owners ⇒ Array<String>
The owners of the bot.
-
#points ⇒ Integer
(also: #votes)
The amount of upvotes the bot has.
-
#prefix ⇒ String
The prefix of the bot.
-
#server_count ⇒ Integer
(also: #guild_count, #server)
Get the bot’s server count.
-
#shards ⇒ Array<String>
Get the bot’s shards.
-
#shortdesc ⇒ String
The short description of the bot.
-
#support ⇒ String
The support server invite code of the bot.
-
#support_link ⇒ String
The bot’s support server link, ready for clicking.
-
#tags ⇒ Array<String>
The tags of the bot.
-
#time ⇒ Time
The time when the bot was approved.
-
#username ⇒ String
The username of the bot.
-
#website ⇒ String
The website url of the bot.
Constructor Details
#initialize(id: nil, data: nil) ⇒ Bot
Initialize the bot
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dblruby/bot.rb', line 6 def initialize(id: nil, data: nil) if id.nil? @data = data else url = "https://discordbots.org/api/bots/#{id}" @data = JSON.parse(RestClient.get(url)) end rescue RestClient::NotFound raise DBLRuby::Errors::InvalidBot, 'The API returned a 404 error! Is that bot listed?' end |
Instance Attribute Details
#data ⇒ Object (readonly) Also known as: to_s
Returns data in raw json form.
19 20 21 |
# File 'lib/dblruby/bot.rb', line 19 def data @data end |
Instance Method Details
#avatar ⇒ String
The avatar hash of the bot’s avatar.
91 92 93 |
# File 'lib/dblruby/bot.rb', line 91 def avatar @data['avatar'] end |
#avatar_img ⇒ String
Get’s the bot’s avatar as an img, ready to be used in image linking.
97 98 99 |
# File 'lib/dblruby/bot.rb', line 97 def avatar_img "https://cdn.discordapp.com/avatars/#{id}/#{avatar}.webp?size=1024" end |
#certified? ⇒ true, false Also known as: certifiedbot, certified, certifiedbot?
The certified status of the bot.
194 195 196 |
# File 'lib/dblruby/bot.rb', line 194 def certified? @data['certifiedBot'] end |
#clientid ⇒ Integer
Get the bot’s Client ID.
79 80 81 |
# File 'lib/dblruby/bot.rb', line 79 def clientid @data['clientid'].to_i end |
#date ⇒ Date
The date when the bot was approved.
130 131 132 |
# File 'lib/dblruby/bot.rb', line 130 def date Date.parse(@data['date']) end |
#defavatar ⇒ String
The cdn hash of the bot’s avatar if the bot has none.
85 86 87 |
# File 'lib/dblruby/bot.rb', line 85 def defavatar @data['defAvatar'] end |
#discriminator ⇒ String Also known as: discrim, tag
The discriminator of the bot.
109 110 111 |
# File 'lib/dblruby/bot.rb', line 109 def discriminator @data['discriminator'] end |
#distinct ⇒ String
Returns the bot’s distinct, which is the Username and Discriminator.
124 125 126 |
# File 'lib/dblruby/bot.rb', line 124 def distinct "#{username}\##{tag}" end |
#donatebotguildid ⇒ String Also known as: donatebotserverid
Get the bot’s donate bot guild ID.
216 217 218 |
# File 'lib/dblruby/bot.rb', line 216 def donatebotguildid @data['donatebotguildid'] end |
#error ⇒ String?
Return the error if there is one, nil otherwise.
25 26 27 |
# File 'lib/dblruby/bot.rb', line 25 def error @data['error'] end |
#error? ⇒ true, false
Return true if there is an error, false otherwise.
31 32 33 |
# File 'lib/dblruby/bot.rb', line 31 def error? !@data['error'].nil? end |
#github ⇒ String
The link to the github repo of the bot.
43 44 45 |
# File 'lib/dblruby/bot.rb', line 43 def github @data['github'] end |
#guilds ⇒ Array<String> Also known as: servers
Get the bot’s “This Bot Powers the following Servers”
164 165 166 |
# File 'lib/dblruby/bot.rb', line 164 def guilds @data['guilds'] end |
#id ⇒ Integer
The id of the bot.
103 104 105 |
# File 'lib/dblruby/bot.rb', line 103 def id @data['id'].to_i end |
#invite ⇒ String
The custom bot invite url of the bot.
37 38 39 |
# File 'lib/dblruby/bot.rb', line 37 def invite @data['invite'] end |
#lib ⇒ String
The library of the bot.
73 74 75 |
# File 'lib/dblruby/bot.rb', line 73 def lib @data['lib'] end |
#longdesc ⇒ String
The long description of the bot. Can contain HTML and/or Markdown.
55 56 57 |
# File 'lib/dblruby/bot.rb', line 55 def longdesc @data['longdesc'] end |
#monthlypoints ⇒ Integer Also known as: monthlyvotes
The amount of upvotes the bot has this month.
178 179 180 |
# File 'lib/dblruby/bot.rb', line 178 def monthlypoints @data['monthlyPoints'].to_i end |
#owners ⇒ Array<String>
The owners of the bot. First one in the array is the main owner.
204 205 206 |
# File 'lib/dblruby/bot.rb', line 204 def owners @data['owners'] end |
#points ⇒ Integer Also known as: votes
The amount of upvotes the bot has.
186 187 188 |
# File 'lib/dblruby/bot.rb', line 186 def points @data['points'].to_i end |
#prefix ⇒ String
The prefix of the bot.
67 68 69 |
# File 'lib/dblruby/bot.rb', line 67 def prefix @data['prefix'] end |
#server_count ⇒ Integer Also known as: guild_count, server
Get the bot’s server count
155 156 157 |
# File 'lib/dblruby/bot.rb', line 155 def server_count @data['server_count'].to_i end |
#shards ⇒ Array<String>
Get the bot’s shards.
172 173 174 |
# File 'lib/dblruby/bot.rb', line 172 def shards @data['shards'] end |
#shortdesc ⇒ String
The short description of the bot.
61 62 63 |
# File 'lib/dblruby/bot.rb', line 61 def shortdesc @data['shortdesc'] end |
#support ⇒ String
The support server invite code of the bot.
143 144 145 |
# File 'lib/dblruby/bot.rb', line 143 def support @data['support'] end |
#support_link ⇒ String
The bot’s support server link, ready for clicking.
149 150 151 |
# File 'lib/dblruby/bot.rb', line 149 def support_link "https://discord.gg/#{support}" end |
#tags ⇒ Array<String>
The tags of the bot.
210 211 212 |
# File 'lib/dblruby/bot.rb', line 210 def @data['tags'] end |
#time ⇒ Time
The time when the bot was approved. This is compatiable with embed.timestamp, unlike #date
137 138 139 |
# File 'lib/dblruby/bot.rb', line 137 def time Time.parse(@data['date']) end |
#username ⇒ String
The username of the bot.
118 119 120 |
# File 'lib/dblruby/bot.rb', line 118 def username @data['username'] end |
#website ⇒ String
The website url of the bot.
49 50 51 |
# File 'lib/dblruby/bot.rb', line 49 def website @data['website'] end |