aboutsummaryrefslogtreecommitdiff
path: root/src/inhibitors/checks/fatal.ts
blob: 4364d486cd884390e7c31e640762809d163f6b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { BotInhibitor, type SlashMessage } from '#lib';
import { type Message } from 'discord.js';

export default class FatalInhibitor extends BotInhibitor {
	public constructor() {
		super('fatal', {
			reason: 'fatal',
			type: 'all',
			priority: 100
		});
	}

	public async exec(message: Message | SlashMessage): Promise<boolean> {
		if (this.client.isOwner(message.author)) return false;
		const globalCache = this.client.cache.global;
		for (const property in globalCache) {
			if (!globalCache[property as keyof typeof globalCache]) {
				void this.client.console.verbose(
					'fatal',
					`Blocked message with id <<${message.id}>> from <<${message.author.tag}>> in <<${message.guild?.name}>>.`
				);
				return true;
			}
		}
		return false;
	}
}