Skip to content

Commit

Permalink
fix(purge): proper url check for attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
didinele committed Jul 19, 2024
1 parent 8d4f90c commit 05271d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion services/interactions/src/handlers/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default class ModHandler implements HandlerModule<CoralInteractionHandler
description: 'Ban a user',
options: baseOptionsWith({
name: 'cleanup',
description: "Delete the user's recent messages",
description: "Specify how far back to go deleting the user's messages (e.g. 8h)",
type: ApplicationCommandOptionType.String,
required: false,
}),
Expand Down
4 changes: 2 additions & 2 deletions services/interactions/src/handlers/purge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export default class PurgeHandler implements HandlerModule<CoralInteractionHandl
return true;
}

return Boolean(message.attachments.some((a) => a.url.endsWith(`.${ext}`)));
return message.attachments.some((attachment) => new URL(attachment.url).pathname.endsWith(`.${ext}`));
};

const gifExt = ['gif', 'apng'];
Expand All @@ -187,7 +187,7 @@ export default class PurgeHandler implements HandlerModule<CoralInteractionHandl
switch (media) {
case 'all': {
const allExt = [...gifExt, ...imageExt, ...videoExt];
if (!allExt.some(checkForExtension) || message.embeds.length > 0) {
if (!allExt.some(checkForExtension) && !message.embeds.length) {
return false;
}

Expand Down

0 comments on commit 05271d2

Please sign in to comment.