forked from cosmic/scythe
24 lines
717 B
TypeScript
24 lines
717 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);
|
|
await guild?.fetch();
|
|
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);
|
|
}
|
|
};
|