Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
feat: add feature to prune old members
Browse files Browse the repository at this point in the history
Prunes members who have been inactive for more than four weeks.
  • Loading branch information
mahyarmirrashed committed Sep 10, 2021
1 parent bdbf3dc commit b58d79d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/events/cron/PruneEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Guild } from 'discord.js';
import Bot from '../../client/Client';
import Handler from '../../interfaces/HandlerStorage';

export const cronJobFrequency = '0 0 * * MON';

export const handler: Handler<unknown> = async (client: Bot): Promise<void> => {
// prune all guilds
await client.guilds.fetch();
client.guilds.cache.each(async (guild: Guild) => {
guild.members
.prune({
days: 28,
reason: 'Please rejoin when you are active on the server again.',
})
.then((pruneCount: number) =>
client.logger.info(`Pruned ${pruneCount} members on ${guild.id}`),
);
});
};

export const name = 'prune';

0 comments on commit b58d79d

Please sign in to comment.