feat: store pluralkit users in redis

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-11-16 23:06:32 +01:00
parent c29d5dfb8d
commit e6337cf6bd
No known key found for this signature in database
GPG key ID: E13DFD4B47127951
3 changed files with 68 additions and 10 deletions

View file

@ -1,10 +1,22 @@
import { Message } from "discord.js";
import { Message } from 'discord.js';
export async function proxied(message: Message): Promise<boolean> {
if (message.webhookId !== null)
return false;
await new Promise(resolve => setTimeout(resolve, 300));
const response = await fetch(`https://api.pluralkit.me/v2/messages/${message.id}`);
return response.ok;
interface PkMessage {
sender: string;
}
export const pkDelay = 500;
export async function fetchPluralKitMessage(message: Message) {
const response = await fetch(
`https://api.pluralkit.me/v2/messages/${message.id}`
);
if (!response.ok) return null;
return (await response.json()) as PkMessage;
}
export async function isMessageProxied(message: Message) {
await new Promise((resolve) => setTimeout(resolve, pkDelay));
return (await fetchPluralKitMessage(message)) !== null;
}