29 lines
708 B
TypeScript
29 lines
708 B
TypeScript
import { Command, Inhibitor } from "discord-akairo";
|
|
import { Message } from "discord.js";
|
|
import { Guild } from "../../entity/Guild";
|
|
|
|
class SetupWhileRegistered extends Inhibitor {
|
|
constructor() {
|
|
super("SetupWhileRegistered", {
|
|
reason: "already setup",
|
|
type: "post",
|
|
priority: 1,
|
|
});
|
|
}
|
|
|
|
async exec(message: Message, command: Command) {
|
|
// we handle no guild somewhere else
|
|
if (!message.guild) return false;
|
|
|
|
if (command.id !== "setup") return false;
|
|
|
|
const author = message.member;
|
|
if (!author) return true;
|
|
|
|
const guild = await Guild.count({ where: { guild: author.guild.id } });
|
|
return guild !== 0;
|
|
}
|
|
}
|
|
|
|
export default SetupWhileRegistered;
|