forked from cosmic/scythe
1
0
Fork 0
scythe/src/utils/intro-check.ts

23 lines
692 B
TypeScript

import type { Client } from "discordx";
import db from "../db";
import { introTable } from "../db/schema";
import type { TextChannel } from "discord.js";
import { sleep } from "./underage";
export const introCheck = async (client: Client) => {
while (true) {
const channelRes = await db.select().from(introTable);
for (const c of channelRes) {
const channel = client.channels.cache.get(c.channel) as TextChannel;
const guild = client.guilds.cache.get(c.guild);
const msgs = await channel.messages.fetch({ limit: 10 });
for (const m of msgs) {
if (!guild?.members.cache.has(m[1].author.id)) {
await m[1].delete();
}
}
}
await sleep(1000 * 60 * 20);
}
};