Skip to content

Update and rename RadarBotList.ts to Radarcord.ts #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions src/Interface/Lists/RadarBotList.ts

This file was deleted.

136 changes: 136 additions & 0 deletions src/Interface/Lists/Radarcord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { Service, ServicePostOptions } from '../Service'
import { Util, IDResolvable } from '../../Utils/Util'

/**
* Represents the Radarcord service.
* @see https://docs.radarcord.net/
*/
export default class Radarcord extends Service {
/** The values that can be used to select the service. */
static get aliases() {
return ['radar', 'radarbots', 'radarbotdirectory.xyz', 'radarcord', 'radarcord.net']
}

/** The logo URL. */
static get logoURL() {
return 'https://radarcord.net/static/logo.png'
}

/** Service's name. */
static get serviceName() {
return 'Radarcord'
}

/** The website URL. */
static get websiteURL() {
return 'https://radarcord.net'
}

/** The base URL of the service's API. */
static get baseURL() {
return 'https://radarcord.net/api'
}

/**
* Posts statistics to this service.
* @param options The options of the request
*/
static post(options: ServicePostOptions) {
const { token, clientID, serverCount, shard } = options
return super._post({
method: 'patch',
url: `/bot/${Util.resolveID(clientID)}/stats/`,
headers: { Authorization: token },
data: shard
? {
guilds: Util.resolveCount(serverCount),
shards: shard.count
}
: { guilds: Util.resolveCount(serverCount) }
})
}

/**
* Gets the bot listed on this service.
* @param id The bot's ID
*/
getBot(id: IDResolvable) {
return this._request({ url: `/bot/${Util.resolveID(id)}` })
}

/**
* Gets the Unix Epoch Timestamp of the last time this user voted for this bot on this service.
* @param botID The bot's ID
* @param userID The user's ID
*/
getBotVotes(botID: IDResolvable, userID: IDResolvable) {
return this._request(
{
url: `/lastvoted/${Util.resolveID(userID)}/${Util.resolveID(botID)}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this endpoint still in the API? Where is it documented in the docs?
Also, it's using the same name as below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an API endpoint, just reminded me to add it to the documentation.
Should be called lastVoted() or something similar

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, lastVoted() will be fine 👍🏻

},
{
requiresToken: false
}
)
}

/**
* Gets the username, ID and listed bots of user
* @param userID The user's ID
*/
getUser(userID: IDResolvable) {
return this._request(
{
url: `/user/${Util.resolveID(userID)}`
},
{
requiresToken: false
}
)
}

/**
* Gets whether the user has voted for the bot
* @param botID The bot's ID
* @param userID The user's ID
*/
getBotVotes(botID: IDResolvable, userID: IDResolvable) {
return this._request(
{
url: `/hasvoted/${Util.resolveID(userID)}/${Util.resolveID(botID)}`
},
{
requiresToken: false
}
)
}
/**
* Returns a 1 or 0 depending on whether the user has voted for the bot
* @param botID The bot's ID
* @param userID The user's ID
*/
getBotVotes(botID: IDResolvable, userID: IDResolvable) {
return this._request(
{
url: `/hasvoted/${Util.resolveID(userID)}/${Util.resolveID(botID)}`
},
{
requiresToken: false
}
)
}
Comment on lines +107 to +121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Returns a 1 or 0 depending on whether the user has voted for the bot
* @param botID The bot's ID
* @param userID The user's ID
*/
getBotVotes(botID: IDResolvable, userID: IDResolvable) {
return this._request(
{
url: `/hasvoted/${Util.resolveID(userID)}/${Util.resolveID(botID)}`
},
{
requiresToken: false
}
)
}

This is a duplicate from above

/**
* Get listed reviews of bot
* @param botID The bot's ID
*/
getBotVotes(botID: IDResolvable, userID: IDResolvable) {
return this._request(
{
url: `/bot/${Util.resolveID(userID)}/reviews`
},
{
requiresToken: false
}
)
}
}