guilds: use common, remove delete_guild() from it

This commit is contained in:
Luna 2019-10-25 13:39:22 -03:00
parent 2ebb94f476
commit b41d3b6f36
1 changed files with 3 additions and 31 deletions

View File

@ -21,8 +21,7 @@ from typing import Optional, List
from quart import Blueprint, request, current_app as app, jsonify from quart import Blueprint, request, current_app as app, jsonify
from litecord.blueprints.guild.channels import create_guild_channel from litecord.common.guilds import create_role, create_guild_channel, delete_guild
from litecord.blueprints.guild.roles import create_role, DEFAULT_EVERYONE_PERMS
from ..auth import token_check from ..auth import token_check
from ..snowflake import get_snowflake from ..snowflake import get_snowflake
@ -34,12 +33,13 @@ from ..schemas import (
SEARCH_CHANNEL, SEARCH_CHANNEL,
VANITY_URL_PATCH, VANITY_URL_PATCH,
) )
from .channels import channel_ack
from .checks import guild_check, guild_owner_check, guild_perm_check 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.utils import to_update, search_result_from_list
from litecord.errors import BadRequest from litecord.errors import BadRequest
from litecord.permissions import get_permissions from litecord.permissions import get_permissions
DEFAULT_EVERYONE_PERMS = 104324161
bp = Blueprint("guilds", __name__) bp = Blueprint("guilds", __name__)
@ -393,34 +393,6 @@ async def _update_guild(guild_id):
return jsonify(guild) 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("/<int:guild_id>", methods=["DELETE"]) @bp.route("/<int:guild_id>", methods=["DELETE"])
# this endpoint is not documented, but used by the official client. # this endpoint is not documented, but used by the official client.
@bp.route("/<int:guild_id>/delete", methods=["POST"]) @bp.route("/<int:guild_id>/delete", methods=["POST"])