mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
Write some more docs
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,5 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Represents any Channel on Discord
|
||||||
|
*/
|
||||||
class Channel {
|
class Channel {
|
||||||
constructor(client, data, guild) {
|
constructor(client, data, guild) {
|
||||||
|
/**
|
||||||
|
* The client that instantiated the Channel
|
||||||
|
* @type {Channel}
|
||||||
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.typingMap = {};
|
this.typingMap = {};
|
||||||
this.typingTimeouts = [];
|
this.typingTimeouts = [];
|
||||||
@@ -13,9 +20,22 @@ class Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup(data) {
|
setup(data) {
|
||||||
|
/**
|
||||||
|
* The unique ID of the channel
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the channel
|
||||||
|
* @return {Promise<Channel>}
|
||||||
|
* @example
|
||||||
|
* // delete the channel
|
||||||
|
* channel.delete()
|
||||||
|
* .then() // success
|
||||||
|
* .catch(console.log); // log error
|
||||||
|
*/
|
||||||
delete() {
|
delete() {
|
||||||
return this.client.rest.methods.deleteChannel(this);
|
return this.client.rest.methods.deleteChannel(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,80 @@
|
|||||||
const User = require('./User');
|
const User = require('./User');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the logged in client's Discord User
|
||||||
|
* @class ClientUser
|
||||||
|
* @extends {User}
|
||||||
|
*/
|
||||||
class ClientUser extends User {
|
class ClientUser extends User {
|
||||||
setup(data) {
|
setup(data) {
|
||||||
super.setup(data);
|
super.setup(data);
|
||||||
|
/**
|
||||||
|
* Whether or not this account has been verified
|
||||||
|
* @type {Boolean}
|
||||||
|
*/
|
||||||
this.verified = data.verified;
|
this.verified = data.verified;
|
||||||
|
/**
|
||||||
|
* The email of this account
|
||||||
|
* @type {String}
|
||||||
|
*/
|
||||||
this.email = data.email;
|
this.email = data.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the username of the logged in Client.
|
||||||
|
* <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
|
||||||
|
* every hour. Use this sparingly!</info>
|
||||||
|
* @param {String} username the new username
|
||||||
|
* @returns {Promise<ClientUser>}
|
||||||
|
* @example
|
||||||
|
* // set username
|
||||||
|
* client.store.user.setUsername('discordjs')
|
||||||
|
* .then(user => console.log(`My new username is ${user.username}`))
|
||||||
|
* .catch(console.log);
|
||||||
|
*/
|
||||||
setUsername(username) {
|
setUsername(username) {
|
||||||
return this.client.rest.methods.updateCurrentUser({ username });
|
return this.client.rest.methods.updateCurrentUser({ username });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this user is a "self bot" or logged in using a normal user's details (which should be avoided), you can set the
|
||||||
|
* email here.
|
||||||
|
* @param {String} email the new email
|
||||||
|
* @returns {Promise<ClientUser>}
|
||||||
|
* @example
|
||||||
|
* // set email
|
||||||
|
* client.store.user.setEmail('bob@gmail.com')
|
||||||
|
* .then(user => console.log(`My new email is ${user.email}`))
|
||||||
|
* .catch(console.log);
|
||||||
|
*/
|
||||||
setEmail(email) {
|
setEmail(email) {
|
||||||
return this.client.rest.methods.updateCurrentUser({ email });
|
return this.client.rest.methods.updateCurrentUser({ email });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this user is a "self bot" or logged in using a normal user's details (which should be avoided), you can set the
|
||||||
|
* password here.
|
||||||
|
* @param {String} password the new password
|
||||||
|
* @returns {Promise<ClientUser>}
|
||||||
|
* @example
|
||||||
|
* // set password
|
||||||
|
* client.store.user.setPassword('password')
|
||||||
|
* .then(user => console.log('New password set!'))
|
||||||
|
* .catch(console.log);
|
||||||
|
*/
|
||||||
setPassword(password) {
|
setPassword(password) {
|
||||||
return this.client.rest.methods.updateCurrentUser({ password });
|
return this.client.rest.methods.updateCurrentUser({ password });
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Set the avatar of the logged in Client.
|
||||||
|
* @param {Base64Resolvable} avatar the new avatar
|
||||||
|
* @returns {Promise<ClientUser>}
|
||||||
|
* @example
|
||||||
|
* // set avatar
|
||||||
|
* client.store.user.setAvatar(fs.readFileSync('./avatar.png'))
|
||||||
|
* .then(user => console.log(`New avatar set!`))
|
||||||
|
* .catch(console.log);
|
||||||
|
*/
|
||||||
setAvatar(avatar) {
|
setAvatar(avatar) {
|
||||||
return this.client.rest.methods.updateCurrentUser({ avatar });
|
return this.client.rest.methods.updateCurrentUser({ avatar });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ class User {
|
|||||||
this.game = data.game || this.game;
|
this.game = data.game || this.game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When concatenated with a String, this automatically concatenates the User's mention instead of the User object.
|
||||||
|
* @returns {String}
|
||||||
|
* @example
|
||||||
|
* // logs: Hello from <@123456789>!
|
||||||
|
* console.log(`Hello from ${user}!`);
|
||||||
|
*/
|
||||||
toString() {
|
toString() {
|
||||||
return `<@${this.id}>`;
|
return `<@${this.id}>`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user