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:
Souji
2021-06-01 17:31:49 +02:00
committed by GitHub
parent 66a6a1fced
commit 7b85a7259f
14 changed files with 97 additions and 153 deletions

View File

@@ -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!'),
];