Beispiel #1
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)
Beispiel #2
0
class Webhook(Model):
    id = Snowflake(required=True)
    guild_id = Snowflake()
    channel_id = Snowflake()
    name = String()
    avatar = String()
    token = String()
Beispiel #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()
Beispiel #4
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()))
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
class VoiceState(Model):
    guild_id = Snowflake()
    channel_id = Snowflake()
    user_id = Snowflake()
    session_id = String()
Beispiel #8
0
class Role(Model):
    id = Snowflake(required=True)
    name = String()
    color = Integer()
    permissions = Integer()
Beispiel #9
0
class EmbedFooter(Model):
    text = String()
    icon_url = String()
    proxy_icon_url = String()
Beispiel #10
0
class EmbedField(Model):
    name = String()
    value = String()
    inline = Boolean(default=False)
Beispiel #11
0
class EmbedAuthor(Model):
    name = String()
    url = String()
    icon_url = String()
    proxy_icon_url = String()
Beispiel #12
0
class EmbedThumbnail(Model):
    url = String()
    proxy_url = String()
    height = Integer()
    width = Integer()
Beispiel #13
0
class EmbedImage(Model):
    url = String()
    proxy_url = String()
    height = Integer()
    width = Integer()
Beispiel #14
0
class User(Model):
    id = Snowflake(required=True)
    username = String()
    discriminator = String()
    avatar = String()
Beispiel #15
0
class StreamersConfig(Model):
    announcement_message = String(max_length=1900)
    announcement_channel = Snowflake()
    hitbox_streamers = List(StreamerField())
    twitch_streamers = List(StreamerField())