mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
feat(*): enforce strings (#4880)
BREAKING CHANGE: Removes all Resolvables for only string inputs Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -49,7 +49,7 @@ export const {
|
|||||||
escapeMarkdown,
|
escapeMarkdown,
|
||||||
fetchRecommendedShards,
|
fetchRecommendedShards,
|
||||||
resolveColor,
|
resolveColor,
|
||||||
resolveString,
|
verifyString,
|
||||||
splitMessage,
|
splitMessage,
|
||||||
Application,
|
Application,
|
||||||
ApplicationCommand,
|
ApplicationCommand,
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ const Messages = {
|
|||||||
COLOR_RANGE: 'Color must be within the range 0 - 16777215 (0xFFFFFF).',
|
COLOR_RANGE: 'Color must be within the range 0 - 16777215 (0xFFFFFF).',
|
||||||
COLOR_CONVERT: 'Unable to convert color to a number.',
|
COLOR_CONVERT: 'Unable to convert color to a number.',
|
||||||
|
|
||||||
|
EMBED_TITLE: 'MessageEmbed title must be a string.',
|
||||||
|
EMBED_FIELD_NAME: 'MessageEmbed field names must be non-empty strings.',
|
||||||
|
EMBED_FIELD_VALUE: 'MessageEmbed field values must be non-empty strings.',
|
||||||
|
EMBED_FOOTER_TEXT: 'MessageEmbed footer text must be a string.',
|
||||||
|
EMBED_DESCRIPTION: 'MessageEmbed description must be a string.',
|
||||||
|
EMBED_AUTHOR_NAME: 'MessageEmbed author name must be a string.',
|
||||||
|
|
||||||
FILE_NOT_FOUND: file => `File could not be found: ${file}`,
|
FILE_NOT_FOUND: file => `File could not be found: ${file}`,
|
||||||
|
|
||||||
USER_NO_DMCHANNEL: 'No DM Channel exists!',
|
USER_NO_DMCHANNEL: 'No DM Channel exists!',
|
||||||
@@ -72,6 +79,7 @@ const Messages = {
|
|||||||
|
|
||||||
MESSAGE_BULK_DELETE_TYPE: 'The messages must be an Array, Collection, or number.',
|
MESSAGE_BULK_DELETE_TYPE: 'The messages must be an Array, Collection, or number.',
|
||||||
MESSAGE_NONCE_TYPE: 'Message nonce must be an integer or a string.',
|
MESSAGE_NONCE_TYPE: 'Message nonce must be an integer or a string.',
|
||||||
|
MESSAGE_CONTENT_TYPE: 'Message content must be a non-empty string.',
|
||||||
|
|
||||||
TYPING_COUNT: 'Count must be at least 1',
|
TYPING_COUNT: 'Count must be at least 1',
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ module.exports = {
|
|||||||
escapeMarkdown: Util.escapeMarkdown,
|
escapeMarkdown: Util.escapeMarkdown,
|
||||||
fetchRecommendedShards: Util.fetchRecommendedShards,
|
fetchRecommendedShards: Util.fetchRecommendedShards,
|
||||||
resolveColor: Util.resolveColor,
|
resolveColor: Util.resolveColor,
|
||||||
resolveString: Util.resolveString,
|
verifyString: Util.verifyString,
|
||||||
splitMessage: Util.splitMessage,
|
splitMessage: Util.splitMessage,
|
||||||
|
|
||||||
// Structures
|
// Structures
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class APIMessage {
|
|||||||
if (this.options.content === null) {
|
if (this.options.content === null) {
|
||||||
content = '';
|
content = '';
|
||||||
} else if (typeof this.options.content !== 'undefined') {
|
} else if (typeof this.options.content !== 'undefined') {
|
||||||
content = Util.resolveString(this.options.content);
|
content = Util.verifyString(this.options.content, RangeError, 'MESSAGE_CONTENT_TYPE', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof content !== 'string') return content;
|
if (typeof content !== 'string') return content;
|
||||||
@@ -322,7 +322,7 @@ class APIMessage {
|
|||||||
/**
|
/**
|
||||||
* Transforms the user-level arguments into a final options object. Passing a transformed options object alone into
|
* Transforms the user-level arguments into a final options object. Passing a transformed options object alone into
|
||||||
* this method will keep it the same, allowing for the reuse of the final options object.
|
* this method will keep it the same, allowing for the reuse of the final options object.
|
||||||
* @param {StringResolvable} [content] Content to send
|
* @param {string} [content] Content to send
|
||||||
* @param {MessageOptions|WebhookMessageOptions|MessageAdditions} [options={}] Options to use
|
* @param {MessageOptions|WebhookMessageOptions|MessageAdditions} [options={}] Options to use
|
||||||
* @param {MessageOptions|WebhookMessageOptions} [extra={}] Extra options to add onto transformed options
|
* @param {MessageOptions|WebhookMessageOptions} [extra={}] Extra options to add onto transformed options
|
||||||
* @param {boolean} [isWebhook=false] Whether or not to use WebhookMessageOptions as the result
|
* @param {boolean} [isWebhook=false] Whether or not to use WebhookMessageOptions as the result
|
||||||
@@ -358,7 +358,7 @@ class APIMessage {
|
|||||||
/**
|
/**
|
||||||
* Creates an `APIMessage` from user-level arguments.
|
* Creates an `APIMessage` from user-level arguments.
|
||||||
* @param {MessageTarget} target Target to send to
|
* @param {MessageTarget} target Target to send to
|
||||||
* @param {StringResolvable} [content] Content to send
|
* @param {string} [content] Content to send
|
||||||
* @param {MessageOptions|WebhookMessageOptions|MessageAdditions} [options={}] Options to use
|
* @param {MessageOptions|WebhookMessageOptions|MessageAdditions} [options={}] Options to use
|
||||||
* @param {MessageOptions|WebhookMessageOptions} [extra={}] - Extra options to add onto transformed options
|
* @param {MessageOptions|WebhookMessageOptions} [extra={}] - Extra options to add onto transformed options
|
||||||
* @returns {MessageOptions|WebhookMessageOptions}
|
* @returns {MessageOptions|WebhookMessageOptions}
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ class Message extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits the content of the message.
|
* Edits the content of the message.
|
||||||
* @param {StringResolvable|APIMessage} [content] The new content for the message
|
* @param {string|APIMessage} [content] The new content for the message
|
||||||
* @param {MessageEditOptions|MessageEmbed} [options] The options to provide
|
* @param {MessageEditOptions|MessageEmbed} [options] The options to provide
|
||||||
* @returns {Promise<Message>}
|
* @returns {Promise<Message>}
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -265,8 +265,8 @@ class MessageEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a field to the embed (max 25).
|
* Adds a field to the embed (max 25).
|
||||||
* @param {StringResolvable} name The name of this field
|
* @param {string} name The name of this field
|
||||||
* @param {StringResolvable} value The value of this field
|
* @param {string} value The value of this field
|
||||||
* @param {boolean} [inline=false] If this field will be displayed inline
|
* @param {boolean} [inline=false] If this field will be displayed inline
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
@@ -309,13 +309,13 @@ class MessageEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the author of this embed.
|
* Sets the author of this embed.
|
||||||
* @param {StringResolvable} name The name of the author
|
* @param {string} name The name of the author
|
||||||
* @param {string} [iconURL] The icon URL of the author
|
* @param {string} [iconURL] The icon URL of the author
|
||||||
* @param {string} [url] The URL of the author
|
* @param {string} [url] The URL of the author
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
setAuthor(name, iconURL, url) {
|
setAuthor(name, iconURL, url) {
|
||||||
this.author = { name: Util.resolveString(name), iconURL, url };
|
this.author = { name: Util.verifyString(name, RangeError, 'EMBED_AUTHOR_NAME'), iconURL, url };
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,24 +331,22 @@ class MessageEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description of this embed.
|
* Sets the description of this embed.
|
||||||
* @param {StringResolvable} description The description
|
* @param {string} description The description
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
setDescription(description) {
|
setDescription(description) {
|
||||||
description = Util.resolveString(description);
|
this.description = Util.verifyString(description, RangeError, 'EMBED_DESCRIPTION');
|
||||||
this.description = description;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the footer of this embed.
|
* Sets the footer of this embed.
|
||||||
* @param {StringResolvable} text The text of the footer
|
* @param {string} text The text of the footer
|
||||||
* @param {string} [iconURL] The icon URL of the footer
|
* @param {string} [iconURL] The icon URL of the footer
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
setFooter(text, iconURL) {
|
setFooter(text, iconURL) {
|
||||||
text = Util.resolveString(text);
|
this.footer = { text: Util.verifyString(text, RangeError, 'EMBED_FOOTER_TEXT'), iconURL };
|
||||||
this.footer = { text, iconURL };
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,12 +383,11 @@ class MessageEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the title of this embed.
|
* Sets the title of this embed.
|
||||||
* @param {StringResolvable} title The title
|
* @param {string} title The title
|
||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
setTitle(title) {
|
setTitle(title) {
|
||||||
title = Util.resolveString(title);
|
this.title = Util.verifyString(title, RangeError, 'EMBED_TITLE');
|
||||||
this.title = title;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,21 +434,23 @@ class MessageEmbed {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes field input and resolves strings.
|
* Normalizes field input and resolves strings.
|
||||||
* @param {StringResolvable} name The name of the field
|
* @param {string} name The name of the field
|
||||||
* @param {StringResolvable} value The value of the field
|
* @param {string} value The value of the field
|
||||||
* @param {boolean} [inline=false] Set the field to display inline
|
* @param {boolean} [inline=false] Set the field to display inline
|
||||||
* @returns {EmbedField}
|
* @returns {EmbedField}
|
||||||
*/
|
*/
|
||||||
static normalizeField(name, value, inline = false) {
|
static normalizeField(name, value, inline = false) {
|
||||||
name = Util.resolveString(name);
|
return {
|
||||||
value = Util.resolveString(value);
|
name: Util.verifyString(name, RangeError, 'EMBED_FIELD_NAME', false),
|
||||||
return { name, value, inline };
|
value: Util.verifyString(value, RangeError, 'EMBED_FIELD_VALUE', false),
|
||||||
|
inline,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} EmbedFieldData
|
* @typedef {Object} EmbedFieldData
|
||||||
* @property {StringResolvable} name The name of this field
|
* @property {string} name The name of this field
|
||||||
* @property {StringResolvable} value The value of this field
|
* @property {string} value The value of this field
|
||||||
* @property {boolean} [inline] If this field will be displayed inline
|
* @property {boolean} [inline] If this field will be displayed inline
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class Webhook {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message with this webhook.
|
* Sends a message with this webhook.
|
||||||
* @param {StringResolvable|APIMessage} [content=''] The content to send
|
* @param {string|APIMessage} [content=''] The content to send
|
||||||
* @param {WebhookMessageOptions|MessageAdditions} [options={}] The options to provide
|
* @param {WebhookMessageOptions|MessageAdditions} [options={}] The options to provide
|
||||||
* @returns {Promise<Message|Object>}
|
* @returns {Promise<Message|Object>}
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class TextBasedChannel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to this channel.
|
* Sends a message to this channel.
|
||||||
* @param {StringResolvable|APIMessage} [content=''] The content to send
|
* @param {string|APIMessage} [content=''] The content to send
|
||||||
* @param {MessageOptions|MessageAdditions} [options={}] The options to provide
|
* @param {MessageOptions|MessageAdditions} [options={}] The options to provide
|
||||||
* @returns {Promise<Message|Message[]>}
|
* @returns {Promise<Message|Message[]>}
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ class Util {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits a string into multiple chunks at a designated character that do not exceed a specific length.
|
* Splits a string into multiple chunks at a designated character that do not exceed a specific length.
|
||||||
* @param {StringResolvable} text Content to split
|
* @param {string} text Content to split
|
||||||
* @param {SplitOptions} [options] Options controlling the behavior of the split
|
* @param {SplitOptions} [options] Options controlling the behavior of the split
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
*/
|
*/
|
||||||
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
|
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
|
||||||
text = Util.resolveString(text);
|
text = Util.verifyString(text, RangeError, 'MESSAGE_CONTENT_TYPE', false);
|
||||||
if (text.length <= maxLength) return [text];
|
if (text.length <= maxLength) return [text];
|
||||||
const splitText = text.split(char);
|
const splitText = text.split(char);
|
||||||
if (splitText.some(chunk => chunk.length > maxLength)) throw new RangeError('SPLIT_MAX_LEN');
|
if (splitText.some(chunk => chunk.length > maxLength)) throw new RangeError('SPLIT_MAX_LEN');
|
||||||
@@ -347,22 +347,22 @@ class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data that can be resolved to give a string. This can be:
|
* Verifies the provided data is a string, otherwise throws provided error.
|
||||||
* * A string
|
* @param {string} data The string resolvable to resolve
|
||||||
* * An array (joined with a new line delimiter to give a string)
|
* @param {Function} [error] The Error constructor to instantiate. Defaults to Error
|
||||||
* * Any value
|
* @param {string} [errorMessage] The error message to throw with. Defaults to "Expected string, got <data> instead."
|
||||||
* @typedef {string|Array|*} StringResolvable
|
* @param {boolean} [allowEmpty=true] Whether an empty string should be allowed
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a StringResolvable to a string.
|
|
||||||
* @param {StringResolvable} data The string resolvable to resolve
|
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
static resolveString(data) {
|
static verifyString(
|
||||||
if (typeof data === 'string') return data;
|
data,
|
||||||
if (Array.isArray(data)) return data.join('\n');
|
error = Error,
|
||||||
return String(data);
|
errorMessage = `Expected a string, got ${data} instead.`,
|
||||||
|
allowEmpty = true,
|
||||||
|
) {
|
||||||
|
if (typeof data !== 'string') throw new error(errorMessage);
|
||||||
|
if (!allowEmpty && data.length === 0) throw new error(errorMessage);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const { Client, Intents, MessageAttachment, MessageEmbed } = require('../src');
|
|||||||
|
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
||||||
|
|
||||||
const fill = c => Array(4).fill(c.repeat(1000));
|
|
||||||
const buffer = l => fetch(l).then(res => res.buffer());
|
const buffer = l => fetch(l).then(res => res.buffer());
|
||||||
const read = util.promisify(fs.readFile);
|
const read = util.promisify(fs.readFile);
|
||||||
const readStream = fs.createReadStream;
|
const readStream = fs.createReadStream;
|
||||||
@@ -24,16 +23,11 @@ const attach = (attachment, name) => new MessageAttachment(attachment, name);
|
|||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
m => m.channel.send('x'),
|
m => m.channel.send('x'),
|
||||||
m => m.channel.send(['x', 'y']),
|
|
||||||
|
|
||||||
m => m.channel.send('x', { code: true }),
|
m => m.channel.send('x', { code: true }),
|
||||||
m => m.channel.send('1', { code: 'js' }),
|
m => m.channel.send('1', { code: 'js' }),
|
||||||
m => m.channel.send('x', { code: '' }),
|
m => m.channel.send('x', { code: '' }),
|
||||||
|
|
||||||
m => m.channel.send(fill('x'), { split: true }),
|
|
||||||
m => m.channel.send(fill('1'), { code: 'js', split: true }),
|
|
||||||
m => m.channel.send(fill('xyz '), { split: { char: ' ' } }),
|
|
||||||
|
|
||||||
m => m.channel.send('x', { embed: { description: 'a' } }),
|
m => m.channel.send('x', { embed: { description: 'a' } }),
|
||||||
m => m.channel.send({ embed: { description: 'a' } }),
|
m => m.channel.send({ embed: { description: 'a' } }),
|
||||||
m => m.channel.send({ files: [{ attachment: linkA }] }),
|
m => m.channel.send({ files: [{ attachment: linkA }] }),
|
||||||
@@ -68,8 +62,8 @@ const tests = [
|
|||||||
m => m.channel.send({ embed: { description: 'a' } }).then(m2 => m2.edit({ embed: null })),
|
m => m.channel.send({ embed: { description: 'a' } }).then(m2 => m2.edit({ embed: null })),
|
||||||
m => m.channel.send(embed().setDescription('a')).then(m2 => m2.edit({ embed: null })),
|
m => m.channel.send(embed().setDescription('a')).then(m2 => m2.edit({ embed: null })),
|
||||||
|
|
||||||
m => m.channel.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
m => m.channel.send('x', [embed().setDescription('a'), attach(linkB)]),
|
||||||
m => m.channel.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
m => m.channel.send('x', [attach(linkA), attach(linkB)]),
|
||||||
|
|
||||||
m => m.channel.send([embed().setDescription('a'), attach(linkB)]),
|
m => m.channel.send([embed().setDescription('a'), attach(linkB)]),
|
||||||
m =>
|
m =>
|
||||||
@@ -83,37 +77,14 @@ const tests = [
|
|||||||
.setImage('attachment://two.png')
|
.setImage('attachment://two.png')
|
||||||
.attachFiles([attach(linkB, 'two.png')]),
|
.attachFiles([attach(linkB, 'two.png')]),
|
||||||
}),
|
}),
|
||||||
async m =>
|
|
||||||
m.channel.send(['x', 'y', 'z'], {
|
|
||||||
code: 'js',
|
|
||||||
embed: embed()
|
|
||||||
.setImage('attachment://two.png')
|
|
||||||
.attachFiles([attach(linkB, 'two.png')]),
|
|
||||||
files: [{ attachment: await buffer(linkA) }],
|
|
||||||
}),
|
|
||||||
|
|
||||||
m => m.channel.send('x', attach(fileA)),
|
m => m.channel.send('x', attach(fileA)),
|
||||||
m => m.channel.send({ files: [fileA] }),
|
m => m.channel.send({ files: [fileA] }),
|
||||||
m => m.channel.send(attach(fileA)),
|
m => m.channel.send(attach(fileA)),
|
||||||
async m => m.channel.send({ files: [await read(fileA)] }),
|
async m => m.channel.send({ files: [await read(fileA)] }),
|
||||||
async m =>
|
|
||||||
m.channel.send(fill('x'), {
|
|
||||||
code: 'js',
|
|
||||||
split: true,
|
|
||||||
embed: embed().setImage('attachment://zero.png'),
|
|
||||||
files: [attach(await buffer(linkA), 'zero.png')],
|
|
||||||
}),
|
|
||||||
|
|
||||||
m => m.channel.send('x', attach(readStream(fileA))),
|
m => m.channel.send('x', attach(readStream(fileA))),
|
||||||
m => m.channel.send({ files: [readStream(fileA)] }),
|
m => m.channel.send({ files: [readStream(fileA)] }),
|
||||||
m => m.channel.send({ files: [{ attachment: readStream(fileA) }] }),
|
m => m.channel.send({ files: [{ attachment: readStream(fileA) }] }),
|
||||||
async m =>
|
|
||||||
m.channel.send(fill('xyz '), {
|
|
||||||
code: 'js',
|
|
||||||
split: { char: ' ', prepend: 'hello! ', append: '!!!' },
|
|
||||||
embed: embed().setImage('attachment://zero.png'),
|
|
||||||
files: [linkB, attach(await buffer(linkA), 'zero.png'), readStream(fileA)],
|
|
||||||
}),
|
|
||||||
|
|
||||||
m => m.channel.send('Done!'),
|
m => m.channel.send('Done!'),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ client.on('message', m => {
|
|||||||
m.channel.send(com, { code: true });
|
m.channel.send(com, { code: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
m.channel.send(e, { code: true });
|
m.channel.send(String(e), { code: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const { Client, Intents, MessageAttachment, MessageEmbed, WebhookClient } = requ
|
|||||||
|
|
||||||
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
|
||||||
|
|
||||||
const fill = c => Array(4).fill(c.repeat(1000));
|
|
||||||
const buffer = l => fetch(l).then(res => res.buffer());
|
const buffer = l => fetch(l).then(res => res.buffer());
|
||||||
const read = util.promisify(fs.readFile);
|
const read = util.promisify(fs.readFile);
|
||||||
const readStream = fs.createReadStream;
|
const readStream = fs.createReadStream;
|
||||||
@@ -24,16 +23,10 @@ const attach = (attachment, name) => new MessageAttachment(attachment, name);
|
|||||||
|
|
||||||
const tests = [
|
const tests = [
|
||||||
(m, hook) => hook.send('x'),
|
(m, hook) => hook.send('x'),
|
||||||
(m, hook) => hook.send(['x', 'y']),
|
|
||||||
|
|
||||||
(m, hook) => hook.send('x', { code: true }),
|
(m, hook) => hook.send('x', { code: true }),
|
||||||
(m, hook) => hook.send('1', { code: 'js' }),
|
(m, hook) => hook.send('1', { code: 'js' }),
|
||||||
(m, hook) => hook.send('x', { code: '' }),
|
(m, hook) => hook.send('x', { code: '' }),
|
||||||
|
|
||||||
(m, hook) => hook.send(fill('x'), { split: true }),
|
|
||||||
(m, hook) => hook.send(fill('1'), { code: 'js', split: true }),
|
|
||||||
(m, hook) => hook.send(fill('xyz '), { split: { char: ' ' } }),
|
|
||||||
|
|
||||||
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
||||||
(m, hook) => hook.send({ files: [{ attachment: linkA }] }),
|
(m, hook) => hook.send({ files: [{ attachment: linkA }] }),
|
||||||
(m, hook) =>
|
(m, hook) =>
|
||||||
@@ -61,8 +54,8 @@ const tests = [
|
|||||||
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
||||||
(m, hook) => hook.send(embed().setDescription('a')),
|
(m, hook) => hook.send(embed().setDescription('a')),
|
||||||
|
|
||||||
(m, hook) => hook.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
(m, hook) => hook.send('x', [embed().setDescription('a'), attach(linkB)]),
|
||||||
(m, hook) => hook.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
(m, hook) => hook.send('x', [attach(linkA), attach(linkB)]),
|
||||||
|
|
||||||
(m, hook) => hook.send([embed().setDescription('a'), attach(linkB)]),
|
(m, hook) => hook.send([embed().setDescription('a'), attach(linkB)]),
|
||||||
(m, hook) =>
|
(m, hook) =>
|
||||||
@@ -93,25 +86,10 @@ const tests = [
|
|||||||
(m, hook) => hook.send({ files: [fileA] }),
|
(m, hook) => hook.send({ files: [fileA] }),
|
||||||
(m, hook) => hook.send(attach(fileA)),
|
(m, hook) => hook.send(attach(fileA)),
|
||||||
async (m, hook) => hook.send({ files: [await read(fileA)] }),
|
async (m, hook) => hook.send({ files: [await read(fileA)] }),
|
||||||
async (m, hook) =>
|
|
||||||
hook.send(fill('x'), {
|
|
||||||
code: 'js',
|
|
||||||
split: true,
|
|
||||||
embeds: [embed().setImage('attachment://zero.png')],
|
|
||||||
files: [attach(await buffer(linkA), 'zero.png')],
|
|
||||||
}),
|
|
||||||
|
|
||||||
(m, hook) => hook.send('x', attach(readStream(fileA))),
|
(m, hook) => hook.send('x', attach(readStream(fileA))),
|
||||||
(m, hook) => hook.send({ files: [readStream(fileA)] }),
|
(m, hook) => hook.send({ files: [readStream(fileA)] }),
|
||||||
(m, hook) => hook.send({ files: [{ attachment: readStream(fileA) }] }),
|
(m, hook) => hook.send({ files: [{ attachment: readStream(fileA) }] }),
|
||||||
async (m, hook) =>
|
|
||||||
hook.send(fill('xyz '), {
|
|
||||||
code: 'js',
|
|
||||||
split: { char: ' ', prepend: 'hello! ', append: '!!!' },
|
|
||||||
embeds: [embed().setImage('attachment://zero.png')],
|
|
||||||
files: [linkB, attach(await buffer(linkA), 'zero.png'), readStream(fileA)],
|
|
||||||
}),
|
|
||||||
|
|
||||||
(m, hook) => hook.send('Done!'),
|
(m, hook) => hook.send('Done!'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
92
typings/index.d.ts
vendored
92
typings/index.d.ts
vendored
@@ -129,13 +129,13 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
public static create(
|
public static create(
|
||||||
target: MessageTarget,
|
target: MessageTarget,
|
||||||
content: APIMessageContentResolvable,
|
content: string | null,
|
||||||
options?: undefined,
|
options?: undefined,
|
||||||
extra?: MessageOptions | WebhookMessageOptions,
|
extra?: MessageOptions | WebhookMessageOptions,
|
||||||
): APIMessage;
|
): APIMessage;
|
||||||
public static create(
|
public static create(
|
||||||
target: MessageTarget,
|
target: MessageTarget,
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: MessageOptions | WebhookMessageOptions | MessageAdditions,
|
options: MessageOptions | WebhookMessageOptions | MessageAdditions,
|
||||||
extra?: MessageOptions | WebhookMessageOptions,
|
extra?: MessageOptions | WebhookMessageOptions,
|
||||||
): APIMessage;
|
): APIMessage;
|
||||||
@@ -144,13 +144,13 @@ declare module 'discord.js' {
|
|||||||
): [MessageEmbed[], MessageAttachment[]];
|
): [MessageEmbed[], MessageAttachment[]];
|
||||||
public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<unknown>;
|
public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise<unknown>;
|
||||||
public static transformOptions(
|
public static transformOptions(
|
||||||
content: APIMessageContentResolvable,
|
content: string | null,
|
||||||
options?: undefined,
|
options?: undefined,
|
||||||
extra?: MessageOptions | WebhookMessageOptions,
|
extra?: MessageOptions | WebhookMessageOptions,
|
||||||
isWebhook?: boolean,
|
isWebhook?: boolean,
|
||||||
): MessageOptions | WebhookMessageOptions;
|
): MessageOptions | WebhookMessageOptions;
|
||||||
public static transformOptions(
|
public static transformOptions(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: MessageOptions | WebhookMessageOptions | MessageAdditions,
|
options: MessageOptions | WebhookMessageOptions | MessageAdditions,
|
||||||
extra?: MessageOptions | WebhookMessageOptions,
|
extra?: MessageOptions | WebhookMessageOptions,
|
||||||
isWebhook?: boolean,
|
isWebhook?: boolean,
|
||||||
@@ -448,16 +448,16 @@ declare module 'discord.js' {
|
|||||||
public defer(options?: InteractionDeferOptions): Promise<void>;
|
public defer(options?: InteractionDeferOptions): Promise<void>;
|
||||||
public deleteReply(): Promise<void>;
|
public deleteReply(): Promise<void>;
|
||||||
public editReply(
|
public editReply(
|
||||||
content: string | APIMessage | WebhookEditMessageOptions | MessageAdditions,
|
content: string | null | APIMessage | WebhookEditMessageOptions | MessageAdditions,
|
||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
public editReply(content: string, options?: WebhookEditMessageOptions): Promise<Message | RawMessage>;
|
public editReply(content: string | null, options?: WebhookEditMessageOptions): Promise<Message | RawMessage>;
|
||||||
public fetchReply(): Promise<Message | RawMessage>;
|
public fetchReply(): Promise<Message | RawMessage>;
|
||||||
public followUp(
|
public followUp(
|
||||||
content: string | APIMessage | InteractionReplyOptions | MessageAdditions,
|
content: string | APIMessage | InteractionReplyOptions | MessageAdditions,
|
||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
public followUp(content: string, options?: InteractionReplyOptions): Promise<Message | RawMessage>;
|
public followUp(content: string | null, options?: InteractionReplyOptions): Promise<Message | RawMessage>;
|
||||||
public reply(content: string | APIMessage | InteractionReplyOptions | MessageAdditions): Promise<void>;
|
public reply(content: string | null | APIMessage | InteractionReplyOptions | MessageAdditions): Promise<void>;
|
||||||
public reply(content: string, options?: InteractionReplyOptions): Promise<void>;
|
public reply(content: string | null, options?: InteractionReplyOptions): Promise<void>;
|
||||||
private transformOption(option: unknown, resolved: unknown): CommandInteractionOption;
|
private transformOption(option: unknown, resolved: unknown): CommandInteractionOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1185,9 +1185,9 @@ declare module 'discord.js' {
|
|||||||
): ReactionCollector;
|
): ReactionCollector;
|
||||||
public delete(): Promise<Message>;
|
public delete(): Promise<Message>;
|
||||||
public edit(
|
public edit(
|
||||||
content: APIMessageContentResolvable | MessageEditOptions | MessageEmbed | APIMessage,
|
content: string | null | MessageEditOptions | MessageEmbed | APIMessage,
|
||||||
): Promise<Message>;
|
): Promise<Message>;
|
||||||
public edit(content: StringResolvable, options: MessageEditOptions | MessageEmbed): Promise<Message>;
|
public edit(content: string | null, options: MessageEditOptions | MessageEmbed): Promise<Message>;
|
||||||
public equals(message: Message, rawData: unknown): boolean;
|
public equals(message: Message, rawData: unknown): boolean;
|
||||||
public fetchReference(): Promise<Message>;
|
public fetchReference(): Promise<Message>;
|
||||||
public fetchWebhook(): Promise<Webhook>;
|
public fetchWebhook(): Promise<Webhook>;
|
||||||
@@ -1197,19 +1197,19 @@ declare module 'discord.js' {
|
|||||||
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
|
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
|
||||||
public removeAttachments(): Promise<Message>;
|
public removeAttachments(): Promise<Message>;
|
||||||
public reply(
|
public reply(
|
||||||
content: APIMessageContentResolvable | (ReplyMessageOptions & { split?: false }) | MessageAdditions,
|
content: string | null | (ReplyMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message>;
|
): Promise<Message>;
|
||||||
public reply(options: ReplyMessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
public reply(options: ReplyMessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
||||||
public reply(options: ReplyMessageOptions | APIMessage): Promise<Message | Message[]>;
|
public reply(options: ReplyMessageOptions | APIMessage): Promise<Message | Message[]>;
|
||||||
public reply(
|
public reply(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: (ReplyMessageOptions & { split?: false }) | MessageAdditions,
|
options: (ReplyMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message>;
|
): Promise<Message>;
|
||||||
public reply(
|
public reply(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: ReplyMessageOptions & { split: true | SplitOptions },
|
options: ReplyMessageOptions & { split: true | SplitOptions },
|
||||||
): Promise<Message[]>;
|
): Promise<Message[]>;
|
||||||
public reply(content: StringResolvable, options: ReplyMessageOptions): Promise<Message | Message[]>;
|
public reply(content: string | null, options: ReplyMessageOptions): Promise<Message | Message[]>;
|
||||||
public suppressEmbeds(suppress?: boolean): Promise<Message>;
|
public suppressEmbeds(suppress?: boolean): Promise<Message>;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
@@ -1271,26 +1271,22 @@ declare module 'discord.js' {
|
|||||||
public type: string;
|
public type: string;
|
||||||
public url: string | null;
|
public url: string | null;
|
||||||
public readonly video: MessageEmbedVideo | null;
|
public readonly video: MessageEmbedVideo | null;
|
||||||
public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this;
|
public addField(name: string, value: string, inline?: boolean): this;
|
||||||
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
|
public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
|
||||||
public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this;
|
public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this;
|
||||||
public setAuthor(name: StringResolvable, iconURL?: string, url?: string): this;
|
public setAuthor(name: string, iconURL?: string, url?: string): this;
|
||||||
public setColor(color: ColorResolvable): this;
|
public setColor(color: ColorResolvable): this;
|
||||||
public setDescription(description: StringResolvable): this;
|
public setDescription(description: string): this;
|
||||||
public setFooter(text: StringResolvable, iconURL?: string): this;
|
public setFooter(text: string, iconURL?: string): this;
|
||||||
public setImage(url: string): this;
|
public setImage(url: string): this;
|
||||||
public setThumbnail(url: string): this;
|
public setThumbnail(url: string): this;
|
||||||
public setTimestamp(timestamp?: Date | number): this;
|
public setTimestamp(timestamp?: Date | number): this;
|
||||||
public setTitle(title: StringResolvable): this;
|
public setTitle(title: string): this;
|
||||||
public setURL(url: string): this;
|
public setURL(url: string): this;
|
||||||
public spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
|
public spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[] | EmbedFieldData[][]): this;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
|
|
||||||
public static normalizeField(
|
public static normalizeField(name: string, value: string, inline?: boolean): Required<EmbedFieldData>;
|
||||||
name: StringResolvable,
|
|
||||||
value: StringResolvable,
|
|
||||||
inline?: boolean,
|
|
||||||
): Required<EmbedFieldData>;
|
|
||||||
public static normalizeFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): Required<EmbedFieldData>[];
|
public static normalizeFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): Required<EmbedFieldData>[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1785,7 +1781,7 @@ declare module 'discord.js' {
|
|||||||
public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
|
public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
|
||||||
public static parseEmoji(text: string): { animated: boolean; name: string; id: string | null } | null;
|
public static parseEmoji(text: string): { animated: boolean; name: string; id: string | null } | null;
|
||||||
public static resolveColor(color: ColorResolvable): number;
|
public static resolveColor(color: ColorResolvable): number;
|
||||||
public static resolveString(data: StringResolvable): string;
|
public static verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string;
|
||||||
public static setPosition<T extends Channel | Role>(
|
public static setPosition<T extends Channel | Role>(
|
||||||
item: T,
|
item: T,
|
||||||
position: number,
|
position: number,
|
||||||
@@ -1794,7 +1790,7 @@ declare module 'discord.js' {
|
|||||||
route: unknown,
|
route: unknown,
|
||||||
reason?: string,
|
reason?: string,
|
||||||
): Promise<{ id: Snowflake; position: number }[]>;
|
): Promise<{ id: Snowflake; position: number }[]>;
|
||||||
public static splitMessage(text: StringResolvable, options?: SplitOptions): string[];
|
public static splitMessage(text: string, options?: SplitOptions): string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class VoiceBroadcast extends EventEmitter {
|
class VoiceBroadcast extends EventEmitter {
|
||||||
@@ -1970,25 +1966,25 @@ declare module 'discord.js' {
|
|||||||
public token: string;
|
public token: string;
|
||||||
public editMessage(
|
public editMessage(
|
||||||
message: MessageResolvable,
|
message: MessageResolvable,
|
||||||
content: APIMessageContentResolvable | APIMessage | MessageEmbed | MessageEmbed[],
|
content: string | null | APIMessage | MessageEmbed | MessageEmbed[],
|
||||||
options?: WebhookEditMessageOptions,
|
options?: WebhookEditMessageOptions,
|
||||||
): Promise<RawMessage>;
|
): Promise<RawMessage>;
|
||||||
public editMessage(message: MessageResolvable, options: WebhookEditMessageOptions): Promise<RawMessage>;
|
public editMessage(message: MessageResolvable, options: WebhookEditMessageOptions): Promise<RawMessage>;
|
||||||
public fetchMessage(message: Snowflake, cache?: boolean): Promise<RawMessage>;
|
public fetchMessage(message: Snowflake, cache?: boolean): Promise<RawMessage>;
|
||||||
public send(
|
public send(
|
||||||
content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
content: string | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<RawMessage>;
|
): Promise<RawMessage>;
|
||||||
public send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<RawMessage[]>;
|
public send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<RawMessage[]>;
|
||||||
public send(options: WebhookMessageOptions | APIMessage): Promise<RawMessage | RawMessage[]>;
|
public send(options: WebhookMessageOptions | APIMessage): Promise<RawMessage | RawMessage[]>;
|
||||||
public send(
|
public send(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<RawMessage>;
|
): Promise<RawMessage>;
|
||||||
public send(
|
public send(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: WebhookMessageOptions & { split: true | SplitOptions },
|
options: WebhookMessageOptions & { split: true | SplitOptions },
|
||||||
): Promise<RawMessage[]>;
|
): Promise<RawMessage[]>;
|
||||||
public send(content: StringResolvable, options: WebhookMessageOptions): Promise<RawMessage | RawMessage[]>;
|
public send(content: string | null, options: WebhookMessageOptions): Promise<RawMessage | RawMessage[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WebSocketManager extends EventEmitter {
|
export class WebSocketManager extends EventEmitter {
|
||||||
@@ -2325,14 +2321,12 @@ declare module 'discord.js' {
|
|||||||
interface PartialTextBasedChannelFields {
|
interface PartialTextBasedChannelFields {
|
||||||
lastMessageID: Snowflake | null;
|
lastMessageID: Snowflake | null;
|
||||||
readonly lastMessage: Message | null;
|
readonly lastMessage: Message | null;
|
||||||
send(
|
send(content: string | (MessageOptions & { split?: false }) | MessageAdditions): Promise<Message>;
|
||||||
content: APIMessageContentResolvable | (MessageOptions & { split?: false }) | MessageAdditions,
|
|
||||||
): Promise<Message>;
|
|
||||||
send(options: MessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
send(options: MessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
||||||
send(options: MessageOptions | APIMessage): Promise<Message | Message[]>;
|
send(options: MessageOptions | APIMessage): Promise<Message | Message[]>;
|
||||||
send(content: StringResolvable, options: (MessageOptions & { split?: false }) | MessageAdditions): Promise<Message>;
|
send(content: string | null, options: (MessageOptions & { split?: false }) | MessageAdditions): Promise<Message>;
|
||||||
send(content: StringResolvable, options: MessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
send(content: string | null, options: MessageOptions & { split: true | SplitOptions }): Promise<Message[]>;
|
||||||
send(content: StringResolvable, options: MessageOptions): Promise<Message | Message[]>;
|
send(content: string | null, options: MessageOptions): Promise<Message | Message[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
||||||
@@ -2368,7 +2362,7 @@ declare module 'discord.js' {
|
|||||||
edit(options: WebhookEditData): Promise<Webhook>;
|
edit(options: WebhookEditData): Promise<Webhook>;
|
||||||
editMessage(
|
editMessage(
|
||||||
message: MessageResolvable | '@original',
|
message: MessageResolvable | '@original',
|
||||||
content: APIMessageContentResolvable | APIMessage | MessageAdditions,
|
content: string | null | APIMessage | MessageAdditions,
|
||||||
options?: WebhookEditMessageOptions,
|
options?: WebhookEditMessageOptions,
|
||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
editMessage(
|
editMessage(
|
||||||
@@ -2377,20 +2371,20 @@ declare module 'discord.js' {
|
|||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | RawMessage>;
|
fetchMessage(message: Snowflake | '@original', cache?: boolean): Promise<Message | RawMessage>;
|
||||||
send(
|
send(
|
||||||
content: APIMessageContentResolvable | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
content: string | (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<(Message | RawMessage)[]>;
|
send(options: WebhookMessageOptions & { split: true | SplitOptions }): Promise<(Message | RawMessage)[]>;
|
||||||
send(options: WebhookMessageOptions | APIMessage): Promise<Message | RawMessage | (Message | RawMessage)[]>;
|
send(options: WebhookMessageOptions | APIMessage): Promise<Message | RawMessage | (Message | RawMessage)[]>;
|
||||||
send(
|
send(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
options: (WebhookMessageOptions & { split?: false }) | MessageAdditions,
|
||||||
): Promise<Message | RawMessage>;
|
): Promise<Message | RawMessage>;
|
||||||
send(
|
send(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: WebhookMessageOptions & { split: true | SplitOptions },
|
options: WebhookMessageOptions & { split: true | SplitOptions },
|
||||||
): Promise<(Message | RawMessage)[]>;
|
): Promise<(Message | RawMessage)[]>;
|
||||||
send(
|
send(
|
||||||
content: StringResolvable,
|
content: string | null,
|
||||||
options: WebhookMessageOptions,
|
options: WebhookMessageOptions,
|
||||||
): Promise<Message | RawMessage | (Message | RawMessage)[]>;
|
): Promise<Message | RawMessage | (Message | RawMessage)[]>;
|
||||||
sendSlackMessage(body: unknown): Promise<boolean>;
|
sendSlackMessage(body: unknown): Promise<boolean>;
|
||||||
@@ -2491,8 +2485,6 @@ declare module 'discord.js' {
|
|||||||
RESOURCE_OVERLOADED: 130000;
|
RESOURCE_OVERLOADED: 130000;
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIMessageContentResolvable = string | number | boolean | bigint | symbol | readonly StringResolvable[];
|
|
||||||
|
|
||||||
interface ApplicationAsset {
|
interface ApplicationAsset {
|
||||||
name: string;
|
name: string;
|
||||||
id: Snowflake;
|
id: Snowflake;
|
||||||
@@ -2801,8 +2793,8 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface EmbedFieldData {
|
interface EmbedFieldData {
|
||||||
name: StringResolvable;
|
name: string;
|
||||||
value: StringResolvable;
|
value: string;
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3207,7 +3199,7 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
interface MessageEditOptions {
|
interface MessageEditOptions {
|
||||||
attachments?: MessageAttachment[];
|
attachments?: MessageAttachment[];
|
||||||
content?: StringResolvable;
|
content?: string;
|
||||||
embed?: MessageEmbed | MessageEmbedOptions | null;
|
embed?: MessageEmbed | MessageEmbedOptions | null;
|
||||||
code?: string | boolean;
|
code?: string | boolean;
|
||||||
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
||||||
@@ -3303,7 +3295,7 @@ declare module 'discord.js' {
|
|||||||
interface MessageOptions {
|
interface MessageOptions {
|
||||||
tts?: boolean;
|
tts?: boolean;
|
||||||
nonce?: string | number;
|
nonce?: string | number;
|
||||||
content?: StringResolvable;
|
content?: string;
|
||||||
embed?: MessageEmbed | MessageEmbedOptions;
|
embed?: MessageEmbed | MessageEmbedOptions;
|
||||||
allowedMentions?: MessageMentionOptions;
|
allowedMentions?: MessageMentionOptions;
|
||||||
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
|
||||||
@@ -3652,8 +3644,6 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type StreamType = 'unknown' | 'converted' | 'opus' | 'ogg/opus' | 'webm/opus';
|
type StreamType = 'unknown' | 'converted' | 'opus' | 'ogg/opus' | 'webm/opus';
|
||||||
|
|
||||||
type StringResolvable = string | string[] | any;
|
|
||||||
|
|
||||||
type SystemChannelFlagsString =
|
type SystemChannelFlagsString =
|
||||||
| 'SUPPRESS_JOIN_NOTIFICATIONS'
|
| 'SUPPRESS_JOIN_NOTIFICATIONS'
|
||||||
| 'SUPPRESS_PREMIUM_SUBSCRIPTIONS'
|
| 'SUPPRESS_PREMIUM_SUBSCRIPTIONS'
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ client.on('message', ({ channel }) => {
|
|||||||
assertIsMessage(channel.send('string'));
|
assertIsMessage(channel.send('string'));
|
||||||
assertIsMessage(channel.send({}));
|
assertIsMessage(channel.send({}));
|
||||||
assertIsMessage(channel.send({ embed: {} }));
|
assertIsMessage(channel.send({ embed: {} }));
|
||||||
assertIsMessage(channel.send({ another: 'property' }, {}));
|
|
||||||
|
|
||||||
const attachment = new MessageAttachment('file.png');
|
const attachment = new MessageAttachment('file.png');
|
||||||
const embed = new MessageEmbed();
|
const embed = new MessageEmbed();
|
||||||
@@ -43,7 +42,6 @@ client.on('message', ({ channel }) => {
|
|||||||
assertIsMessage(channel.send(embed));
|
assertIsMessage(channel.send(embed));
|
||||||
assertIsMessage(channel.send([attachment, embed]));
|
assertIsMessage(channel.send([attachment, embed]));
|
||||||
|
|
||||||
assertIsMessageArray(channel.send(Symbol('another primitive'), { split: true }));
|
|
||||||
assertIsMessageArray(channel.send({ split: true }));
|
assertIsMessageArray(channel.send({ split: true }));
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
|||||||
Reference in New Issue
Block a user