Update commands to check roles per server

This commit is contained in:
Ethan Lane 2022-03-16 20:12:50 +00:00
parent d111363c87
commit 1387200c00
Signed by: Vylpes
GPG key ID: EED233CC06D12504
17 changed files with 111 additions and 20 deletions

View file

@ -12,7 +12,7 @@ export default class Ban extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}

View file

@ -11,7 +11,7 @@ export default class Clear extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}

View file

@ -1,5 +1,6 @@
import { Guild } from "discord.js";
import { readFileSync } from "fs";
import { CommandResponse } from "../constants/CommandResponse";
import DefaultValues from "../constants/DefaultValues";
import { ICommandContext } from "../contracts/ICommandContext";
import ICommandReturnContext from "../contracts/ICommandReturnContext";
@ -13,6 +14,25 @@ export default class Config extends Command {
constructor() {
super();
super._category = "Administration";
super._roles = [
"administrator"
]
}
public override async precheckAsync(context: ICommandContext): Promise<CommandResponse> {
if (!context.message.guild) {
return CommandResponse.ServerNotSetup;
}
const server = await Server.FetchOneById<Server>(Server, context.message.guild?.id, [
"Settings",
]);
if (!server) {
return CommandResponse.ServerNotSetup;
}
return CommandResponse.Ok;
}
public override async execute(context: ICommandContext) {
@ -25,8 +45,6 @@ export default class Config extends Command {
]);
if (!server) {
const embed = new ErrorEmbed(context, "This server hasn't been setup yet, please run the setup command");
embed.SendToCurrentChannel();
return;
}

View file

@ -12,7 +12,7 @@ export default class Kick extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}

View file

@ -12,7 +12,7 @@ export default class Mute extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}

View file

@ -18,7 +18,7 @@ export default class Rules extends Command {
super._category = "Admin";
super._roles = [
process.env.ROLES_MODERATOR!
"administrator"
];
}

View file

@ -9,6 +9,9 @@ export default class Setup extends Command {
constructor() {
super();
super._category = "Administration";
super._roles = [
"moderator"
]
}
public override async execute(context: ICommandContext) {

View file

@ -12,7 +12,7 @@ export default class Unmute extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}

View file

@ -11,7 +11,7 @@ export default class Warn extends Command {
super._category = "Moderation";
super._roles = [
process.env.ROLES_MODERATOR!
"moderator"
];
}