Skip to content

Alter warning role verification (fix?)#400

Open
szykaro23 wants to merge 3 commits intoFederationStudios:mainfrom
szykaro23:main
Open

Alter warning role verification (fix?)#400
szykaro23 wants to merge 3 commits intoFederationStudios:mainfrom
szykaro23:main

Conversation

@szykaro23
Copy link
Copy Markdown
Contributor

Avoid casting interaction.member to GuildMemberRoleManager by fetching the full GuildMember for the user and checking member.roles.cache.has(...). This prevents runtime errors when interaction.member is partial or missing roles data and ensures an accurate authorization check. Current version seems to be causing errors, possibly by not being able to verify roles. Also removes the now unused GuildMemberRoleManager import.

Avoid casting interaction.member to GuildMemberRoleManager by fetching the full GuildMember for the user and checking member.roles.cache.has(...). This prevents runtime errors when interaction.member is partial or missing roles data and ensures an accurate authorization check for altering warnings. Also removes the now-unused GuildMemberRoleManager import.
@totallytavi

This comment was marked as outdated.

@totallytavi
Copy link
Copy Markdown
Contributor

The whole reason why I typecast to GuildMemberRoleManager is because I don't mark the CommandInteraction as "cached", which would fix these typing issues entirely. By default, TypeScript will assume the CommandInteraction is both "cached" and "raw" unless you tell it otherwise (hence <CommandInteraction>.member not always being a GuildMember since CommandInteraction<'raw'>.member is not a GuildMember)

The true solution? Update everything to CommandInteraction<'cached'>. That's a low priority though

@szykaro23 szykaro23 marked this pull request as draft April 5, 2026 16:29
@szykaro23 szykaro23 marked this pull request as ready for review April 5, 2026 16:35
@szykaro23
Copy link
Copy Markdown
Contributor Author

@totallytavi Hopefully that is what you meant, if not then let me know and I will work on it the way you want it to be 🫡

@totallytavi
Copy link
Copy Markdown
Contributor

Wait, I used ChatInputCommandInteraction? Huh. Could've sworn I did CommandInteraction. Oh well! Either way, it should work. I gotta check it personally before I sign off

@szykaro23
Copy link
Copy Markdown
Contributor Author

Bump @totallytavi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants