fix: make /ban ignore target input when targetting by reply
This commit is contained in:
parent
9b3eaa6752
commit
96a0d2b7c8
2 changed files with 14 additions and 15 deletions
|
@ -31,7 +31,7 @@ export default {
|
||||||
] });
|
] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userInput = args.shift() || '';
|
const userInput = !message.reply_ids?.length ? args.shift() || '' : undefined;
|
||||||
if (!userInput && !message.reply_ids?.length) return message.reply({ embeds: [
|
if (!userInput && !message.reply_ids?.length) return message.reply({ embeds: [
|
||||||
embed(
|
embed(
|
||||||
`Please specify one or more users by replying to their message while running this command or ` +
|
`Please specify one or more users by replying to their message while running this command or ` +
|
||||||
|
@ -78,25 +78,19 @@ export default {
|
||||||
const targetUsers: User|{ _id: string }[] = [];
|
const targetUsers: User|{ _id: string }[] = [];
|
||||||
|
|
||||||
const targetInput = dedupeArray(
|
const targetInput = dedupeArray(
|
||||||
// Replied messages
|
message.reply_ids?.length
|
||||||
(await Promise.allSettled(
|
? (await Promise.allSettled(
|
||||||
(message.reply_ids ?? []).map(msg => message.channel?.fetchMessage(msg))
|
message.reply_ids.map(msg => message.channel?.fetchMessage(msg))
|
||||||
))
|
))
|
||||||
.filter(m => m.status == 'fulfilled').map(m => (m as any).value.author_id),
|
.filter(m => m.status == 'fulfilled').map(m => (m as any).value.author_id)
|
||||||
// Provided users
|
: userInput!.split(','),
|
||||||
userInput.split(','),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const userStr of targetInput) {
|
for (const userStr of targetInput) {
|
||||||
try {
|
try {
|
||||||
let user = await parseUserOrId(userStr);
|
let user = await parseUserOrId(userStr);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
if (message.reply_ids?.length && userStr == userInput) {
|
|
||||||
reason = reason ? `${userInput} ${reason}` : userInput;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
embeds.push(embed(`I can't resolve \`${sanitizeMessageContent(userStr).trim()}\` to a user.`, null, '#ff785d'));
|
embeds.push(embed(`I can't resolve \`${sanitizeMessageContent(userStr).trim()}\` to a user.`, null, '#ff785d'));
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +169,7 @@ export default {
|
||||||
colour: EmbedColor.Success,
|
colour: EmbedColor.Success,
|
||||||
description: `This is ${userWarnCount == 1 ? '**the first infraction**' : `infraction number **${userWarnCount}**`}` +
|
description: `This is ${userWarnCount == 1 ? '**the first infraction**' : `infraction number **${userWarnCount}**`}` +
|
||||||
` for ${await fetchUsername(user._id)}.\n` +
|
` for ${await fetchUsername(user._id)}.\n` +
|
||||||
|
`**User ID:** \`${user._id}\`\n` +
|
||||||
`**Infraction ID:** \`${infraction._id}\`\n` +
|
`**Infraction ID:** \`${infraction._id}\`\n` +
|
||||||
`**Reason:** \`${infraction.reason}\``
|
`**Reason:** \`${infraction.reason}\``
|
||||||
});
|
});
|
||||||
|
@ -222,7 +217,8 @@ export default {
|
||||||
colour: EmbedColor.Success,
|
colour: EmbedColor.Success,
|
||||||
description: `This is ${userWarnCount == 1 ? '**the first infraction**' : `infraction number **${userWarnCount}**`}` +
|
description: `This is ${userWarnCount == 1 ? '**the first infraction**' : `infraction number **${userWarnCount}**`}` +
|
||||||
` for ${await fetchUsername(user._id)}.\n` +
|
` for ${await fetchUsername(user._id)}.\n` +
|
||||||
`**Ban duration:** ` +
|
`**Ban duration:** ${banDurationFancy}\n` +
|
||||||
|
`**User ID:** \`${user._id}\`\n` +
|
||||||
`**Infraction ID:** \`${infraction._id}\`\n` +
|
`**Infraction ID:** \`${infraction._id}\`\n` +
|
||||||
`**Reason:** \`${infraction.reason}\``
|
`**Reason:** \`${infraction.reason}\``
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,9 @@ class Infraction {
|
||||||
user: string;
|
user: string;
|
||||||
createdBy: string|null;
|
createdBy: string|null;
|
||||||
server: string;
|
server: string;
|
||||||
|
channel?: string;
|
||||||
|
message?: string;
|
||||||
|
targetMessages?: string[];
|
||||||
reason: string;
|
reason: string;
|
||||||
date: number;
|
date: number;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue