disnake icon indicating copy to clipboard operation
disnake copied to clipboard

refactor!(activity): improve typing, remove redundancies, fix `Spotify` fields raising errors

Open shiftinv opened this issue 3 years ago • 0 comments

Summary

Changes:

  • Improve activity deserialization typing by explicitly specifying kwargs in __init__s (no PEP 692 yet :/ )
  • Move created_at and timestamp properties start, end into common base class
    • This notably changes Spotify.start/.end/.duration to optional, fixing an edge case as reported here
  • Fix Activity.buttons type, data received over gateway only contains button labels
  • Default to activity type 0 (= ActivityType.playing) instead of -1 if not provided; previously, the API would silently discard presence updates with disnake.Activity(name=...) without a type as activity type -1 is unknown

Checklist

  • [x] If code changes were made, then they have been tested
    • [x] I have updated the documentation to reflect the changes
    • [x] I have formatted the code properly by running task lint
    • [x] I have type-checked the code by running task pyright
  • [x] This PR fixes an issue
  • [ ] This PR adds something new (e.g. new method or parameters)
  • [x] This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • [ ] This PR is not a code change (e.g. documentation, README, ...)

shiftinv avatar Aug 02 '22 18:08 shiftinv