From b41d3b6f36f6c88872e8601f3b4892702f843693 Mon Sep 17 00:00:00 2001 From: Luna Date: Fri, 25 Oct 2019 13:39:22 -0300 Subject: [PATCH] guilds: use common, remove delete_guild() from it --- litecord/blueprints/guilds.py | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index ce2b78b..d5b9375 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -21,8 +21,7 @@ from typing import Optional, List from quart import Blueprint, request, current_app as app, jsonify -from litecord.blueprints.guild.channels import create_guild_channel -from litecord.blueprints.guild.roles import create_role, DEFAULT_EVERYONE_PERMS +from litecord.common.guilds import create_role, create_guild_channel, delete_guild from ..auth import token_check from ..snowflake import get_snowflake @@ -34,12 +33,13 @@ from ..schemas import ( SEARCH_CHANNEL, VANITY_URL_PATCH, ) -from .channels import channel_ack from .checks import guild_check, guild_owner_check, guild_perm_check +from ..common.channels import channel_ack from litecord.utils import to_update, search_result_from_list from litecord.errors import BadRequest from litecord.permissions import get_permissions +DEFAULT_EVERYONE_PERMS = 104324161 bp = Blueprint("guilds", __name__) @@ -393,34 +393,6 @@ async def _update_guild(guild_id): return jsonify(guild) -async def delete_guild(guild_id: int): - """Delete a single guild.""" - await app.db.execute( - """ - DELETE FROM guilds - WHERE guilds.id = $1 - """, - guild_id, - ) - - # Discord's client expects IDs being string - await app.dispatcher.dispatch( - "guild", - guild_id, - "GUILD_DELETE", - { - "guild_id": str(guild_id), - "id": str(guild_id), - # 'unavailable': False, - }, - ) - - # remove from the dispatcher so nobody - # becomes the little memer that tries to fuck up with - # everybody's gateway - await app.dispatcher.remove("guild", guild_id) - - @bp.route("/", methods=["DELETE"]) # this endpoint is not documented, but used by the official client. @bp.route("//delete", methods=["POST"])