From b7f966c8c2f88c02845417c0d54a681fcfda77d0 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Sun, 18 Aug 2024 10:46:17 +0200 Subject: [PATCH] Prettier, remove manual deletion of msgs --- .../routes/guilds/#guild_id/widget.json.ts | 2 +- src/util/entities/Channel.ts | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/api/routes/guilds/#guild_id/widget.json.ts b/src/api/routes/guilds/#guild_id/widget.json.ts index 362a4a1c..12b31b88 100644 --- a/src/api/routes/guilds/#guild_id/widget.json.ts +++ b/src/api/routes/guilds/#guild_id/widget.json.ts @@ -51,7 +51,7 @@ router.get( where: { id: guild_id }, select: { channel_ordering: true, - } + }, }); if (!guild.widget_enabled) throw new HTTPError("Widget Disabled", 404); diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts index 9f19cb0d..6538b523 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts @@ -459,8 +459,6 @@ export class Channel extends BaseClass { } static async deleteChannel(channel: Channel) { - await Message.delete({ channel_id: channel.id }); //TODO we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util - //TODO before deleting the channel we should check and delete other relations await Channel.delete({ id: channel.id }); const guild = await Guild.findOneOrFail({ @@ -471,7 +469,10 @@ export class Channel extends BaseClass { const updatedOrdering = guild.channel_ordering.filter( (id) => id != channel.id, ); - await Guild.update({id: channel.guild_id}, { channel_ordering: updatedOrdering }); + await Guild.update( + { id: channel.guild_id }, + { channel_ordering: updatedOrdering }, + ); } static async calculatePosition( @@ -501,13 +502,15 @@ export class Channel extends BaseClass { ), ); - return channels.filter(channel => channel !== null).reduce((r, v) => { - v = v as Channel; + return channels + .filter((channel) => channel !== null) + .reduce((r, v) => { + v = v as Channel; - v.position = (guild as Guild).channel_ordering.indexOf(v.id); - r[v.position] = v; - return r; - }, [] as Array); + v.position = (guild as Guild).channel_ordering.indexOf(v.id); + r[v.position] = v; + return r; + }, [] as Array); } isDm() {