From 9985895a6d68437df64f28741624ec8cbea272a2 Mon Sep 17 00:00:00 2001 From: Federico Grandi Date: Sat, 27 Mar 2021 08:46:23 +0100 Subject: [PATCH 1/3] feat: add base for FatesList --- src/Interface/Lists/FatesList.ts | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/Interface/Lists/FatesList.ts diff --git a/src/Interface/Lists/FatesList.ts b/src/Interface/Lists/FatesList.ts new file mode 100644 index 00000000..1729dea1 --- /dev/null +++ b/src/Interface/Lists/FatesList.ts @@ -0,0 +1,56 @@ +import { Service, ServicePostOptions } from '../Service' +import { Util, IDResolvable } from '../../Utils/Util' + +/** + * Represents the FatesList service. + * @see https://fateslist.xyz/api/docs/endpoints + */ +export default class FatesList extends Service { + /** The values that can be used to select the service. */ + static get aliases() { + return ['fateslist', 'fateslist.xyz'] + } + + /** The logo URL. */ + static get logoURL() { + return 'https://cdn.discordapp.com/avatars/798951566634778641/dfb619dd43f9039dbd4d7854845aa0ca.png' + } + + /** Service's name. */ + static get serviceName() { + return 'Fates List' + } + + /** The website URL. */ + static get websiteURL() { + return 'https://fateslist.xyz/' + } + + /** The base URL of the service's API. */ + static get baseURL() { + return 'https://fateslist.xyz/api' + } + + /** + * Posts statistics to this service. + * Shard data posting is not supported for this service. + * @param options The options of the request + */ + static post(options: ServicePostOptions) { + const { token, clientID, serverCount, userCount, shard } = options + return super._post({ + method: 'post', + url: `/bots/${Util.resolveID(clientID)}/stats`, + headers: { Authorization: token }, + data: { + guild_count: Util.resolveCount(serverCount), + user_count: Util.resolveCount(userCount), + ...(shard + ? { + shards: shard.count + } + : {}) + } + }) + } +} From 3e5d2a957190338897788b4be61d5b9c083e6654 Mon Sep 17 00:00:00 2001 From: Federico Grandi Date: Sat, 27 Mar 2021 07:48:17 +0000 Subject: [PATCH 2/3] [auto] docs: update docs --- docs/general/services.md | 77 +++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/docs/general/services.md b/docs/general/services.md index 430059f0..81af84e8 100644 --- a/docs/general/services.md +++ b/docs/general/services.md @@ -1,4 +1,4 @@ -# Supported Services (31) +# Supported Services (32)

@@ -9,7 +9,7 @@

Arcane Bot List

Keys: `arcane`, `arcane-center.xyz` -Class: [dbots.Arcane](/#/docs/main/master/class/Arcane) +Class: [dbots.Arcane](/#/docs/main/N-fateslist/class/Arcane) Website: https://arcane-center.xyz
@@ -22,7 +22,7 @@ Website: https://arcane-center.xyz

Astro Bot List

Keys: `astrobotlist`, `botlists.com` -Class: [dbots.AstroBotList](/#/docs/main/master/class/AstroBotList) +Class: [dbots.AstroBotList](/#/docs/main/N-fateslist/class/AstroBotList) Website: https://botlists.com @@ -35,7 +35,7 @@ Website: https://botlists.com

BladeBotList

Keys: `bladebotlist`, `bladebotlist.xyz` -Class: [dbots.BladeBotList](/#/docs/main/master/class/BladeBotList) +Class: [dbots.BladeBotList](/#/docs/main/N-fateslist/class/BladeBotList) Website: https://bladebotlist.xyz @@ -48,7 +48,7 @@ Website: https://bladebotlist.xyz

Blist

Keys: `blist`, `blist.xyz` -Class: [dbots.Blist](/#/docs/main/master/class/Blist) +Class: [dbots.Blist](/#/docs/main/N-fateslist/class/Blist) Website: https://blist.xyz @@ -61,7 +61,7 @@ Website: https://blist.xyz

botlist.space

Keys: `botlistspace`, `botlist.space` -Class: [dbots.BotListSpace](/#/docs/main/master/class/BotListSpace) +Class: [dbots.BotListSpace](/#/docs/main/N-fateslist/class/BotListSpace) Website: https://botlist.space @@ -74,7 +74,7 @@ Website: https://botlist.space

BotsDataBase

Keys: `botsdatabase`, `botsdatabase.com` -Class: [dbots.BotsDataBase](/#/docs/main/master/class/BotsDataBase) +Class: [dbots.BotsDataBase](/#/docs/main/N-fateslist/class/BotsDataBase) Website: https://botsdatabase.com @@ -87,7 +87,7 @@ Website: https://botsdatabase.com

Bots For Discord

Keys: `botsfordiscord`, `botsfordiscord.com` -Class: [dbots.BotsForDiscord](/#/docs/main/master/class/BotsForDiscord) +Class: [dbots.BotsForDiscord](/#/docs/main/N-fateslist/class/BotsForDiscord) Website: https://botsfordiscord.com @@ -100,7 +100,7 @@ Website: https://botsfordiscord.com

Bots On Discord

Keys: `botsondiscord`, `bots.ondiscord.xyz` -Class: [dbots.BotsOnDiscord](/#/docs/main/master/class/BotsOnDiscord) +Class: [dbots.BotsOnDiscord](/#/docs/main/N-fateslist/class/BotsOnDiscord) Website: https://bots.ondiscord.xyz @@ -114,7 +114,7 @@ Website: https://bots.ondiscord.xyz

Carbonitex

Keys: `carbonitex`, `carbonitex.net`, `carbon` -Class: [dbots.Carbon](/#/docs/main/master/class/Carbon) +Class: [dbots.Carbon](/#/docs/main/N-fateslist/class/Carbon) Website: https://www.carbonitex.net/Discord/bots @@ -127,7 +127,7 @@ Website: https://www.carbonitex.net/Discord/bots

DBots.co

Keys: `dbots`, `dbots.co` -Class: [dbots.DBots](/#/docs/main/master/class/DBots) +Class: [dbots.DBots](/#/docs/main/N-fateslist/class/DBots) Website: https://dbots.co/ @@ -140,7 +140,7 @@ Website: https://dbots.co/

Discord Apps

Keys: `discordappsdev`, `discordapps.dev` -Class: [dbots.DiscordAppsDev](/#/docs/main/master/class/DiscordAppsDev) +Class: [dbots.DiscordAppsDev](/#/docs/main/N-fateslist/class/DiscordAppsDev) Website: https://discordapps.dev @@ -153,7 +153,7 @@ Website: https://discordapps.dev

Discord Boats

Keys: `discordboats`, `discord.boats` -Class: [dbots.DiscordBoats](/#/docs/main/master/class/DiscordBoats) +Class: [dbots.DiscordBoats](/#/docs/main/N-fateslist/class/DiscordBoats) Website: https://discord.boats @@ -166,7 +166,7 @@ Website: https://discord.boats

Discord Bot Directory

Keys: `discordbotdirectory`, `discordbotdirectory.net` -Class: [dbots.DiscordBotDirectory](/#/docs/main/master/class/DiscordBotDirectory) +Class: [dbots.DiscordBotDirectory](/#/docs/main/N-fateslist/class/DiscordBotDirectory) Website: https://discordbotdirectory.net @@ -179,7 +179,7 @@ Website: https://discordbotdirectory.net

Discord Bot List

Keys: `discordbotlist`, `discordbotlist.com` -Class: [dbots.DiscordBotList](/#/docs/main/master/class/DiscordBotList) +Class: [dbots.DiscordBotList](/#/docs/main/N-fateslist/class/DiscordBotList) Website: https://discordbotlist.com @@ -192,7 +192,7 @@ Website: https://discordbotlist.com

DiscordBots.co

Keys: `discordbotsco`, `discordbots.co` -Class: [dbots.DiscordBotsCo](/#/docs/main/master/class/DiscordBotsCo) +Class: [dbots.DiscordBotsCo](/#/docs/main/N-fateslist/class/DiscordBotsCo) Website: https://discordbots.co @@ -205,7 +205,7 @@ Website: https://discordbots.co

Discord Bots

Keys: `discordbotsgg`, `discord.bots.gg` -Class: [dbots.DiscordBotsGG](/#/docs/main/master/class/DiscordBotsGG) +Class: [dbots.DiscordBotsGG](/#/docs/main/N-fateslist/class/DiscordBotsGG) Website: https://discord.bots.gg @@ -218,7 +218,7 @@ Website: https://discord.bots.gg

Discord Extreme List

Keys: `discordextremelist`, `discordextremelist.xyz` -Class: [dbots.DiscordExtremeList](/#/docs/main/master/class/DiscordExtremeList) +Class: [dbots.DiscordExtremeList](/#/docs/main/N-fateslist/class/DiscordExtremeList) Website: https://discordextremelist.xyz/ @@ -231,7 +231,7 @@ Website: https://discordextremelist.xyz/

Discord Labs

Keys: `discordlabs`, `discordlabs.org` -Class: [dbots.DiscordLabs](/#/docs/main/master/class/DiscordLabs) +Class: [dbots.DiscordLabs](/#/docs/main/N-fateslist/class/DiscordLabs) Website: https://bots.discordlabs.org/ @@ -244,7 +244,7 @@ Website: https://bots.discordlabs.org/

DiscordListology

Keys: `discordlistology`, `discordlistology.com` -Class: [dbots.DiscordListology](/#/docs/main/master/class/DiscordListology) +Class: [dbots.DiscordListology](/#/docs/main/N-fateslist/class/DiscordListology) Website: https://discordlistology.com/ @@ -257,7 +257,7 @@ Website: https://discordlistology.com/

Discord Services

Keys: `discordservices`, `discordservices.net` -Class: [dbots.DiscordServices](/#/docs/main/master/class/DiscordServices) +Class: [dbots.DiscordServices](/#/docs/main/N-fateslist/class/DiscordServices) Website: https://discordservices.net @@ -270,10 +270,23 @@ Website: https://discordservices.net

Disforge

Keys: `disforge`, `disforge.com` -Class: [dbots.Disforge](/#/docs/main/master/class/Disforge) +Class: [dbots.Disforge](/#/docs/main/N-fateslist/class/Disforge) Website: https://disforge.com/bots +
+

+ fateslist logo +

+ + +

Fates List

+ +Keys: `fateslist`, `fateslist.xyz` +Class: [dbots.FatesList](/#/docs/main/N-fateslist/class/FatesList) +Website: https://fateslist.xyz/ +
+

glennbotlist logo @@ -283,7 +296,7 @@ Website: https://disforge.com/bots

Glenn Bot List

Keys: `glennbotlist`, `glennbotlist.xyz` -Class: [dbots.GlennBotList](/#/docs/main/master/class/GlennBotList) +Class: [dbots.GlennBotList](/#/docs/main/N-fateslist/class/GlennBotList) Website: https://glennbotlist.xyz
@@ -296,7 +309,7 @@ Website: https://glennbotlist.xyz

Infinity Bot List

Keys: `infinitybots`, `infinitybots.xyz` -Class: [dbots.InfinityBots](/#/docs/main/master/class/InfinityBots) +Class: [dbots.InfinityBots](/#/docs/main/N-fateslist/class/InfinityBots) Website: https://infinitybots.xyz @@ -309,7 +322,7 @@ Website: https://infinitybots.xyz

List My Bots

Keys: `listmybots`, `listmybots.com` -Class: [dbots.ListMyBots](/#/docs/main/master/class/ListMyBots) +Class: [dbots.ListMyBots](/#/docs/main/N-fateslist/class/ListMyBots) Website: https://listmybots.com/ @@ -322,7 +335,7 @@ Website: https://listmybots.com/

Paradise Bots

Keys: `paradisebots`, `paradisebots.net` -Class: [dbots.ParadiseBots](/#/docs/main/master/class/ParadiseBots) +Class: [dbots.ParadiseBots](/#/docs/main/N-fateslist/class/ParadiseBots) Website: https://paradisebots.net/ @@ -335,7 +348,7 @@ Website: https://paradisebots.net/

Space Bots List

Keys: `spacebotslist`, `space-bot-list.xyz` -Class: [dbots.SpaceBotsList](/#/docs/main/master/class/SpaceBotsList) +Class: [dbots.SpaceBotsList](/#/docs/main/N-fateslist/class/SpaceBotsList) Website: https://space-bot-list.xyz/ @@ -348,7 +361,7 @@ Website: https://space-bot-list.xyz/

TopCord

Keys: `topcord`, `topcord.xyz` -Class: [dbots.TopCord](/#/docs/main/master/class/TopCord) +Class: [dbots.TopCord](/#/docs/main/N-fateslist/class/TopCord) Website: https://topcord.xyz/ @@ -361,7 +374,7 @@ Website: https://topcord.xyz/

Top.gg

Keys: `topgg`, `top.gg` -Class: [dbots.TopGG](/#/docs/main/master/class/TopGG) +Class: [dbots.TopGG](/#/docs/main/N-fateslist/class/TopGG) Website: https://top.gg @@ -374,7 +387,7 @@ Website: https://top.gg

Void Bots

Keys: `voidbots`, `voidbots.net` -Class: [dbots.VoidBots](/#/docs/main/master/class/VoidBots) +Class: [dbots.VoidBots](/#/docs/main/N-fateslist/class/VoidBots) Website: https://voidbots.net/ @@ -387,7 +400,7 @@ Website: https://voidbots.net/

Wonder Bot List

Keys: `wonderbotlist`, `wonderbotlist.com` -Class: [dbots.WonderBotList](/#/docs/main/master/class/WonderBotList) +Class: [dbots.WonderBotList](/#/docs/main/N-fateslist/class/WonderBotList) Website: https://wonderbotlist.com/en @@ -400,6 +413,6 @@ Website: https://wonderbotlist.com/en

Yet Another Bot List

Keys: `yabl`, `yabl.xyz` -Class: [dbots.YABL](/#/docs/main/master/class/YABL) +Class: [dbots.YABL](/#/docs/main/N-fateslist/class/YABL) Website: https://yabl.xyz/ \ No newline at end of file From 282edef11e9bddb2cf38d29389fc6008fd34324e Mon Sep 17 00:00:00 2001 From: Federico Grandi Date: Mon, 29 Mar 2021 09:07:28 +0200 Subject: [PATCH 3/3] feat(FatesList): add API methods --- src/Interface/Lists/FatesList.ts | 292 +++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/src/Interface/Lists/FatesList.ts b/src/Interface/Lists/FatesList.ts index 1729dea1..0e8f483f 100644 --- a/src/Interface/Lists/FatesList.ts +++ b/src/Interface/Lists/FatesList.ts @@ -1,5 +1,6 @@ import { Service, ServicePostOptions } from '../Service' import { Util, IDResolvable } from '../../Utils/Util' +import { Query } from '../../Utils/Constants' /** * Represents the FatesList service. @@ -53,4 +54,295 @@ export default class FatesList extends Service { } }) } + + /** + * Gets a bot promotion + * @param id The bot's ID + */ + getPromotion(id: IDResolvable) { + return this._request({ url: `/bots/${Util.resolveID(id)}/promotions` }) + } + + /** + * Adds a bot promotion + * @param botID The bot's ID + * @param promotionData The promotion payload + */ + addPromotion(botID: IDResolvable, promotionData: any) { + return this._request( + { + method: 'post', + url: `/bots/${Util.resolveID(botID)}/promotions`, + headers: { + Authorization: this.token + }, + data: promotionData + }, + { requiresToken: true } + ) + } + + /** + * Deletes a bot promotion, or every promotion if no id is provided + * @param botID The bot's ID + * @param promotionID The promotion ID + */ + deletePromotion(botID: IDResolvable, promotionID?: string) { + return this._request( + { + method: 'delete', + url: `/bots/${Util.resolveID(botID)}/promotions`, + headers: { + Authorization: this.token + }, + data: { promo_id: promotionID } + }, + { requiresToken: true } + ) + } + + /** + * Edits a bot promotion + * @param botID The bot's ID + * @param promotionData The promotion payload + */ + editPromotion(botID: IDResolvable, promotionData: any) { + return this._request( + { + method: 'patch', + url: `/bots/${Util.resolveID(botID)}/promotions`, + headers: { + Authorization: this.token + }, + data: promotionData + }, + { requiresToken: true } + ) + } + + /** + * Regenrates the API token + * @param botID The bot's ID + */ + regenerateToken(botID: IDResolvable) { + return this._request( + { + method: 'patch', + url: `/bots/${Util.resolveID(botID)}/token`, + headers: { + Authorization: this.token + } + }, + { requiresToken: true } + ) + } + + /** Gets a random bot */ + getRandomBot() { + return this._request({ url: '/bots/random' }) + } + + /** + * Gets a bot from the API + * @param id The bot's ID + * @param query Query to use + */ + getBot(id: IDResolvable, query?: Query) { + return this._request({ + url: `/bots/${Util.resolveID(id)}`, + headers: { Authorization: this.token }, // Token is not required but gives access to more info + params: query + }) + } + + /** + * Get a bot's commands + * @param id The bot's ID + */ + getBotCommands(id: IDResolvable) { + return this._request({ url: `/bots/${Util.resolveID(id)}/commands` }) + } + + /** + * Adds a command to a bot + * @param botID The bot's ID + * @param commandData The command payload + * @param query The query to use + */ + addBotCommand(botID: IDResolvable, commandData: any, query?: Query) { + return this._request( + { + method: 'post', + url: `/bots/${Util.resolveID(botID)}/commands`, + headers: { Authorization: this.token }, + params: query, + data: commandData + }, + { requiresToken: true } + ) + } + + /** + * Deletes a bot's command + * @param botID The bot's ID + * @param commandID The command ID + */ + deleteBotCommand(botID: IDResolvable, commandID: string) { + return this._request( + { + method: 'delete', + url: `/bots/${Util.resolveID(botID)}/commands`, + headers: { Authorization: this.token }, + data: { id: commandID } + }, + { requiresToken: true } + ) + } + + /** + * Edits a bot's command + * @param botID The bot's ID + * @param commandData The command payload + */ + editBotCommand(botID: IDResolvable, commandData: any) { + return this._request( + { + method: 'patch', + url: `/bots/${Util.resolveID(botID)}/commands`, + headers: { Authorization: this.token }, + data: commandData + }, + { requiresToken: true } + ) + } + + /** + * Gets the number of votes a user gave to a bot + * @param botID The bot's ID + * @param userID The user's ID + */ + getVotes(botID: IDResolvable, userID: IDResolvable) { + return this._request( + { + url: `/bots/${Util.resolveID(botID)}/votes`, + headers: { Authorization: this.token }, + params: { user_id: Util.resolveID(userID) } + }, + { requiresToken: true } + ) + } + + /** + * Gets the votes a user gave to a bot with timestamps + * @param botID The bot's ID + * @param userID The user's ID + */ + getTimestampedVotes(botID: IDResolvable, userID: IDResolvable) { + return this._request( + { + url: `/bots/${Util.resolveID(botID)}/votes/timestamped`, + headers: { Authorization: this.token }, + params: { user_id: Util.resolveID(userID) } + }, + { requiresToken: true } + ) + } + + /** + * Allows you to enable or disable the maintenance status + * @param botID The bot's ID + * @param maintenanceData The maintenance payload + */ + setMaintenance(botID: IDResolvable, maintenanceData?: any) { + return this._request( + { + method: 'post', + url: `/bots/${Util.resolveID(botID)}/maintenance`, + headers: { Authorization: this.token }, + data: maintenanceData + }, + { requiresToken: true } + ) + } + + /** + * Gets a service feature + * @param featureName The internal name of the feature + */ + getFeature(featureName: string) { + return this._request({ url: `/features/${featureName}` }) + } + + /** + * Gets a service tag + * @param tagName The internal name of the tag + */ + getTag(tagName: string) { + return this._request({ url: `/tags/${tagName}` }) + } + + /** + * Gets a vanity from the service + * @param vanity The vanity string + */ + getVanity(vanity: string) { + return this._request({ url: `/vanity/${vanity}` }) + } + + /** + * Gets a user from the service + * @param id The user's id + */ + getUser(id: IDResolvable) { + return this._request({ url: `/users/${Util.resolveID(id)}` }) + } + + /** + * Sets your user's description + * @param userID The user's id + * @param description The new description + */ + setUserDescription(userID: IDResolvable, description: string) { + return this._request( + { + method: 'patch', + url: `/users/${Util.resolveID(userID)}/description`, + headers: { Authorization: this.token }, + data: { description } + }, + { requiresToken: true } + ) + } + + /** Gets the bot index page */ + getBotIndex() { + return this._request({ url: '/bots/ext/index' }) + } + + /** Gets the bot search page */ + getSearch() { + return this._request({ url: '/bots/ext/search' }) + } + + /** + * Gets the rendered bot description preview + * @param previewData The preview payload + */ + getDescriptionPreview(previewData: any) { + return this._request({ + method: 'post', + url: `/preview`, + data: previewData + }) + } + + /** + * Gtes the valid servers on the service + * @param userID The user's ID + */ + getValidServers(userID: IDResolvable) { + return this._request({ + url: `/users/${Util.resolveID(userID)}/valid_servers` + }) + } }