Exemplo n.º 1
0
class Guild(Model):
    id = Snowflake(required=True)
    name = String()
    owner_id = Snowflake()
    roles = List(ModelField(Role))
    channels = List(ModelField(Channel))

    def __init__(self, **kwargs):
        self.db = kwargs.get('db')
        self.plugin = kwargs.get('plugin')
        super(Guild, self).__init__(**kwargs)

    @property
    def members(self):
        pass

    @property
    def config(self):
        return self.plugin.get_config(self)

    @property
    def storage(self):
        return self.plugin.get_guild_storage(self)

    @property
    def voice_channels(self):
        return [c for c in self.channels if c.type == 2]

    @property
    def text_channels(self):
        return [c for c in self.channels if c.type == 0]

    def __repr__(self):
        return "<Guild id={} name={}>".format(self.id, self.name)
Exemplo n.º 2
0
class Webhook(Model):
    id = Snowflake(required=True)
    guild_id = Snowflake()
    channel_id = Snowflake()
    name = String()
    avatar = String()
    token = String()
Exemplo n.º 3
0
class Message(Model):
    id = Snowflake(required=True)
    channel_id = Snowflake()
    content = String()
    timestamp = String()
    edited_timestamp = String()
    author = ModelField(User)
    webhook_id = Snowflake()
Exemplo n.º 4
0
class Member(Model):
    user = ModelField(User)
    guild_permissions = Integer(default=0)
    nick = String()
    roles = List(Snowflake())
    joined_at = String()
    voice_state = ModelField(VoiceState)

    def get_voice_channel(self, guild):
        if not self.voice_state:
            return None

        if not self.voice_state.channel_id:
            return None

        for vc in guild.voice_channels:
            if vc.id == self.voice_state.channel_id:
                return vc

        return None

    @property
    def mention(self):
        return '<@{}>'.format(self.id)

    def get_permissions(self, guild):
        roles = [role for role in guild.roles if role.id in self.roles]
        return sum(role.permissions for role in roles)

    def __repr__(self):
        return "<Member id={} name={}>".format(self.user.id,
                                               self.user.username)
Exemplo n.º 5
0
class Channel(Model):
    id = Snowflake(required=True)
    name = String()
    type = Integer()
    position = Integer()

    @property
    def mention(self):
        return '<#{}>'.format(self.id)

    def __repr__(self):
        return "<Channel id={} name={}>".format(self.id, self.name)
Exemplo n.º 6
0
class VoiceState(Model):
    guild_id = Snowflake()
    channel_id = Snowflake()
    user_id = Snowflake()
    session_id = String()
Exemplo n.º 7
0
class Role(Model):
    id = Snowflake(required=True)
    name = String()
    color = Integer()
    permissions = Integer()
Exemplo n.º 8
0
class CommandConfig(Model):
    enabled = Boolean(required=True, default=True)
    global_cooldown = Cooldown()
    personal_cooldown = Cooldown()
    allowed_roles = List(Snowflake())
Exemplo n.º 9
0
class User(Model):
    id = Snowflake(required=True)
    username = String()
    discriminator = String()
    avatar = String()
Exemplo n.º 10
0
class RedditConfig(Model):
    subreddits = List(SubredditField())
    announcement_channel = Snowflake()
Exemplo n.º 11
0
class StreamersConfig(Model):
    announcement_message = String(max_length=1900)
    announcement_channel = Snowflake()
    hitbox_streamers = List(StreamerField())
    twitch_streamers = List(StreamerField())