mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
Add base class. Make to_json available to all of the existing models.
This commit is contained in:
15
flask_discord/models/base.py
Normal file
15
flask_discord/models/base.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from abc import ABC
|
||||
|
||||
|
||||
class DiscordModelsBase(ABC):
|
||||
|
||||
def to_json(self):
|
||||
"""A utility method which returns raw payload object as it was received from discord.
|
||||
|
||||
Returns
|
||||
-------
|
||||
dict
|
||||
A dict representing raw payload object received from discord.
|
||||
|
||||
"""
|
||||
return self._payload
|
||||
@@ -1,7 +1,9 @@
|
||||
from .base import DiscordModelsBase
|
||||
|
||||
from .user import User
|
||||
|
||||
|
||||
class Integration(object):
|
||||
class Integration(DiscordModelsBase):
|
||||
""""Class representing discord server integrations.
|
||||
|
||||
Attributes
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from .base import DiscordModelsBase
|
||||
|
||||
from .. import configs
|
||||
|
||||
|
||||
class Guild(object):
|
||||
class Guild(DiscordModelsBase):
|
||||
"""Class representing discord Guild the user is part of.
|
||||
|
||||
Attributes
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from .base import DiscordModelsBase
|
||||
|
||||
from .. import configs
|
||||
|
||||
|
||||
class User(object):
|
||||
class User(DiscordModelsBase):
|
||||
"""Class representing Discord User.
|
||||
|
||||
Attributes
|
||||
@@ -65,16 +67,6 @@ class User(object):
|
||||
"""A boolean representing if avatar of user is animated. Meaning user has GIF avatar."""
|
||||
return self.avatar_hash.startswith("a_")
|
||||
|
||||
def to_json(self):
|
||||
"""A utility method which returns raw user object as it was returned from discord.
|
||||
|
||||
Returns
|
||||
-------
|
||||
dict
|
||||
A dict of user's document.
|
||||
"""
|
||||
return self._payload
|
||||
|
||||
|
||||
class Bot(User):
|
||||
"""Class representing the client user itself.
|
||||
|
||||
Reference in New Issue
Block a user