mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
Internal API Request Rewrite (#1490)
* start rewrite * converted guilds * more changes * convert GuildMember * convert User and remove friend methods which kill people * convert more stuff * even more stuff * make things nicer * speed and fixes and stuff * almost finished * fix * Update Client.js * uwu * Update RESTMethods.js * message editing * fix router * fix issue with references * message delete reason * move message sending * fix dm * message splitting * NO MORE REST METHODS * Update Client.js * Update WebhookClient.js * remove all those endpoints from the constants * Update ClientUser.js * Update ClientUser.js * fixes * Update ClientUser.js * complaiancy * all sort of fixes * merge master (#1) * Fix Permissions now that member is deprecated (#1491) * removing more deprecation leftovers (#1492) * Fix MessageCollectors * Fix awaitMessages (#1493) * Fix MessageCollector#cleanup * Fix MessageCollector#postCheck * Add max option back for safety * Update Invite.js (#1496) * guild setPosition missing docs (#1498) * missing docs * update return docs * indent * switched .invites for the apirouter and invite.js * make multiple options an object * Update ClientUser.js * fix nicks * Update WebhookClient.js
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const Constants = require('../util/Constants');
|
||||
const Presence = require('./Presence').Presence;
|
||||
const UserProfile = require('./UserProfile');
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
|
||||
/**
|
||||
@@ -115,7 +116,7 @@ class User {
|
||||
size = format;
|
||||
format = 'default';
|
||||
}
|
||||
return Constants.Endpoints.User(this).Avatar(this.client.options.http.cdn, this.avatar, format, size);
|
||||
return Constants.Endpoints.CDN(this.client.options.http.cdn).Avatar(this.id, this.avatar, format, size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +200,11 @@ class User {
|
||||
* @returns {Promise<DMChannel>}
|
||||
*/
|
||||
createDM() {
|
||||
return this.client.rest.methods.createDM(this);
|
||||
if (this.dmChannel) return Promise.resolve(this.dmChannel);
|
||||
return this.client.api.users(this.client.user.id).channels.post({ data: {
|
||||
recipient_id: this.id,
|
||||
} })
|
||||
.then(data => this.client.actions.ChannelCreate.handle(data).channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,43 +212,10 @@ class User {
|
||||
* @returns {Promise<DMChannel>}
|
||||
*/
|
||||
deleteDM() {
|
||||
return this.client.rest.methods.deleteChannel(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a friend request to the user.
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
addFriend() {
|
||||
return this.client.rest.methods.addFriend(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the user from your friends.
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
removeFriend() {
|
||||
return this.client.rest.methods.removeFriend(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the user.
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
block() {
|
||||
return this.client.rest.methods.blockUser(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks the user.
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
unblock() {
|
||||
return this.client.rest.methods.unblockUser(this);
|
||||
if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!'));
|
||||
return this.client.api.channels(this.dmChannel.id).delete().then(data =>
|
||||
this.client.actions.ChannelDelete.handle(data).channel
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +224,7 @@ class User {
|
||||
* @returns {Promise<UserProfile>}
|
||||
*/
|
||||
fetchProfile() {
|
||||
return this.client.rest.methods.fetchUserProfile(this);
|
||||
return this.client.api.users(this.id).profile.get().then(data => new UserProfile(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +234,8 @@ class User {
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
setNote(note) {
|
||||
return this.client.rest.methods.setNote(this, note);
|
||||
return this.client.api.users('@me').notes(this.id).put({ data: { note } })
|
||||
.then(() => this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user