Skip to content

Commit

Permalink
chore: deprecate userbot methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewdcario committed Jul 26, 2018
1 parent d685e39 commit 95a2d25
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ class Client extends EventEmitter {
* Logs the client in, establishing a websocket connection to Discord.

This comment has been minimized.

Copy link
@saske-pro

saske-pro Jun 12, 2019

.

* <info>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.</info>
* Bot accounts also have access to many features that user accounts cannot utilise. Automating a user account is
* considered a violation of the ToS.</info>
* @param {string} token Token of the account to log in with
* @returns {Promise<string>} Token of the account used
* @example
Expand Down Expand Up @@ -395,11 +395,12 @@ class Client extends EventEmitter {
* <warn>Bots can only fetch their own profile.</warn>
* @param {Snowflake} [id='@me'] ID of application to fetch
* @returns {Promise<OAuth2Application>}
* client.fetchApplication('id')
* client.fetchApplication()
* .then(application => console.log(`Obtained application with name: ${application.name}`)
* .catch(console.error);
*/
fetchApplication(id = '@me') {
if (id !== '@me') process.emitWarning('fetchApplication: use "@me" as an argument', 'DeprecationWarning');
return this.rest.methods.getApplication(id);
}

Expand Down
16 changes: 16 additions & 0 deletions src/structures/ClientUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ class ClientUser extends User {

/**
* Fetches messages that mentioned the client's user.
* <warn>This is only available when using a user account.</warn>
* @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
Expand Down Expand Up @@ -412,4 +413,19 @@ class ClientUser extends User {
ClientUser.prototype.setGame =
util.deprecate(ClientUser.prototype.setGame, 'ClientUser#setGame: use ClientUser#setActivity instead');

ClientUser.prototype.addFriend =
util.deprecate(ClientUser.prototype.addFriend, 'ClientUser#addFriend: userbot methods will be removed');

ClientUser.prototype.removeFriend =
util.deprecate(ClientUser.prototype.removeFriend, 'ClientUser#removeFriend: userbot methods will be removed');

ClientUser.prototype.setPassword =
util.deprecate(ClientUser.prototype.setPassword, 'ClientUser#setPassword: userbot methods will be removed');

ClientUser.prototype.setEmail =
util.deprecate(ClientUser.prototype.setEmail, 'ClientUser#setEmail: userbot methods will be removed');

ClientUser.prototype.fetchMentions =
util.deprecate(ClientUser.prototype.fetchMentions, 'ClientUser#fetchMentions: userbot methods will be removed');

module.exports = ClientUser;
12 changes: 12 additions & 0 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,4 +1333,16 @@ Object.defineProperty(Guild.prototype, 'defaultChannel', {
}, 'Guild#defaultChannel: This property is obsolete, will be removed in v12.0.0, and may not function as expected.'),
});

Guild.prototype.acknowledge =
util.deprecate(Guild.prototype.acknowledge, 'Guild#acknowledge: userbot methods will be removed');

Guild.prototype.setPosition =
util.deprecate(Guild.prototype.setPosition, 'Guild#setPosition: userbot methods will be removed');

Guild.prototype.search =
util.deprecate(Guild.prototype.search, 'Guild#search: userbot methods will be removed');

Guild.prototype.sync =
util.deprecate(Guild.prototype.sync, 'Guild#sync:, userbot methods will be removed');

module.exports = Guild;
4 changes: 4 additions & 0 deletions src/structures/OAuth2Application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Snowflake = require('../util/Snowflake');
const util = require('util');

/**
* Represents an OAuth2 Application.
Expand Down Expand Up @@ -140,4 +141,7 @@ class OAuth2Application {
}
}

OAuth2Application.prototype.reset =
util.deprecate(OAuth2Application.prototype.reset, 'OAuth2Application#reset: userbot methods will be removed');

module.exports = OAuth2Application;
19 changes: 19 additions & 0 deletions src/structures/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const TextBasedChannel = require('./interfaces/TextBasedChannel');
const Constants = require('../util/Constants');
const Presence = require('./Presence').Presence;
const Snowflake = require('../util/Snowflake');
const util = require('util');

/**
* Represents a user on Discord.
Expand Down Expand Up @@ -300,4 +301,22 @@ class User {

TextBasedChannel.applyToClass(User);

User.prototype.block =
util.deprecate(User.prototype.block, 'User#block: userbot methods will be removed');

User.prototype.unblock =
util.deprecate(User.prototype.unblock, 'User#unblock: userbot methods will be removed');

User.prototype.addFriend =
util.deprecate(User.prototype.addFriend, 'User#addFriend: userbot methods will be removed');

User.prototype.removeFriend =
util.deprecate(User.prototype.removeFriend, 'User#removeFriend: userbot methods will be removed');

User.prototype.setNote =
util.deprecate(User.prototype.setNote, 'User#setNote, userbot methods will be removed');

User.prototype.fetchProfile =
util.deprecate(User.prototype.fetchProfile, 'User#fetchProfile: userbot methods will be removed');

module.exports = User;
7 changes: 7 additions & 0 deletions src/structures/interfaces/TextBasedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,10 @@ exports.applyToClass = (structure, full = false, ignore = []) => {
Object.defineProperty(structure.prototype, prop, Object.getOwnPropertyDescriptor(TextBasedChannel.prototype, prop));
}
};

TextBasedChannel.prototype.acknowledge = util.deprecate(
TextBasedChannel.prototype.acknowledge, 'TextBasedChannel#acknowledge: userbot methods will be removed'
);

TextBasedChannel.prototype.search =
util.deprecate(TextBasedChannel.prototype.search, 'TextBasedChannel#search: userbot methods will be removed');

0 comments on commit 95a2d25

Please sign in to comment.