11 changed files with 336 additions and 10 deletions
@ -0,0 +1,5 @@ |
|||||
|
from disco.types.channel import Channel |
||||
|
from disco.types.guild import Guild, GuildMember, Role |
||||
|
from disco.types.user import User |
||||
|
from disco.types.message import Message |
||||
|
from disco.types.voice import VoiceState |
@ -0,0 +1,42 @@ |
|||||
|
import skema |
||||
|
|
||||
|
from holster.enum import Enum |
||||
|
|
||||
|
# from disco.types.guild import Guild |
||||
|
from disco.types.user import User |
||||
|
|
||||
|
|
||||
|
ChannelType = Enum( |
||||
|
GUILD_TEXT=0, |
||||
|
DM=1, |
||||
|
GUILD_VOICE=2, |
||||
|
GROUP_DM=3, |
||||
|
) |
||||
|
|
||||
|
PermissionOverwriteType = Enum( |
||||
|
ROLE='role', |
||||
|
MEMBER='member' |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class PermissionOverwrite(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
type = skema.StringType(choices=PermissionOverwriteType.ALL_VALUES) |
||||
|
|
||||
|
allow = skema.IntType() |
||||
|
deny = skema.IntType() |
||||
|
|
||||
|
|
||||
|
class Channel(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
|
||||
|
name = skema.StringType() |
||||
|
topic = skema.StringType() |
||||
|
last_message_id = skema.SnowflakeType() |
||||
|
position = skema.IntType() |
||||
|
bitrate = skema.IntType(required=False) |
||||
|
|
||||
|
recipient = skema.ModelType(User, required=False) |
||||
|
type = skema.IntType(choices=ChannelType.ALL_VALUES) |
||||
|
|
||||
|
permission_overwrites = skema.ListType(skema.ModelType(PermissionOverwrite)) |
@ -1,7 +1,58 @@ |
|||||
import skema |
import skema |
||||
|
|
||||
from disco.util.oop import TypedClass |
from disco.util.types import PreHookType |
||||
|
from disco.types.user import User |
||||
|
from disco.types.voice import VoiceState |
||||
|
from disco.types.channel import Channel |
||||
|
|
||||
|
|
||||
|
class Emoji(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
name = skema.StringType() |
||||
|
require_colons = skema.BooleanType() |
||||
|
managed = skema.BooleanType() |
||||
|
roles = skema.ListType(skema.SnowflakeType()) |
||||
|
|
||||
|
|
||||
|
class Role(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
name = skema.StringType() |
||||
|
hoist = skema.BooleanType() |
||||
|
managed = skema.BooleanType() |
||||
|
color = skema.IntType() |
||||
|
permissions = skema.IntType() |
||||
|
position = skema.IntType() |
||||
|
|
||||
|
|
||||
|
class GuildMember(skema.Model): |
||||
|
user = skema.ModelType(User) |
||||
|
mute = skema.BooleanType() |
||||
|
deaf = skema.BooleanType() |
||||
|
joined_at = PreHookType(lambda k: k[:-6], skema.DateTimeType()) |
||||
|
roles = skema.ListType(skema.SnowflakeType()) |
||||
|
|
||||
|
|
||||
class Guild(skema.Model): |
class Guild(skema.Model): |
||||
id = skema.SnowflakeType() |
id = skema.SnowflakeType() |
||||
|
|
||||
|
owner_id = skema.SnowflakeType() |
||||
|
afk_channel_id = skema.SnowflakeType() |
||||
|
embed_channel_id = skema.SnowflakeType() |
||||
|
|
||||
|
name = skema.StringType() |
||||
|
icon = skema.BinaryType(None) |
||||
|
splash = skema.BinaryType(None) |
||||
|
region = skema.StringType() |
||||
|
|
||||
|
afk_timeout = skema.IntType() |
||||
|
embed_enabled = skema.BooleanType() |
||||
|
verification_level = skema.IntType() |
||||
|
mfa_level = skema.IntType() |
||||
|
|
||||
|
features = skema.ListType(skema.StringType()) |
||||
|
|
||||
|
members = skema.ListType(skema.ModelType(GuildMember)) |
||||
|
voice_states = skema.ListType(skema.ModelType(VoiceState)) |
||||
|
channels = skema.ListType(skema.ModelType(Channel)) |
||||
|
roles = skema.ListType(skema.ModelType(Role)) |
||||
|
emojis = skema.ListType(skema.ModelType(Emoji)) |
||||
|
@ -0,0 +1,44 @@ |
|||||
|
import skema |
||||
|
|
||||
|
from disco.util.types import PreHookType |
||||
|
from disco.types.user import User |
||||
|
|
||||
|
|
||||
|
class MessageEmbed(skema.Model): |
||||
|
title = skema.StringType() |
||||
|
type = skema.StringType() |
||||
|
description = skema.StringType() |
||||
|
url = skema.StringType() |
||||
|
|
||||
|
|
||||
|
class MessageAttachment(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
filename = skema.StringType() |
||||
|
url = skema.StringType() |
||||
|
proxy_url = skema.StringType() |
||||
|
size = skema.IntType() |
||||
|
height = skema.IntType() |
||||
|
width = skema.IntType() |
||||
|
|
||||
|
|
||||
|
class Message(skema.Model): |
||||
|
id = skema.SnowflakeType() |
||||
|
channel_id = skema.SnowflakeType() |
||||
|
|
||||
|
author = skema.ModelType(User) |
||||
|
content = skema.StringType() |
||||
|
nonce = skema.StringType() |
||||
|
|
||||
|
timestamp = PreHookType(lambda k: k[:-6], skema.DateTimeType()) |
||||
|
edited_timestamp = PreHookType(lambda k: k[:-6], skema.DateTimeType()) |
||||
|
|
||||
|
tts = skema.BooleanType() |
||||
|
mention_everyone = skema.BooleanType() |
||||
|
|
||||
|
pinned = skema.BooleanType(required=False) |
||||
|
|
||||
|
mentions = skema.ListType(skema.ModelType(User)) |
||||
|
mention_roles = skema.ListType(skema.SnowflakeType()) |
||||
|
|
||||
|
embeds = skema.ListType(skema.ModelType(MessageEmbed)) |
||||
|
attachment = skema.ListType(skema.ModelType(MessageAttachment)) |
@ -0,0 +1,5 @@ |
|||||
|
import skema |
||||
|
|
||||
|
|
||||
|
class VoiceState(skema.Model): |
||||
|
id = skema.SnowflakeType() |
@ -0,0 +1,18 @@ |
|||||
|
from skema import BaseType |
||||
|
|
||||
|
|
||||
|
class PreHookType(BaseType): |
||||
|
_hashable = False |
||||
|
|
||||
|
def __init__(self, func, field, **kwargs): |
||||
|
self.func = func |
||||
|
self.field = field |
||||
|
|
||||
|
super(PreHookType, self).__init__(**kwargs) |
||||
|
|
||||
|
def to_python(self, value): |
||||
|
value = self.func(value) |
||||
|
return self.field.to_python(value) |
||||
|
|
||||
|
def to_storage(self, *args, **kwargs): |
||||
|
return self.field.to_storage(*args, **kwargs) |
Loading…
Reference in new issue