Skip to content

decode message flags#718

Open
lara-rium wants to merge 5 commits into
Kraigie:masterfrom
lara-rium:message-flags
Open

decode message flags#718
lara-rium wants to merge 5 commits into
Kraigie:masterfrom
lara-rium:message-flags

Conversation

@lara-rium

Copy link
Copy Markdown
Contributor

closes #711

i looked at user flags impl and reflected those on message but some things may be missing. pls lmk upon review. also sorry ab the messy revert commits, forgot to create different branches for each pr

Copilot AI review requested due to automatic review settings March 3, 2026 18:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for exposing Discord message flags in Nostrum.Struct.Message and introduces a dedicated Nostrum.Struct.Message.Flags helper module to convert between the integer bitfield and a boolean-flag struct.

Changes:

  • Introduce Nostrum.Struct.Message.Flags with from_integer/1 and to_integer/1 helpers.
  • Add a :flags field (raw bitfield integer) to Nostrum.Struct.Message and attempt to cast it during to_struct/1 and update merges.
  • Add a message flags type to the struct typespecs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
lib/nostrum/struct/message/flags.ex New helper struct/module for converting message flags between bitfield integers and booleans.
lib/nostrum/struct/message.ex Adds :flags to the message struct and attempts to cast it during struct construction/updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/nostrum/struct/message/flags.ex Outdated
Comment thread lib/nostrum/struct/message.ex Outdated
Comment thread lib/nostrum/struct/message.ex
Comment thread lib/nostrum/struct/message.ex Outdated
Comment thread lib/nostrum/struct/message.ex Outdated
Comment thread lib/nostrum/struct/message/flags.ex
@jchristgit jchristgit self-assigned this Mar 4, 2026
@jchristgit jchristgit self-requested a review March 4, 2026 19:23

@jchristgit jchristgit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the pull request!

Clanker comments are mostly fine, to be honest. I'm positively surprised. See my comments below.

We should think about whether we want the flags field in the Message to automatically be decoded. Right now, from my understanding, they are just being kept as-is.

Comment thread lib/nostrum/struct/message/flags.ex
Comment thread lib/nostrum/struct/message/flags.ex Outdated
Comment thread lib/nostrum/struct/message/flags.ex
Comment thread lib/nostrum/struct/message.ex Outdated
Comment thread lib/nostrum/struct/message.ex
Comment thread lib/nostrum/struct/message.ex
Comment thread lib/nostrum/struct/message.ex Outdated

@lara-rium lara-rium left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should resolve all the comments, pls let me know if i need further adjustments

@lara-rium

Copy link
Copy Markdown
Contributor Author

We should think about whether we want the flags field in the Message to automatically be decoded. Right now, from my understanding, they are just being kept as-is.

i just copied over from user, which also keeps it as it is. if we wanna discuss this i think we should do it in another issue cos it'd affect other flags as well. im also not very happy with this approach bc it involves copy/pasting the same to_integer and from_integer functions

@jchristgit jchristgit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this looks good!

I think we can remove the extra test cases from flags_test.exs because as far as I can tell they are the same as the doctests. What do you think?

Other than that, LGTM :shipit: 🦀

@lara-rium

Copy link
Copy Markdown
Contributor Author

wdym by doctests? do the examples act as tests somehow?

@BrandtHill

Copy link
Copy Markdown
Contributor

doctest Flags runs all expressions following iex> and asserts the return value matches the next line.

@lara-rium

Copy link
Copy Markdown
Contributor Author

thats rly smart

@jchristgit

Copy link
Copy Markdown
Collaborator

@lara-rium could you fix conflicts, please? Thank you!

@lara-rium

Copy link
Copy Markdown
Contributor Author

done

Comment thread lib/nostrum/api/guild.ex
```
"""
@spec modify_member(Guild.id(), User.id() | :me, Api.options(), AuditLogEntry.reason()) ::
@spec modify_member(Guild.id(), User.id(), Api.options(), AuditLogEntry.reason()) ::

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to now be undoing some of your latest changes to master around the @me endpoint support, I assume this is unintentional and should get reverted.

@lara-rium lara-rium Mar 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my thinking was that this pr is solely for decoding message flags so other features i added should be reverted. this conflict should probably be fixed while merging #717 or this pr. this wouldnt have happened if i hadnt forgotten to create a sole branch for #717 but it is what it is. lmk if u dont agree w this revert

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best if you could drop these unrelated commits from the history of this branch, could you do that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, how do i do that?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the basic idea would be something like this:

  1. Start by making a backup of your branch: git checkout -b message-flags-backup, then git checkout message-flags
  2. git rebase -i master
  3. Do a local sanity check. If it's bad, git reset --hard message-flags-backup
  4. git push -f

But I'm really struggling to see which commit actually intoduces the message flag decoding without other changes. It would maybe be best if you open a new pull request with only the message flag changes cherry picked out of here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i unfortunately don't have time for this right now.. anyone else is welcome to take this on

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.

message flags aren't decoded

5 participants