diff --git a/src/client/Client.js b/src/client/Client.js
index f685382d60b0..b6c25f677fce 100644
--- a/src/client/Client.js
+++ b/src/client/Client.js
@@ -14,7 +14,6 @@ const VoiceBroadcast = require('./voice/VoiceBroadcast');
const UserStore = require('../stores/UserStore');
const ChannelStore = require('../stores/ChannelStore');
const GuildStore = require('../stores/GuildStore');
-const ClientPresenceStore = require('../stores/ClientPresenceStore');
const GuildEmojiStore = require('../stores/GuildEmojiStore');
const { Events, browser } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
@@ -96,17 +95,10 @@ class Client extends BaseClient {
*/
this.channels = new ChannelStore(this);
- /**
- * Presences that have been received for the client user's friends, mapped by user IDs
- * This is only filled when using a user account.
- * @type {ClientPresenceStore}
- */
- this.presences = new ClientPresenceStore(this);
-
Object.defineProperty(this, 'token', { writable: true });
if (!browser && !this.token && 'CLIENT_TOKEN' in process.env) {
/**
- * Authorization token for the logged in user/bot
+ * Authorization token for the logged in bot
* This should be kept private at all times.
* @type {?string}
*/
@@ -240,10 +232,6 @@ class Client extends BaseClient {
/**
* Logs the client in, establishing a websocket connection to Discord.
- * Both bot and regular user accounts are supported, but it is highly recommended to use a bot account whenever
- * possible. User accounts are subject to harsher ratelimits and other restrictions that don't apply to bot accounts.
- * Bot accounts also have access to many features that user accounts cannot utilise. User accounts that are found to
- * be abusing/overusing the API will be banned, locking you out of Discord entirely.
* @param {string} token Token of the account to log in with
* @returns {Promise} Token of the account used
* @example
@@ -269,20 +257,6 @@ class Client extends BaseClient {
return this.manager.destroy();
}
- /**
- * Requests a sync of guild data with Discord.
- * This can be done automatically every 30 seconds by enabling {@link ClientOptions#sync}.
- * This is only available when using a user account.
- * @param {Guild[]|Collection} [guilds=this.guilds] An array or collection of guilds to sync
- */
- syncGuilds(guilds = this.guilds) {
- if (this.user.bot) return;
- this.ws.send({
- op: 12,
- d: guilds instanceof Collection ? guilds.keyArray() : guilds.map(g => g.id),
- });
- }
-
/**
* Obtains an invite from Discord.
* @param {InviteResolvable} invite Invite code or URL
diff --git a/src/client/ClientManager.js b/src/client/ClientManager.js
index 2a081e3a71db..b1929cbdebac 100644
--- a/src/client/ClientManager.js
+++ b/src/client/ClientManager.js
@@ -64,14 +64,9 @@ class ClientManager {
destroy() {
this.client.ws.destroy();
if (!this.client.user) return Promise.resolve();
- if (this.client.user.bot) {
+ return this.client.api.logout.post().then(() => {
this.client.token = null;
- return Promise.resolve();
- } else {
- return this.client.api.logout.post().then(() => {
- this.client.token = null;
- });
- }
+ });
}
}
diff --git a/src/errors/Messages.js b/src/errors/Messages.js
index 0485296a6426..a4e8362ceb81 100644
--- a/src/errors/Messages.js
+++ b/src/errors/Messages.js
@@ -6,8 +6,6 @@ const Messages = {
TOKEN_INVALID: 'An invalid token was provided.',
TOKEN_MISSING: 'Request to use token, but token was unavailable to the client.',
- FEATURE_USER_ONLY: 'Only user accounts are able to make use of this feature.',
-
WS_CONNECTION_TIMEOUT: 'The connection to the gateway timed out.',
WS_CONNECTION_EXISTS: 'There is already an existing WebSocket connection.',
WS_NOT_OPEN: (data = 'data') => `Websocket not open to send ${data}`,
diff --git a/src/index.js b/src/index.js
index b89d9ce5674f..9606c66388f0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -25,7 +25,6 @@ module.exports = {
// Stores
ChannelStore: require('./stores/ChannelStore'),
- ClientPresenceStore: require('./stores/ClientPresenceStore'),
GuildChannelStore: require('./stores/GuildChannelStore'),
GuildEmojiStore: require('./stores/GuildEmojiStore'),
GuildEmojiRoleStore: require('./stores/GuildEmojiRoleStore'),
@@ -57,8 +56,6 @@ module.exports = {
return require('./structures/ClientUser');
},
ClientUserChannelOverride: require('./structures/ClientUserChannelOverride'),
- ClientUserGuildSettings: require('./structures/ClientUserGuildSettings'),
- ClientUserSettings: require('./structures/ClientUserSettings'),
Collector: require('./structures/interfaces/Collector'),
DMChannel: require('./structures/DMChannel'),
Emoji: require('./structures/Emoji'),
diff --git a/src/rest/RESTManager.js b/src/rest/RESTManager.js
index 4ca4cb174c78..ec9d3891f759 100644
--- a/src/rest/RESTManager.js
+++ b/src/rest/RESTManager.js
@@ -39,8 +39,7 @@ class RESTManager {
getAuth() {
const token = this.client.token || this.client.accessToken;
- const prefixed = !!this.client.application || (this.client.user && this.client.user.bot);
- if (token && prefixed) return `${this.tokenPrefix} ${token}`;
+ if (token && this.client.application) return `${this.tokenPrefix} ${token}`;
else if (token) return token;
throw new Error('TOKEN_MISSING');
}
diff --git a/src/stores/ClientPresenceStore.js b/src/stores/ClientPresenceStore.js
deleted file mode 100644
index 94d48d4a424f..000000000000
--- a/src/stores/ClientPresenceStore.js
+++ /dev/null
@@ -1,80 +0,0 @@
-const PresenceStore = require('./PresenceStore');
-const Collection = require('../util/Collection');
-const { ActivityTypes, OPCodes } = require('../util/Constants');
-const { Presence } = require('../structures/Presence');
-const { TypeError } = require('../errors');
-
-/**
- * Stores the client presence and other presences.
- * @extends {PresenceStore}
- */
-class ClientPresenceStore extends PresenceStore {
- constructor(...args) {
- super(...args);
- this.clientPresence = new Presence(this.client, {
- status: 'online',
- afk: false,
- since: null,
- activity: null,
- });
- }
-
- async setClientPresence(presence) {
- const packet = await this._parse(presence);
- this.clientPresence.patch(packet);
- this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
- return this.clientPresence;
- }
-
- async _parse({ status, since, afk, activity }) { // eslint-disable-line complexity
- const applicationID = activity && (activity.application ? activity.application.id || activity.application : null);
- let assets = new Collection();
- if (activity) {
- if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', 'name', 'string');
- if (!activity.type) activity.type = 0;
- if (activity.assets && applicationID) {
- try {
- const a = await this.client.api.oauth2.applications(applicationID).assets.get();
- for (const asset of a) assets.set(asset.name, asset.id);
- } catch (err) { } // eslint-disable-line no-empty
- }
- }
-
- const packet = {
- afk: afk != null ? afk : false, // eslint-disable-line eqeqeq
- since: since != null ? since : null, // eslint-disable-line eqeqeq
- status: status || this.clientPresence.status,
- game: activity ? {
- type: activity.type,
- name: activity.name,
- url: activity.url,
- details: activity.details || undefined,
- state: activity.state || undefined,
- assets: activity.assets ? {
- large_text: activity.assets.largeText || undefined,
- small_text: activity.assets.smallText || undefined,
- large_image: assets.get(activity.assets.largeImage) || activity.assets.largeImage,
- small_image: assets.get(activity.assets.smallImage) || activity.assets.smallImage,
- } : undefined,
- timestamps: activity.timestamps || undefined,
- party: activity.party || undefined,
- application_id: applicationID || undefined,
- secrets: activity.secrets || undefined,
- instance: activity.instance || undefined,
- } : null,
- };
-
- if ((status || afk || since) && !activity) {
- packet.game = this.clientPresence.activity;
- }
-
- if (packet.game) {
- packet.game.type = typeof packet.game.type === 'number' ?
- packet.game.type : ActivityTypes.indexOf(packet.game.type);
- }
-
- return packet;
- }
-}
-
-module.exports = ClientPresenceStore;
diff --git a/src/stores/GuildStore.js b/src/stores/GuildStore.js
index c42bf5e490af..5787fd193301 100644
--- a/src/stores/GuildStore.js
+++ b/src/stores/GuildStore.js
@@ -39,7 +39,7 @@ class GuildStore extends DataStore {
/**
* Creates a guild.
- * This is only available to bots in less than 10 guilds and user accounts.
+ * This is only available to bots in less than 10 guilds.
* @param {string} name The name of the guild
* @param {Object} [options] Options for the creating
* @param {string} [options.region] The region for the server, defaults to the closest one available
diff --git a/src/stores/MessageStore.js b/src/stores/MessageStore.js
index 852f4ebe55bb..7db733eb3cd1 100644
--- a/src/stores/MessageStore.js
+++ b/src/stores/MessageStore.js
@@ -1,7 +1,6 @@
const DataStore = require('./DataStore');
const Collection = require('../util/Collection');
const Message = require('../structures/Message');
-const { Error } = require('../errors');
/**
* Stores messages for text-based channels.
@@ -68,12 +67,6 @@ class MessageStore extends DataStore {
}
async _fetchId(messageID) {
- if (!this.client.user.bot) {
- const messages = await this._fetchMany({ limit: 1, around: messageID });
- const msg = messages.get(messageID);
- if (!msg) throw new Error('MESSAGE_MISSING');
- return msg;
- }
const data = await this.client.api.channels[this.channel.id].messages[messageID].get();
return this.add(data);
}
diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js
index f76e98b0a37b..e6cf07016899 100644
--- a/src/structures/ClientApplication.js
+++ b/src/structures/ClientApplication.js
@@ -174,26 +174,6 @@ class ClientApplication extends Base {
} });
}
- /**
- * Resets the app's secret.
- * This is only available when using a user account.
- * @returns {Promise}
- */
- resetSecret() {
- return this.client.api.oauth2.applications[this.id].reset.post()
- .then(app => new ClientApplication(this.client, app));
- }
-
- /**
- * Resets the app's bot token.
- * This is only available when using a user account.
- * @returns {Promise}
- */
- resetToken() {
- return this.client.api.oauth2.applications[this.id].bot.reset.post()
- .then(app => new ClientApplication(this.client, Object.assign({}, this, { bot: app })));
- }
-
/**
* When concatenated with a string, this automatically returns the application's name instead of the
* ClientApplication object.
diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js
index cce9957ad071..0929438d99dc 100644
--- a/src/structures/ClientUser.js
+++ b/src/structures/ClientUser.js
@@ -1,10 +1,5 @@
const Structures = require('../util/Structures');
-const Collection = require('../util/Collection');
-const ClientUserSettings = require('./ClientUserSettings');
-const ClientUserGuildSettings = require('./ClientUserGuildSettings');
-const Util = require('../util/Util');
const DataResolver = require('../util/DataResolver');
-const Guild = require('./Guild');
/**
* Represents the logged in client's Discord user.
@@ -20,75 +15,8 @@ class ClientUser extends Structures.get('User') {
*/
this.verified = data.verified;
- /**
- * The email of this account
- * This is only filled when using a user account.
- * @type {?string}
- */
- this.email = data.email;
this._typing = new Map();
- /**
- * A Collection of friends for the logged in user
- * This is only filled when using a user account.
- * @type {Collection}
- */
- this.friends = new Collection();
-
- /**
- * A Collection of blocked users for the logged in user
- * This is only filled when using a user account.
- * @type {Collection}
- */
- this.blocked = new Collection();
-
- /**
- * A Collection of notes for the logged in user
- * This is only filled when using a user account.
- * @type {Collection}
- */
- this.notes = new Collection();
-
- /**
- * If the user has Discord premium (nitro)
- * This is only filled when using a user account.
- * @type {?boolean}
- */
- this.premium = typeof data.premium === 'boolean' ? data.premium : null;
-
- /**
- * If the user has MFA enabled on their account
- * This is only filled when using a user account.
- * @type {?boolean}
- */
- this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
-
- /**
- * If the user has ever used a mobile device on Discord
- * This is only filled when using a user account.
- * @type {?boolean}
- */
- this.mobile = typeof data.mobile === 'boolean' ? data.mobile : null;
-
- /**
- * Various settings for this user
- * This is only filled when using a user account.
- * @type {?ClientUserSettings}
- */
- this.settings = data.user_settings ? new ClientUserSettings(this, data.user_settings) : null;
-
- /**
- * All of the user's guild settings
- * This is only filled when using a user account.
- * @type {Collection}
- */
- this.guildSettings = new Collection();
- if (data.user_guild_settings) {
- for (const settings of data.user_guild_settings) {
- this.guildSettings.set(settings.guild_id, new ClientUserGuildSettings(this.client, settings));
- }
- }
-
if (data.token) this.client.token = data.token;
}
@@ -101,15 +29,7 @@ class ClientUser extends Structures.get('User') {
return this.client.presences.clientPresence;
}
- edit(data, passcode) {
- if (!this.bot) {
- if (typeof passcode !== 'object') {
- data.password = passcode;
- } else {
- data.code = passcode.mfaCode;
- data.password = passcode.password;
- }
- }
+ edit(data) {
return this.client.api.users('@me').patch({ data })
.then(newData => {
this.client.token = newData.token;
@@ -122,7 +42,6 @@ class ClientUser extends Structures.get('User') {
* Changing usernames in Discord is heavily rate limited, with only 2 requests
* every hour. Use this sparingly!
* @param {string} username The new username
- * @param {string} [password] Current password (only for user accounts)
* @returns {Promise}
* @example
* // Set username
@@ -130,43 +49,8 @@ class ClientUser extends Structures.get('User') {
* .then(user => console.log(`My new username is ${user.username}`))
* .catch(console.error);
*/
- setUsername(username, password) {
- return this.edit({ username }, password);
- }
-
- /**
- * Changes the email for the client user's account.
- * This is only available when using a user account.
- * @param {string} email New email to change to
- * @param {string} password Current password
- * @returns {Promise}
- * @example
- * // Set email
- * client.user.setEmail('bob@gmail.com', 'some amazing password 123')
- * .then(user => console.log(`My new email is ${user.email}`))
- * .catch(console.error);
- */
- setEmail(email, password) {
- return this.edit({ email }, password);
- }
-
- /**
- * Changes the password for the client user's account.
- * This is only available when using a user account.
- * @param {string} newPassword New password to change to
- * @param {Object|string} options Object containing an MFA code, password or both.
- * Can be just a string for the password.
- * @param {string} [options.oldPassword] Current password
- * @param {string} [options.mfaCode] Timed MFA Code
- * @returns {Promise}
- * @example
- * // Set password
- * client.user.setPassword('some new amazing password 456', 'some amazing password 123')
- * .then(user => console.log('New password set!'))
- * .catch(console.error);
- */
- setPassword(newPassword, options) {
- return this.edit({ new_password: newPassword }, { password: options.oldPassword, mfaCode: options.mfaCode });
+ setUsername(username) {
+ return this.edit({ username });
}
/**
@@ -262,36 +146,6 @@ class ClientUser extends Structures.get('User') {
return this.setPresence({ afk });
}
- /**
- * Fetches messages that mentioned the client's user.
- * This is only available when using a user account.
- * @param {Object} [options={}] Options for the fetch
- * @param {number} [options.limit=25] Maximum number of mentions to retrieve
- * @param {boolean} [options.roles=true] Whether to include role mentions
- * @param {boolean} [options.everyone=true] Whether to include everyone/here mentions
- * @param {GuildResolvable} [options.guild] Limit the search to a specific guild
- * @returns {Promise}
- * @example
- * // Fetch mentions
- * client.user.fetchMentions()
- * .then(console.log)
- * .catch(console.error);
- * @example
- * // Fetch mentions from a guild
- * client.user.fetchMentions({
- * guild: '222078108977594368'
- * })
- * .then(console.log)
- * .catch(console.error);
- */
- fetchMentions(options = {}) {
- if (options.guild instanceof Guild) options.guild = options.guild.id;
- Util.mergeDefault({ limit: 25, roles: true, everyone: true, guild: null }, options);
-
- return this.client.api.users('@me').mentions.get({ query: options })
- .then(data => data.map(m => this.client.channels.get(m.channel_id).messages.add(m, false)));
- }
-
/**
* An object containing either a user or access token, and an optional nickname.
* @typedef {Object} GroupDMRecipientOptions
diff --git a/src/structures/ClientUserGuildSettings.js b/src/structures/ClientUserGuildSettings.js
deleted file mode 100644
index ef1ba9a57bf1..000000000000
--- a/src/structures/ClientUserGuildSettings.js
+++ /dev/null
@@ -1,60 +0,0 @@
-const { UserGuildSettingsMap } = require('../util/Constants');
-const Collection = require('../util/Collection');
-const ClientUserChannelOverride = require('./ClientUserChannelOverride');
-
-/**
- * A wrapper around the ClientUser's guild settings.
- */
-class ClientUserGuildSettings {
- constructor(client, data) {
- /**
- * The client that created the instance of the ClientUserGuildSettings
- * @name ClientUserGuildSettings#client
- * @type {Client}
- * @readonly
- */
- Object.defineProperty(this, 'client', { value: client });
- /**
- * The ID of the guild these settings are for
- * @type {Snowflake}
- */
- this.guildID = data.guild_id;
- this.channelOverrides = new Collection();
- this.patch(data);
- }
-
- /**
- * Patch the data contained in this class with new partial data.
- * @param {Object} data Data to patch this with
- * @private
- */
- patch(data) {
- for (const [key, value] of Object.entries(UserGuildSettingsMap)) {
- if (!data.hasOwnProperty(key)) continue;
- if (key === 'channel_overrides') {
- for (const channel of data[key]) {
- const override = this.channelOverrides.get(channel.channel_id);
- if (override) override.patch(channel);
- else this.channelOverrides.set(channel.channel_id, new ClientUserChannelOverride(channel));
- }
- } else if (typeof value === 'function') {
- this[value.name] = value(data[key]);
- } else {
- this[value] = data[key];
- }
- }
- }
-
- /**
- * Update a specific property of the guild settings.
- * @param {string} name Name of property
- * @param {*} value Value to patch
- * @returns {Promise