mineral-dart / core

🧡 The neuralgic heart of the application, this module gathers all the functionalities of the framework.
https://mineral-foundation.org
MIT License
27 stars 8 forks source link

Button interaction internal builder misused #64

Closed helomri closed 2 years ago

helomri commented 2 years ago

Hello, I recently started using the library and wanted to use the button interaction API but when I wanted to handle the button I got an error:

Unhandled exception:
type 'Null' is not a subtype of type 'String'
#0      new ButtonInteraction.from (package:mineral/src/api/interactions/button_interaction.dart:37:14)
#1      InteractionCreate._executeButtonInteraction (package:mineral/src/internal/websockets/packets/interaction_create.dart:141:61)
<asynchronous suspension>

So to address this issue I think that we should just change this constructor from

 return ButtonInteraction(
      payload['id'],
      payload['application_id'],
      payload['version'],
      payload['type'],
      payload['token'],
      payload['member']?['user']?['id'],
      payload['guild_id'],
      payload['message_id'],
      payload['data']['custom_id'],
      payload['channel_id'],
    );

to

 return ButtonInteraction(
      payload['id'],
      payload['application_id'],
      payload['version'],
      payload['type'],
      payload['token'],
      payload['member']?['user']?['id'],
      payload['guild_id'],
      payload['id'],
      payload['data']['custom_id'],
      payload['channel_id'],
    );
vic256 commented 2 years ago

Hello, We fixed this some time ago, it will be available in a future release. Meanwhile, you can replace payload['message_id'] with payload['message']?['id'].

helomri commented 2 years ago

Thanks for the information !