From 7d936efb2f37db42c3e57ee9a915ed4d5ab8e25f Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 27 Aug 2022 05:18:48 +0200 Subject: Cleanup, reformat, fix some todos, git hook fixup! Cleanup, reformat, fix some todos, git hook --- src/api/util/handlers/Message.ts | 21 ++++++++++----------- src/api/util/handlers/Voice.ts | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/api/util/handlers') diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 07ed11ad..5237b26a 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -18,16 +18,11 @@ import { MessageType, MessageUpdateEvent, OrmUtils, + PluginEventHandler, + PreMessageEventArgs, Role, ROLE_MENTION, User, - Application, - Webhook, - Attachment, - Config, - MessageCreateSchema, - PluginEventHandler, - PreMessageEventArgs, USER_MENTION, Webhook } from "@fosscord/util"; @@ -212,11 +207,15 @@ export async function postHandleMessage(message: Message) { export async function sendMessage(opts: MessageOptions) { const message = await handleMessage({ ...opts, timestamp: new Date() }); - if((await PluginEventHandler.preMessageEvent({ - message - } as PreMessageEventArgs)).filter(x=>x.cancel).length > 0) return; + if ( + ( + await PluginEventHandler.preMessageEvent({ + message + } as PreMessageEventArgs) + ).filter((x) => x.cancel).length > 0 + ) + return; - //TODO: check this, removed toJSON call await Promise.all([ Message.insert(message), emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message } as MessageCreateEvent) diff --git a/src/api/util/handlers/Voice.ts b/src/api/util/handlers/Voice.ts index 4d60eb91..624c868a 100644 --- a/src/api/util/handlers/Voice.ts +++ b/src/api/util/handlers/Voice.ts @@ -1,5 +1,5 @@ import { Config } from "@fosscord/util"; -import { distanceBetweenLocations, IPAnalysis } from "../utility/ipAddress"; +import { distanceBetweenLocations, IPAnalysis } from "../../../util/util/ipAddress"; export async function getVoiceRegions(ipAddress: string, vip: boolean) { const regions = Config.get().regions; @@ -12,7 +12,7 @@ export async function getVoiceRegions(ipAddress: string, vip: boolean) { let min = Number.POSITIVE_INFINITY; for (let ar of availableRegions) { - //TODO the endpoint location should be saved in the database if not already present to prevent IPAnalysis call + //TODO: the endpoint location should be saved in the database if not already present to prevent IPAnalysis call const dist = distanceBetweenLocations(clientIpAnalysis, ar.location || (await IPAnalysis(ar.endpoint))); if (dist < min) { -- cgit 1.5.1