Remove all deprecated methods / props

This commit is contained in:
Crawl
2017-05-14 20:15:55 +02:00
parent 4422f2aa8a
commit ca926ee404
11 changed files with 3 additions and 317 deletions

View File

@@ -39,11 +39,6 @@ class DMChannel extends Channel {
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}
sendMessage() {}
sendEmbed() {}
sendFile() {}
sendFiles() {}
sendCode() {}
fetchMessage() {}
fetchMessages() {}
fetchPinnedMessages() {}

View File

@@ -155,11 +155,6 @@ class GroupDMChannel extends Channel {
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}
sendMessage() {}
sendEmbed() {}
sendFile() {}
sendFiles() {}
sendCode() {}
fetchMessage() {}
fetchMessages() {}
fetchPinnedMessages() {}

View File

@@ -3,7 +3,6 @@ const Role = require('./Role');
const Permissions = require('../util/Permissions');
const Collection = require('../util/Collection');
const Presence = require('./Presence').Presence;
const util = require('util');
/**
* Represents a member of a guild on Discord.
@@ -310,18 +309,6 @@ class GuildMember {
return this.roles.some(r => r.hasPermission(permission, undefined, checkAdmin));
}
/**
* Checks whether the roles of the member allows them to perform specific actions.
* @param {PermissionResolvable[]} permissions The permissions to check for
* @param {boolean} [explicit=false] Whether to require the member to explicitly have the exact permissions
* @returns {boolean}
* @deprecated
*/
hasPermissions(permissions, explicit = false) {
if (!explicit && this.user.id === this.guild.ownerID) return true;
return this.hasPermission(permissions, explicit);
}
/**
* Checks whether the roles of the member allows them to perform specific actions, and lists any missing permissions.
* @param {PermissionResolvable[]} permissions The permissions to check for
@@ -509,15 +496,8 @@ class GuildMember {
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}
sendMessage() {}
sendEmbed() {}
sendFile() {}
sendCode() {}
}
TextBasedChannel.applyToClass(GuildMember);
GuildMember.prototype.hasPermissions = util.deprecate(GuildMember.prototype.hasPermissions,
'GuildMember#hasPermissions is deprecated - use GuildMember#hasPermission, it now takes an array');
module.exports = GuildMember;

View File

@@ -383,18 +383,6 @@ class Message {
return this.client.rest.methods.updateMessage(this, content, options);
}
/**
* Edit the content of the message, with a code block.
* @param {string} lang The language for the code block
* @param {StringResolvable} content The new content for the message
* @returns {Promise<Message>}
* @deprecated
*/
editCode(lang, content) {
content = Util.escapeMarkdown(this.client.resolver.resolveString(content), true);
return this.edit(`\`\`\`${lang || ''}\n${content}\n\`\`\``);
}
/**
* Pins this message to the channel's pinned messages.
* @returns {Promise<Message>}

View File

@@ -1,5 +1,4 @@
const Collector = require('./interfaces/Collector');
const util = require('util');
/**
* @typedef {CollectorOptions} MessageCollectorOptions
@@ -35,29 +34,9 @@ class MessageCollector extends Collector {
this.client.on('message', this.listener);
// For backwards compatibility (remove in v12)
if (this.options.max) this.options.maxProcessed = this.options.max;
if (this.options.maxMatches) this.options.max = this.options.maxMatches;
this._reEmitter = message => {
/**
* Emitted when the collector receives a message.
* @event MessageCollector#message
* @param {Message} message The message
* @deprecated
*/
this.emit('message', message);
};
this.on('collect', this._reEmitter);
}
// Remove in v12
on(eventName, listener) {
if (eventName === 'message') {
listener = util.deprecate(listener, 'MessageCollector will soon no longer emit "message", use "collect" instead');
}
super.on(eventName, listener);
}
/**
* Handle an incoming message for possible collection.
* @param {Message} message The message that could be collected

View File

@@ -1,6 +1,5 @@
const Snowflake = require('../util/Snowflake');
const Permissions = require('../util/Permissions');
const util = require('util');
/**
* Represents a role on Discord.
@@ -167,17 +166,6 @@ class Role {
);
}
/**
* Checks if the role has all specified permissions.
* @param {PermissionResolvable[]} permissions The permissions to check for
* @param {boolean} [explicit=false] Whether to require the role to explicitly have the exact permissions
* @returns {boolean}
* @deprecated
*/
hasPermissions(permissions, explicit = false) {
return new Permissions(this.permissions).has(permissions, !explicit);
}
/**
* Compares this role's position to another role's.
* @param {Role} role Role to compare to this one
@@ -351,8 +339,4 @@ class Role {
}
}
Role.prototype.hasPermissions = util
.deprecate(Role.prototype.hasPermissions,
'Role#hasPermissions is deprecated - use Role#hasPermission instead, it now takes an array');
module.exports = Role;

View File

@@ -84,11 +84,6 @@ class TextChannel extends GuildChannel {
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}
sendMessage() {}
sendEmbed() {}
sendFile() {}
sendFiles() {}
sendCode() {}
fetchMessage() {}
fetchMessages() {}
fetchPinnedMessages() {}

View File

@@ -296,10 +296,6 @@ class User {
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}
sendMessage() {}
sendEmbed() {}
sendFile() {}
sendCode() {}
}
TextBasedChannel.applyToClass(User);

View File

@@ -70,7 +70,7 @@ class Webhook {
}
/**
* Options that can be passed into send, sendMessage, sendFile, sendEmbed, and sendCode.
* Options that can be passed into send.
* @typedef {Object} WebhookMessageOptions
* @property {string} [username=this.name] Username override for the message
* @property {string} [avatarURL] Avatar URL override for the message
@@ -138,47 +138,6 @@ class Webhook {
return this.client.rest.methods.sendWebhookMessage(this, content, options);
}
/**
* Send a message with this webhook
* @param {StringResolvable} content The content to send
* @param {WebhookMessageOptions} [options={}] The options to provide
* @returns {Promise<Message|Message[]>}
* @deprecated
* @example
* // Send a message
* webhook.sendMessage('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
*/
sendMessage(content, options = {}) {
return this.send(content, options);
}
/**
* Send a file with this webhook.
* @param {BufferResolvable} attachment The file to send
* @param {string} [name='file.jpg'] The name and extension of the file
* @param {StringResolvable} [content] Text message to send with the attachment
* @param {WebhookMessageOptions} [options] The options to provide
* @returns {Promise<Message>}
* @deprecated
*/
sendFile(attachment, name, content, options = {}) {
return this.send(content, Object.assign(options, { file: { attachment, name } }));
}
/**
* Send a code block with this webhook.
* @param {string} lang Language for the code block
* @param {StringResolvable} content Content of the code block
* @param {WebhookMessageOptions} options The options to provide
* @returns {Promise<Message|Message[]>}
* @deprecated
*/
sendCode(lang, content, options = {}) {
return this.send(content, Object.assign(options, { code: lang }));
}
/**
* Send a raw slack message with this webhook.
* @param {Object} body The raw body to send

View File

@@ -2,7 +2,6 @@ const path = require('path');
const Message = require('../Message');
const MessageCollector = require('../MessageCollector');
const Collection = require('../../util/Collection');
const util = require('util');
/**
* Interface for classes that have text-channel-like features.
@@ -38,7 +37,6 @@ class TextBasedChannel {
* (see [here](https://discordapp.com/developers/docs/resources/channel#embed-object) for more details)
* @property {boolean} [disableEveryone=this.client.options.disableEveryone] Whether or not @everyone and @here
* should be replaced with plain-text
* @property {FileOptions|string} [file] A file to send with the message **(deprecated)**
* @property {FileOptions[]|string[]} [files] Files to send with the message
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
* @property {boolean|SplitOptions} [split=false] Whether or not the message should be split into multiple messages if
@@ -301,17 +299,6 @@ class TextBasedChannel {
return 0;
}
/**
* Creates a Message Collector
* @param {CollectorFilter} filter The filter to create the collector with
* @param {MessageCollectorOptions} [options={}] The options to pass to the collector
* @returns {MessageCollector}
* @deprecated
*/
createCollector(filter, options) {
return this.createMessageCollector(filter, options);
}
/**
* Creates a Message Collector.
* @param {CollectorFilter} filter The filter to create the collector with
@@ -398,86 +385,8 @@ class TextBasedChannel {
}
}
/** @lends TextBasedChannel.prototype */
const Deprecated = {
/**
* Send a message to this channel.
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options={}] Options for the message
* @returns {Promise<Message|Message[]>}
* @deprecated
* @example
* // Send a message
* channel.sendMessage('hello!')
* .then(message => console.log(`Sent message: ${message.content}`))
* .catch(console.error);
*/
sendMessage(content, options) {
return this.send(content, options);
},
/**
* Send an embed to this channel.
* @param {RichEmbed|Object} embed Embed for the message
* @param {string} [content] Text for the message
* @param {MessageOptions} [options] Options for the message
* @returns {Promise<Message>}
* @deprecated
*/
sendEmbed(embed, content, options) {
if (!options && typeof content === 'object' && !(content instanceof Array)) {
options = content;
content = '';
} else if (!options) {
options = {};
}
return this.send(content, Object.assign(options, { embed }));
},
/**
* Send files to this channel.
* @param {FileOptions[]|string[]} files Files to send with the message
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options] Options for the message
* @returns {Promise<Message>}
* @deprecated
*/
sendFiles(files, content, options = {}) {
return this.send(content, Object.assign(options, { files }));
},
/**
* Send a file to this channel.
* @param {BufferResolvable} attachment File to send
* @param {string} [name='file.jpg'] Name and extension of the file
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options] Options for the message
* @returns {Promise<Message>}
* @deprecated
*/
sendFile(attachment, name, content, options = {}) {
return this.send({ files: [{ attachment, name }], content, options });
},
/**
* Send a code block to this channel.
* @param {string} lang Language for the code block
* @param {StringResolvable} content Content of the code block
* @param {MessageOptions} [options] Options for the message
* @returns {Promise<Message|Message[]>}
* @deprecated
*/
sendCode(lang, content, options = {}) {
return this.send(content, Object.assign(options, { code: lang }));
},
};
for (const key of Object.keys(Deprecated)) {
TextBasedChannel.prototype[key] = util.deprecate(Deprecated[key], `TextChannel#${key}: use TextChannel#send instead`);
}
exports.applyToClass = (structure, full = false, ignore = []) => {
const props = ['send', 'sendMessage', 'sendEmbed', 'sendFile', 'sendFiles', 'sendCode'];
const props = ['send'];
if (full) {
props.push(
'_cacheMessage',
@@ -491,7 +400,6 @@ exports.applyToClass = (structure, full = false, ignore = []) => {
'typing',
'typingCount',
'fetchPinnedMessages',
'createCollector',
'createMessageCollector',
'awaitMessages'
);

View File

@@ -1,5 +1,4 @@
const Constants = require('../util/Constants');
const util = require('util');
/**
* Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of
@@ -8,19 +7,9 @@ const util = require('util');
*/
class Permissions {
/**
* @param {GuildMember} [member] Member the permissions are for **(deprecated)**
* @param {number|PermissionResolvable[]} permissions Permissions or bitfield to read from
*/
constructor(member, permissions) {
permissions = typeof member === 'object' && !(member instanceof Array) ? permissions : member;
/**
* Member the permissions are for
* @type {GuildMember}
* @deprecated
*/
this._member = typeof member === 'object' ? member : null;
constructor(permissions) {
/**
* Bitfield of the packed permissions
* @type {number}
@@ -28,29 +17,6 @@ class Permissions {
this.bitfield = typeof permissions === 'number' ? permissions : this.constructor.resolve(permissions);
}
get member() {
return this._member;
}
set member(value) {
this._member = value;
}
/**
* Bitfield of the packed permissions
* @type {number}
* @see {@link Permissions#bitfield}
* @deprecated
* @readonly
*/
get raw() {
return this.bitfield;
}
set raw(raw) {
this.bitfield = raw;
}
/**
* Checks whether the bitfield has a permission, or multiple permissions.
* @param {PermissionResolvable|PermissionResolvable[]} permission Permission(s) to check for
@@ -114,42 +80,6 @@ class Permissions {
return serialized;
}
/**
* Checks whether the user has a certain permission, e.g. `READ_MESSAGES`.
* @param {PermissionResolvable} permission The permission to check for
* @param {boolean} [explicit=false] Whether to require the user to explicitly have the exact permission
* @returns {boolean}
* @see {@link Permissions#has}
* @deprecated
*/
hasPermission(permission, explicit = false) {
return this.has(permission, !explicit);
}
/**
* Checks whether the user has all specified permissions.
* @param {PermissionResolvable[]} permissions The permissions to check for
* @param {boolean} [explicit=false] Whether to require the user to explicitly have the exact permissions
* @returns {boolean}
* @see {@link Permissions#has}
* @deprecated
*/
hasPermissions(permissions, explicit = false) {
return this.has(permissions, !explicit);
}
/**
* Checks whether the user has all specified permissions, and lists any missing permissions.
* @param {PermissionResolvable[]} permissions The permissions to check for
* @param {boolean} [explicit=false] Whether to require the user to explicitly have the exact permissions
* @returns {PermissionResolvable[]}
* @see {@link Permissions#missing}
* @deprecated
*/
missingPermissions(permissions, explicit = false) {
return this.missing(permissions, !explicit);
}
/**
* Data that can be resolved to give a permission number. This can be:
* - A string (see {@link Permissions.flags})
@@ -189,7 +119,6 @@ class Permissions {
* - `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord)
* - `MENTION_EVERYONE`
* - `USE_EXTERNAL_EMOJIS` (use emojis from different guilds)
* - `EXTERNAL_EMOJIS` **(deprecated)**
* - `CONNECT` (connect to a voice channel)
* - `SPEAK` (speak in a voice channel)
* - `MUTE_MEMBERS` (mute members across all voice channels)
@@ -199,7 +128,6 @@ class Permissions {
* - `CHANGE_NICKNAME`
* - `MANAGE_NICKNAMES` (change other members' nicknames)
* - `MANAGE_ROLES`
* - `MANAGE_ROLES_OR_PERMISSIONS` **(deprecated)**
* - `MANAGE_WEBHOOKS`
* - `MANAGE_EMOJIS`
* @type {Object}
@@ -223,7 +151,6 @@ Permissions.FLAGS = {
ATTACH_FILES: 1 << 15,
READ_MESSAGE_HISTORY: 1 << 16,
MENTION_EVERYONE: 1 << 17,
EXTERNAL_EMOJIS: 1 << 18,
USE_EXTERNAL_EMOJIS: 1 << 18,
CONNECT: 1 << 20,
@@ -236,7 +163,6 @@ Permissions.FLAGS = {
CHANGE_NICKNAME: 1 << 26,
MANAGE_NICKNAMES: 1 << 27,
MANAGE_ROLES: 1 << 28,
MANAGE_ROLES_OR_PERMISSIONS: 1 << 28,
MANAGE_WEBHOOKS: 1 << 29,
MANAGE_EMOJIS: 1 << 30,
};
@@ -253,23 +179,4 @@ Permissions.ALL = Object.keys(Permissions.FLAGS).reduce((all, p) => all | Permis
*/
Permissions.DEFAULT = 104324097;
/**
* @class EvaluatedPermissions
* @classdesc The final evaluated permissions for a member in a channel
* @see {@link Permissions}
* @deprecated
*/
Permissions.prototype.hasPermission = util.deprecate(Permissions.prototype.hasPermission,
'EvaluatedPermissions#hasPermission is deprecated, use Permissions#has instead');
Permissions.prototype.hasPermissions = util.deprecate(Permissions.prototype.hasPermissions,
'EvaluatedPermissions#hasPermissions is deprecated, use Permissions#has instead');
Permissions.prototype.missingPermissions = util.deprecate(Permissions.prototype.missingPermissions,
'EvaluatedPermissions#missingPermissions is deprecated, use Permissions#missing instead');
Object.defineProperty(Permissions.prototype, 'member', {
get: util
.deprecate(Object.getOwnPropertyDescriptor(Permissions.prototype, 'member').get,
'EvaluatedPermissions#member is deprecated'),
});
module.exports = Permissions;