mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
docs: improvements & examples
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user