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'
);