Closed Hype3808 closed 2 years ago
Hi, as of now we only support invariant types for data injection—covariant types are supported by #68 though, so your code should work as that gets merged. Anyway, you got 2 options here, first one is to move the callback after the class definition and pass Bot as opposed to Client to data(), e.g.,
class Bot(commands.AutoShardedBot):
...
@topgg.endpoint(...)
def dbl_vote(data: topgg.types.BotVoteData, bot: Bot = topgg.data(Bot)):
...
The second option would be to have it a method instead of a function, e.g.,
class Bot(commands.AutoShardedBot):
def __init__(self, ...):
...
(
webhook_manager.endpoint()
.type(...) # topgg.WebhookType
.route(...) # "/dbl"
.auth(...)
.callback(self.dbl_vote)
.add_to_manager()
)
def dbl_vote(self, data: topgg.BotVoteData):
...
I'm not sure why you're not getting any errors though, you should be getting a KeyError because there's no datum with the key discord.Client.
The first solution fixed my problem! Tysm!
topgg.endpoint doesn't work.
Expected Behavior
printing
topgg.types.BotVoteData
Current Behavior
No error raised. Nothing happened and printed
Development Environment
Python Version: 3.8.12 topggpy version: Master
Steps to Reproduce
Context
Possible Solution
Detailed Description
Possible Implementation
Notes
Could be my problem, could be not.