breqdev/flask-discord-interactions

Couldn't handle select menu

doesnmisclown opened this issue ยท 2 comments

Describe the bug
A clear and concise description of what the bug is.
Couldn't handle select menu. After select option raises this error

4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/context.py", line 153, in from_data
4|wh       |     result.parse_message(data)
4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/context.py", line 197, in parse_message
4|wh       |     self.message = Message.from_dict(data["message"])
4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/models/utils.py", line 16, in from_dict
4|wh       |     return cls(
4|wh       |   File "<string>", line 19, in __init__
4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/models/message.py", line 121, in __post_init__
4|wh       |     self.author = Member.from_dict(self.author)
4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/models/user.py", line 43, in from_dict
4|wh       |     return super().from_dict(data)
4|wh       |   File "/usr/local/lib/python3.9/dist-packages/flask_discord_interactions/models/utils.py", line 16, in from_dict
4|wh       |     return cls(
4|wh       | TypeError: __init__() missing 1 required positional argument: 'public_flags'

Categorization
This issue impacts...

  • The library itself
  • Documentation
  • Examples

To Reproduce
Steps to reproduce the behavior:

  1. ...
    Run this code
@discord.command(name="quiz")
def quiz(ctx):
    emojis = ["๐Ÿ”บ", "๐Ÿ”ท", "๐ŸŸก", "๐ŸŸฉ"]
    def get_quiz():
        q = random.choice(questions)
        random.shuffle(q["answers"])
        select = SelectMenu(
            placeholder=f'{questions.index(q)}. {q["question"]}',
            custom_id=handle_quiz_answer,
            options=[
                SelectMenuOption(
                    label=i,
                    value=f'{questions.index(q)}:{q["answers"].index(i)}',
                    emoji={"name": emojis[q["answers"].index(i)]},
                )
                for i in q["answers"]
            ],
            max_values=1,
        )
        return ctx.edit(Message(components=[ActionRow(components=[select])],update=True))

Expected behavior
A clear and concise description of what you expected to happen.
After select option run handle_quiz_answer
Environment
I am using... (check any that apply, leave unchecked if you don't know)

  • Quart and/or Asyncio
  • A "Bot User"
  • Additional Flask extensions (SQLAlchemy, Flask-CORS, etc.)
  • Additional backend services (Redis, RQ, Celery)

Additional context
Add any other context about the problem here.

Thanks for reporting this issue!

It looks like Discord is inconsistent as to when they send the public_flags field with the message author info, and this library has been treating it as required since #118 was merged. I've marked that field as optional, and I'll push out a new release shortly.

Let me know if the issue persists!

My issue is solved, thanks!