Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/scripts/network/sendBroadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default (
};
}

const messageOrError = await sendMessage(messageFormat, connection.webhookURL);
const messageOrError = await sendMessage(connection.webhookURL, messageFormat);

// return the message and webhook URL to store the message in the db
return {
Expand Down
13 changes: 7 additions & 6 deletions src/scripts/network/sendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { APIMessage, WebhookMessageCreateOptions } from 'discord.js';

export default async (message: WebhookMessageCreateOptions, webhookUrl: string) => {
const res = await fetch('https://interchat-networkwebhook.vercel.app/api/send', {
method: 'PUT',
type DiscordErrorFormat = { message: string; code: number };

export default async (webhookUrl: string, message: WebhookMessageCreateOptions) => {
const res = await fetch('https://api.interchat.fun/send', {
method: 'POST',
body: JSON.stringify(message),
headers: {
authorization: `${process.env.NETWORK_API_KEY}`,
Expand All @@ -11,7 +13,6 @@ export default async (message: WebhookMessageCreateOptions, webhookUrl: string)
},
});

const resBody = await res.json();

return res.status === 200 ? (resBody.result as APIMessage) : String(resBody.error);
const resBody: APIMessage | DiscordErrorFormat = await res.json();
return 'code' in resBody ? resBody.message : resBody;
};