fix reply splitting (#1750)

This commit is contained in:
Will Nelson
2017-08-04 00:17:10 -07:00
committed by Crawl
parent fd11381cc5
commit a30fc87816

View File

@@ -15,6 +15,14 @@ module.exports = function sendMessage(channel, options) { // eslint-disable-line
if (isNaN(nonce) || nonce < 0) throw new RangeError('MESSAGE_NONCE_TYPE');
}
// Add the reply prefix
if (reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') {
const id = channel.client.resolver.resolveUserID(reply);
const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`;
if (split) split.prepend = `${mention}, ${split.prepend || ''}`;
content = `${mention}${typeof content !== 'undefined' ? `, ${content}` : ''}`;
}
if (content) {
content = Util.resolveString(content);
if (split && typeof split !== 'object') split = {};
@@ -36,14 +44,6 @@ module.exports = function sendMessage(channel, options) { // eslint-disable-line
if (split) content = Util.splitMessage(content, split);
}
// Add the reply prefix
if (reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') {
const id = channel.client.resolver.resolveUserID(reply);
const mention = `<@${reply instanceof GuildMember && reply.nickname ? '!' : ''}${id}>`;
if (split) split.prepend = `${mention}, ${split.prepend || ''}`;
content = `${mention}${typeof content !== 'undefined' ? `, ${content}` : ''}`;
}
if (content instanceof Array) {
return new Promise((resolve, reject) => {
const messages = [];