Example #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)
Example #2
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)
Example #3
0
class MessageEmbed(Model):
    title = String()
    description = String()
    url = String()
    color = Integer()
    footer = ModelField(EmbedFooter())
    image = ModelField(EmbedImage())
    thumbnail = ModelField(EmbedThumbnail())
    author = ModelField(EmbedAuthor())
    fields = List(ModelField(EmbedField()))
Example #4
0
class CommandConfig(Model):
    enabled = Boolean(required=True, default=True)
    global_cooldown = Cooldown()
    personal_cooldown = Cooldown()
    allowed_roles = List(Snowflake())
Example #5
0
class RedditConfig(Model):
    subreddits = List(SubredditField())
    announcement_channel = Snowflake()
Example #6
0
class StreamersConfig(Model):
    announcement_message = String(max_length=1900)
    announcement_channel = Snowflake()
    hitbox_streamers = List(StreamerField())
    twitch_streamers = List(StreamerField())