Skip to content

Commit

Permalink
Merge pull request #295 from TheKodeToad/pluralkit-proxy-check
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrumplex authored Nov 15, 2023
2 parents 557d5fc + f340137 commit 686f315
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { sayCommand } from './commands/say';
import random from 'just-random';
import { green, bold, yellow, cyan } from 'kleur/colors';
import 'dotenv/config';
import { proxied } from './utils/pluralKit';

const client = new Client({
intents: [
Expand Down Expand Up @@ -88,6 +89,8 @@ client.once('ready', async () => {

if (e.author === client.user) return;

if (await proxied(e)) return;

if (e.cleanContent.match(BuildConfig.ETA_REGEX)) {
await e.reply(
`${random(BuildConfig.ETA_MESSAGES)} <:pofat:1031701005559144458>`
Expand Down
10 changes: 10 additions & 0 deletions src/utils/pluralKit.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 686f315

Please sign in to comment.