diff --git a/api/src/util/handlers/Instance.ts b/api/src/util/handlers/Instance.ts
index 6bddfa98..7c337270 100644
--- a/api/src/util/handlers/Instance.ts
+++ b/api/src/util/handlers/Instance.ts
@@ -1,4 +1,5 @@
import { Config, Guild, Session } from "@fosscord/util";
+import { createQueryBuilder } from "typeorm";
export async function initInstance() {
// TODO: clean up database and delete tombstone data
@@ -9,7 +10,7 @@ export async function initInstance() {
const { autoJoin } = Config.get().guild;
if (autoJoin.enabled && !autoJoin.guilds?.length) {
- let guild = await Guild.findOne({});
+ let guild = await Guild.findOne({where: {}, order: {id: "ASC"}});
if (guild) {
// @ts-ignore
await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } });
diff --git a/api/src/util/handlers/Message.ts b/api/src/util/handlers/Message.ts
index 80012260..7035bc5c 100644
--- a/api/src/util/handlers/Message.ts
+++ b/api/src/util/handlers/Message.ts
@@ -201,9 +201,10 @@ export async function postHandleMessage(message: Message) {
export async function sendMessage(opts: MessageOptions) {
const message = await handleMessage({ ...opts, timestamp: new Date() });
+ //TODO: check this, removed toJSON call
await Promise.all([
Message.insert(message),
- emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message.toJSON() } as MessageCreateEvent)
+ emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message } as MessageCreateEvent)
]);
postHandleMessage(message).catch((e) => {}); // no await as it should catch error non-blockingly
diff --git a/api/src/util/index.ts b/api/src/util/index.ts
index ac439371..b3c7559f 100644
--- a/api/src/util/index.ts
+++ b/api/src/util/index.ts
@@ -1,9 +1,9 @@
+export * from "./entities/AssetCacheItem";
+export * from "./handlers/Message";
+export * from "./handlers/route";
+export * from "./handlers/Voice";
export * from "./utility/Base64";
export * from "./utility/ipAddress";
-export * from "./handlers/Message";
export * from "./utility/passwordStrength";
export * from "./utility/RandomInviteID";
-export * from "./handlers/route";
-export * from "./utility/String";
-export * from "./handlers/Voice";
-export * from "./entities/AssetCacheItem";
\ No newline at end of file
+export * from "./utility/String";
\ No newline at end of file
|