mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Using a traditional for loop rather than a for in loop for options.files (#1461)
This commit is contained in:
@@ -105,14 +105,22 @@ class Webhook {
|
||||
options = {};
|
||||
}
|
||||
if (options.file) {
|
||||
if (typeof options.file === 'string') options.file = { attachment: options.file };
|
||||
if (!options.file.name) {
|
||||
if (typeof options.file.attachment === 'string') {
|
||||
options.file.name = path.basename(options.file.attachment);
|
||||
} else if (options.file.attachment && options.file.attachment.path) {
|
||||
options.file.name = path.basename(options.file.attachment.path);
|
||||
} else {
|
||||
options.file.name = 'file.jpg';
|
||||
if (options.files) options.files.push(options.file);
|
||||
else options.files = [options.file];
|
||||
}
|
||||
|
||||
if (options.files) {
|
||||
for (let i = 0; i < options.files.length; i++) {
|
||||
let file = options.files[i];
|
||||
if (typeof file === 'string') file = { attachment: file };
|
||||
if (!file.name) {
|
||||
if (typeof file.attachment === 'string') {
|
||||
file.name = path.basename(file.attachment);
|
||||
} else if (file.attachment && file.attachment.path) {
|
||||
file.name = path.basename(file.attachment.path);
|
||||
} else {
|
||||
file.name = 'file.jpg';
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.client.resolver.resolveBuffer(options.file.attachment).then(file =>
|
||||
|
||||
@@ -88,7 +88,7 @@ class TextBasedChannel {
|
||||
}
|
||||
|
||||
if (options.files) {
|
||||
for (const i in options.files) {
|
||||
for (let i = 0; i < options.files.length; i++) {
|
||||
let file = options.files[i];
|
||||
if (typeof file === 'string') file = { attachment: file };
|
||||
if (!file.name) {
|
||||
|
||||
Reference in New Issue
Block a user