Merge pull request #295 from TheKodeToad/pluralkit-proxy-check

This commit is contained in:
Sefa Eyeoglu 2023-11-15 12:37:55 +01:00 committed by GitHub
commit 686f315e0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -26,6 +26,7 @@ import { sayCommand } from './commands/say';
import random from 'just-random'; import random from 'just-random';
import { green, bold, yellow, cyan } from 'kleur/colors'; import { green, bold, yellow, cyan } from 'kleur/colors';
import 'dotenv/config'; import 'dotenv/config';
import { proxied } from './utils/pluralKit';
const client = new Client({ const client = new Client({
intents: [ intents: [
@ -88,6 +89,8 @@ client.once('ready', async () => {
if (e.author === client.user) return; if (e.author === client.user) return;
if (await proxied(e)) return;
if (e.cleanContent.match(BuildConfig.ETA_REGEX)) { if (e.cleanContent.match(BuildConfig.ETA_REGEX)) {
await e.reply( await e.reply(
`${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>` `${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>`

10
src/utils/pluralKit.ts Normal file
View file

@ -0,0 +1,10 @@
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;
}