New module: Message-Quotes#196
Conversation
|
A description and an icon for the dashboard are missing. |
SCDerox
left a comment
There was a problem hiding this comment.
Hey @JeanCoding16 👋 thanks a lot for this - a quotes module has been one of the most-requested features on the board, and you clearly put real care into it: the config surface is thoughtful, the permission checks on the target channel are a nice touch, and the attachment/reply/delete options cover a lot of real use-cases. Really appreciate the contribution. 🙌
I went through it in depth and left inline comments. Heads up: this was an AI-assisted review, so a human has sanity-checked the important points, but please push back on anything that looks off - a few are judgment calls rather than hard rules.
There's one security issue I'd consider a blocker before merge, plus a handful of smaller must-fixes, some "would be great to have" config ideas, and a few typos. Grouped overview:
🔴 Must-fix before merge
- Cross-channel info disclosure (security): the bot checks whether it can read the linked channel, but not whether the user who pasted the link can. Right now any member can paste a link to a staff/ticket/mod channel and have its contents reposted into a public channel. This is the big one - details inline.
- Mention re-pinging (security): quoted content can fire live
@role/@userpings (and@everyoneon the reply path). Suppress mentions on both send paths. - Broken icon:
fas fa-chatisn't a valid icon and won't render. - Expiring image links: quoted images use raw Discord CDN URLs that 404 after a few hours.
- Crash if the config arrays aren't set yet (first boot before defaults persist).
🟡 Should-fix / robustness
- No rate-limit or cooldown - a single user can spam quotes and burn the bot's API budget.
- Silent failure when "delete trigger" is on but the bot lacks Manage Messages (no log).
- Attachment forwarding has no count/size cap.
- Empty
>>>blockquote when quoting an image-only message.
🟢 Nice-to-have config ideas (totally your call - the module works without these)
- A channel allow-list (not just blacklist), a
selfQuotetoggle, a per-user cooldown, and an optional trigger keyword so quoting is opt-in rather than firing on every link. These mirror what ourstarboardmodule offers. - Surfacing the original message's timestamp in the default embed, and exposing the author's server nickname + a channel mention as params.
✍️ Typos / copy (these show up in the dashboard, so worth a quick pass) - flagged inline.
Thanks again - this is genuinely close, and the security fix aside it's mostly polish. Happy to clarify any of the comments. 🚀
| }); | ||
| } | ||
|
|
||
| const firstAttachment = targetMsg.attachments.first()?.url || ''; |
There was a problem hiding this comment.
🔴 attachments.first()?.url is a raw Discord CDN URL with an expiry token - the image will 404 within a few hours, so quoted-image embeds break. Our starboard module handles this with archiveDiscordAttachment() (persistent storage) plus a regex fallback that scans message content for image URLs. Worth mirroring that here.
|
One more pointer @JeanCoding16 - while you're tweaking |
|
I've changed the points mentioned. I can't view this page; I'm missing the flag: https://scnx.app/developers/configuration. And regarding |
|
Thanks for the quick turnaround @JeanCoding16. The two security fixes (the member permission check and On the persistent images - this is simpler than it looked, so I don't think you need to leave it out.
let finalImage = '';
const firstAttachment = targetMsg.attachments.first();
if (firstAttachment) {
finalImage = await archiveDiscordAttachment(client, firstAttachment.url, {
displayName: `Quote by ${formatDiscordUserName(targetMsg.author)} in #${targetChannel.name}`.slice(0, 100),
tags: ['message-quotes'],
uploaderDiscordID: targetMsg.author.id
});
} else {
// covers messages that are just a pasted image link
const imgMatch = targetMsg.content.match(/https?:\/\/\S+\.(?:png|jpe?g|gif|webp)/i);
if (imgMatch) finalImage = imgMatch[0];
}That also covers messages that are just a pasted image link with no attachment. On the cooldown, one thing to check: Smaller stuff:
Also, you should have access to the config preview docs now (https://scnx.app/developers/configuration), so previewing the new param and copy changes should work. Sorry about the flag gap earlier. The |
…ixed and parameter %displayName% added to configuration
|
Fixed. I haven't found anything yet on how to replace the footer timestamp with %timestamp%, so it's still not included. |
A quotes module that is extensively customizable. Aligned with the following suggestions:
Featuring the following capabilities:
Notes: The "Include attachments" option forwards images, videos, and GIFs; this may potentially require more granular filtering in the future.