refactor: removed code and split options (#5918)

Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com>

BREAKING CHANGE: Removed `APIMessage#split`
BREAKING CHANGE: Removed `MessageEditOptions#code`
BREAKING CHANGE: Removed `BaseMessageOptions#code`
BREAKING CHANGE: Removed `BaseMessageOptions#split`
This commit is contained in:
Antonio Román
2021-06-27 00:11:40 +02:00
committed by GitHub
parent 0d0c8f07f2
commit 985d4d6a43
7 changed files with 19 additions and 101 deletions

View File

@@ -104,7 +104,7 @@ class APIMessage {
/**
* Makes the content of this message.
* @returns {?(string|string[])}
* @returns {?string}
*/
makeContent() {
let content;
@@ -114,27 +114,6 @@ class APIMessage {
content = Util.verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false);
}
if (typeof content !== 'string') return content;
const isSplit = typeof this.options.split !== 'undefined' && this.options.split !== false;
const isCode = typeof this.options.code !== 'undefined' && this.options.code !== false;
const splitOptions = isSplit ? { ...this.options.split } : undefined;
if (content) {
if (isCode) {
const codeName = typeof this.options.code === 'string' ? this.options.code : '';
content = `\`\`\`${codeName}\n${Util.cleanCodeBlockContent(content)}\n\`\`\``;
if (isSplit) {
splitOptions.prepend = `${splitOptions.prepend || ''}\`\`\`${codeName}\n`;
splitOptions.append = `\n\`\`\`${splitOptions.append || ''}`;
}
}
if (isSplit) {
content = Util.splitMessage(content, splitOptions);
}
}
return content;
}
@@ -232,37 +211,6 @@ class APIMessage {
return this;
}
/**
* Converts this APIMessage into an array of APIMessages for each split content
* @returns {APIMessage[]}
*/
split() {
if (!this.data) this.resolveData();
if (!Array.isArray(this.data.content)) return [this];
const apiMessages = [];
for (let i = 0; i < this.data.content.length; i++) {
let data;
let opt;
if (i === this.data.content.length - 1) {
data = { ...this.data, content: this.data.content[i] };
opt = { ...this.options, content: this.data.content[i] };
} else {
data = { content: this.data.content[i], tts: this.data.tts, allowed_mentions: this.options.allowedMentions };
opt = { content: this.data.content[i], tts: this.data.tts, allowedMentions: this.options.allowedMentions };
}
const apiMessage = new APIMessage(this.target, opt);
apiMessage.data = data;
apiMessages.push(apiMessage);
}
return apiMessages;
}
/**
* Resolves a single file into an object sendable to the API.
* @param {BufferResolvable|Stream|FileOptions|MessageAttachment} fileLike Something that could be resolved to a file