Constructor
new Client(optionsopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
ClientOptions |
<optional> |
{} | Options to pass. |
Members
endpoint :string
The API URL of serverlist.space. Version is missing.
Type:
- string
Methods
edit(options, presetopt) → {ClientOptions}
Edits ClientOptions.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
ClientOptions | Options to pass. | ||
preset |
boolean |
<optional> |
false | Whether or not to use the default ClientOptions. Otherwise uses [this.client.options](Client#options) |
Returns:
The new ClientOptions.
- Type
- ClientOptions
Example
SpaceClient.edit({ guildID: 123 }); // TypeError: options.guildID must be a string
SpaceClient.edit({ guildID: '123' }); // { ..., guildID: '123', ... };
(async) fetchGuild(idopt, optionsopt) → {Promise.<Guild>}
Fetches a single guild from serverlist.space
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | FetchOptions |
<optional> |
this.options.guildID | A guild ID listed on serverlist.space to fetch. Can also be FetchOptions; Uses [this.options.guildID](ClientOptions#guildID) for the ID if so. |
options |
FetchOptions |
<optional> |
{} | Options to pass. |
Returns:
- Type
- Promise.<Guild>
(async) fetchGuilds(optionsopt) → {Promise.<(Array.<Guild>|Store.<string, Guild>)>}
Fetches a page of guilds from serverlist.space
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
MultiFetchOptions |
<optional> |
{} | Options to pass. |
Returns:
(async) fetchGuildsOfUser(id, optionsopt) → {Promise.<(Array.<Guild>|Store.<string, Guild>)>}
Fetches a page of guilds that a user lists on serverlist.space
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | The ID of a user to get guilds from. | ||
options |
MultiFetchOptions |
<optional> |
{} | Options to pass. |
Returns:
Example
SpaceClient.fetchGuildsOfUser('235593018332282884')
.then(guilds => {
console.log(`All Guilds that User 235593018332282884 Owns:\n\n${guilds.map(g => g.name).join('\n')}`);
})
.catch(console.error);
(async) fetchStats(optionsopt) → {Promise.<Stats>}
serverlist.space Statistics
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
FetchOptions |
<optional> |
{} | Options to pass. |
Returns:
- Type
- Promise.<Stats>
(async) fetchUpvotes(idopt, optionsopt) → {Promise.<(Array.<Upvote>|Store.<string, Upvote>)>}
Fetches a guild's upvotes in the current month; Requires a Bot Token.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | MultiFetchOptions |
<optional> |
this.options.guildID | A guild ID to check upvotes of. Can also be MultiFetchOptions; Uses [this.options.guildID](ClientOptions#guildID) for the ID if so. |
options |
MultiFetchOptions |
<optional> |
{} | Options to pass. |
Returns:
Example
async () => {
const upvotes = await SpaceClient.fetchUpvotes('guildID', { botToken: 'someAPIToken', mapify: false });
for (const { user } of upvotes) console.log(`${user.tag} has upvoted this month!`);
}
(async) fetchUser(id, optionsopt) → {Promise.<User>}
Fetches a user on serverlist.space
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | A user ID to get properties of | ||
options |
FetchOptions |
<optional> |
{} | Options to pass. |
Returns:
- Type
- Promise.<User>