aboutsummaryrefslogtreecommitdiff
path: root/src/inhibitors/checks/fatal.ts
blob: 9fda50434ddc90a63e0e13931607a8dbdfaa6365 (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
28
import { BushInhibitor, type SlashMessage } from '#lib';
import { type Message } from 'discord.js';

export default class FatalInhibitor extends BushInhibitor {
	public constructor() {
		super('fatal', {
			reason: 'fatal',
			type: 'all',
			category: 'checks',
			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;
	}
}