forked from Supositware/Haha-Yes
Handle attachment correctly
This commit is contained in:
parent
5a6119bc42
commit
3b60fee0df
1 changed files with 12 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
||||||
* Make this shit work.
|
* Make this shit work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
|
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
|
||||||
import db from '../../models/index.js';
|
import db from '../../models/index.js';
|
||||||
import { rand } from '../../utils/rand.js';
|
import { rand } from '../../utils/rand.js';
|
||||||
const ratelimit = {};
|
const ratelimit = {};
|
||||||
|
@ -369,14 +369,21 @@ export default {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const args = {};
|
const args = {};
|
||||||
|
|
||||||
const argsLength = command.data.options.length;
|
const argsLength = command.data.options.length;
|
||||||
|
|
||||||
|
command.data.options.forEach(obj => {
|
||||||
|
if (obj.type === ApplicationCommandOptionType.Attachment) {
|
||||||
|
args[obj.name] = message.attachments.first();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for (let i = 0, j = 0; i < argsLength; i++, j++) {
|
for (let i = 0, j = 0; i < argsLength; i++, j++) {
|
||||||
if (!messageArgs[i]) continue;
|
if (!messageArgs[i]) continue;
|
||||||
const arg = command.data.options[j];
|
const arg = command.data.options[j];
|
||||||
const type = arg.constructor.name.toLowerCase();
|
if (arg.type === ApplicationCommandOptionType.Attachment) continue;
|
||||||
let payloadName = arg.name;
|
let payloadName = arg.name;
|
||||||
let payload = messageArgs[i];
|
let payload = messageArgs[i];
|
||||||
|
|
||||||
if (i >= argsLength - 1) {
|
if (i >= argsLength - 1) {
|
||||||
payload = messageArgs.slice(i).join(' ');
|
payload = messageArgs.slice(i).join(' ');
|
||||||
}
|
}
|
||||||
|
@ -386,13 +393,11 @@ export default {
|
||||||
payload = true;
|
payload = true;
|
||||||
j--;
|
j--;
|
||||||
}
|
}
|
||||||
else if (type.includes('mentionable')) {
|
|
||||||
|
if (arg.type === ApplicationCommandOptionType.Mentionable) {
|
||||||
await message.guild.members.fetch();
|
await message.guild.members.fetch();
|
||||||
payload = message.mentions.members.first() ? message.mentions.members.first() : message.guild.members.cache.find(u => u.user.username.toLowerCase().includes(payload.toLowerCase()));
|
payload = message.mentions.members.first() ? message.mentions.members.first() : message.guild.members.cache.find(u => u.user.username.toLowerCase().includes(payload.toLowerCase()));
|
||||||
}
|
}
|
||||||
else if (type.includes('attachment')) {
|
|
||||||
payload = message.attachments.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
args[payloadName] = payload;
|
args[payloadName] = payload;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue