docs: improvements & examples

This commit is contained in:
Lewdcario
2018-03-01 20:47:18 -06:00
parent acdf43a872
commit fcdffcf623
3 changed files with 16 additions and 2 deletions

View File

@@ -174,6 +174,11 @@ class ClientUser extends User {
* Sets the full presence of the client user.
* @param {PresenceData} data Data for the presence
* @returns {Promise<ClientUser>}
* @example
* // Set the client user's presence
* client.user.setPresence({ game: { name: 'with discord.js' }, status: 'idle' })
* .then(console.log)
* .catch(console.error);
*/
setPresence(data) {
// {"op":3,"d":{"status":"dnd","since":0,"game":null,"afk":false}}
@@ -241,6 +246,11 @@ class ClientUser extends User {
* Sets the status of the client user.
* @param {PresenceStatus} status Status to change to
* @returns {Promise<ClientUser>}
* @example
* // Set the client user's status
* client.user.setStatus('idle')
* .then(console.log)
* .catch(console.error);
*/
setStatus(status) {
return this.setPresence({ status });

View File

@@ -441,10 +441,14 @@ class Guild {
/**
* Fetch a collection of banned users in this guild.
* @returns {Promise<Collection<Snowflake, User>>}
* @example
* // Fetch bans in guild
* guild.fetchBans()
* .then(bans => console.log(`This guild has ${bans.size} bans`))
* .catch(console.error);
*/
fetchBans() {
return this.client.rest.methods.getGuildBans(this)
// This entire re-mapping can be removed in the next major release
.then(bans => {
const users = new Collection();
for (const ban of bans.values()) users.set(ban.user.id, ban.user);

View File

@@ -263,7 +263,7 @@ class GuildChannel extends Channel {
/**
* Set a new parent for the guild channel.
* @param {GuildChannel|SnowFlake} parent The new parent for the guild channel
* @param {CategoryChannel|SnowFlake} parent The new parent for the guild channel
* @param {string} [reason] Reason for changing the guild channel's parent
* @returns {Promise<GuildChannel>}
* @example