diff --git a/litecord/blueprints/channels.py b/litecord/blueprints/channels.py index 2832aa1..795ddfb 100644 --- a/litecord/blueprints/channels.py +++ b/litecord/blueprints/channels.py @@ -23,8 +23,8 @@ async def channel_check(user_id, channel_id): if ctype is None: raise ChannelNotFound(f'channel type not found') - if ctype in (ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE, - ChannelType.GUILD_CATEGORY): + if ChannelType(ctype) in (ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE, + ChannelType.GUILD_CATEGORY): guild_id = await app.db.fetchval(""" SELECT guild_id FROM guild_channels @@ -116,7 +116,7 @@ async def create_message(channel_id): j.get('tts', False), '@everyone' in j['content'], int(j.get('nonce', 0)), - MessageType.DEFAULT + MessageType.DEFAULT.value ) # TODO: dispatch_channel diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 28e24dc..c8daca0 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -69,7 +69,7 @@ async def create_guild(): await app.db.execute(""" INSERT INTO channels (id, channel_type) VALUES ($1, $2) - """, general_id, ChannelType.GUILD_TEXT) + """, general_id, ChannelType.GUILD_TEXT.value) await app.db.execute(""" INSERT INTO guild_channels (id, guild_id, name, position) @@ -211,6 +211,8 @@ async def create_channel(guild_id): new_channel_id = get_snowflake() channel_type = j.get('type', ChannelType.GUILD_TEXT) + channel_type = ChannelType(channel_type) + if channel_type not in (ChannelType.GUILD_TEXT, ChannelType.GUILD_VOICE): raise BadRequest('Invalid channel type') @@ -218,7 +220,7 @@ async def create_channel(guild_id): await app.db.execute(""" INSERT INTO channels (id, channel_type) VALUES ($1, $2) - """, new_channel_id, channel_type) + """, new_channel_id, channel_type.value) max_pos = await app.db.fetch(""" SELECT MAX(position)