mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16: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:
@@ -9,7 +9,6 @@ const { Client, Intents, MessageAttachment, MessageEmbed } = require('../src');
|
||||
|
||||
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 read = util.promisify(fs.readFile);
|
||||
const readStream = fs.createReadStream;
|
||||
@@ -24,16 +23,11 @@ const attach = (attachment, name) => new MessageAttachment(attachment, name);
|
||||
|
||||
const tests = [
|
||||
m => m.channel.send('x'),
|
||||
m => m.channel.send(['x', 'y']),
|
||||
|
||||
m => m.channel.send('x', { code: true }),
|
||||
m => m.channel.send('1', { code: 'js' }),
|
||||
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({ embed: { description: 'a' } }),
|
||||
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().setDescription('a')).then(m2 => m2.edit({ embed: null })),
|
||||
|
||||
m => m.channel.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
||||
m => m.channel.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
||||
m => m.channel.send('x', [embed().setDescription('a'), attach(linkB)]),
|
||||
m => m.channel.send('x', [attach(linkA), attach(linkB)]),
|
||||
|
||||
m => m.channel.send([embed().setDescription('a'), attach(linkB)]),
|
||||
m =>
|
||||
@@ -83,37 +77,14 @@ const tests = [
|
||||
.setImage('attachment://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({ files: [fileA] }),
|
||||
m => m.channel.send(attach(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({ files: [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!'),
|
||||
];
|
||||
|
||||
@@ -58,7 +58,7 @@ client.on('message', m => {
|
||||
m.channel.send(com, { code: true });
|
||||
} catch (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 fill = c => Array(4).fill(c.repeat(1000));
|
||||
const buffer = l => fetch(l).then(res => res.buffer());
|
||||
const read = util.promisify(fs.readFile);
|
||||
const readStream = fs.createReadStream;
|
||||
@@ -24,16 +23,10 @@ const attach = (attachment, name) => new MessageAttachment(attachment, name);
|
||||
|
||||
const tests = [
|
||||
(m, hook) => hook.send('x'),
|
||||
(m, hook) => hook.send(['x', 'y']),
|
||||
|
||||
(m, hook) => hook.send('x', { code: true }),
|
||||
(m, hook) => hook.send('1', { code: 'js' }),
|
||||
(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({ files: [{ attachment: linkA }] }),
|
||||
(m, hook) =>
|
||||
@@ -61,8 +54,8 @@ const tests = [
|
||||
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
||||
(m, hook) => hook.send(embed().setDescription('a')),
|
||||
|
||||
(m, hook) => hook.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
||||
(m, hook) => hook.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
||||
(m, hook) => hook.send('x', [embed().setDescription('a'), attach(linkB)]),
|
||||
(m, hook) => hook.send('x', [attach(linkA), attach(linkB)]),
|
||||
|
||||
(m, hook) => hook.send([embed().setDescription('a'), attach(linkB)]),
|
||||
(m, hook) =>
|
||||
@@ -93,25 +86,10 @@ const tests = [
|
||||
(m, hook) => hook.send({ files: [fileA] }),
|
||||
(m, hook) => hook.send(attach(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({ files: [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!'),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user