Fix issue with bot crashing
This commit is contained in:
parent
55bd7ec5c7
commit
62dc3a8d6e
2 changed files with 16 additions and 4 deletions
|
@ -5,7 +5,7 @@ bot.prefix: The bot prefix for the server (Default: "v!")
|
||||||
|
|
||||||
commands.disabled: Disabled commands, separated by commas (Default: "")
|
commands.disabled: Disabled commands, separated by commas (Default: "")
|
||||||
|
|
||||||
role.assignable: List of roles assignable to user (Default: [])
|
role.assignable: List of roles assignable to user, separated by commas (Default: "")
|
||||||
role.moderator: The moderator role name (Default: "Moderator")
|
role.moderator: The moderator role name (Default: "Moderator")
|
||||||
role.administrator: The administrator role name (Default: "Administrator")
|
role.administrator: The administrator role name (Default: "Administrator")
|
||||||
role.muted: The muted role name (Default: "Muted")
|
role.muted: The muted role name (Default: "Muted")
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Role as DiscordRole } from "discord.js";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import { ICommandContext } from "../contracts/ICommandContext";
|
import { ICommandContext } from "../contracts/ICommandContext";
|
||||||
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
import ICommandReturnContext from "../contracts/ICommandReturnContext";
|
||||||
|
import SettingsHelper from "../helpers/SettingsHelper";
|
||||||
|
|
||||||
export default class Role extends Command {
|
export default class Role extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -13,12 +14,23 @@ export default class Role extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async execute(context: ICommandContext) {
|
public override async execute(context: ICommandContext) {
|
||||||
const roles = process.env.COMMANDS_ROLE_ROLES!.split(',');
|
if (!context.message.guild) return;
|
||||||
|
|
||||||
|
const roles = await SettingsHelper.GetSetting("role.assignable", context.message.guild.id);
|
||||||
|
|
||||||
|
if (!roles) {
|
||||||
|
const errorEmbed = new ErrorEmbed(context, "Unable to find any assignable roles");
|
||||||
|
errorEmbed.SendToCurrentChannel();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rolesArray = roles.split(",");
|
||||||
|
|
||||||
if (context.args.length == 0) {
|
if (context.args.length == 0) {
|
||||||
this.SendRolesList(context, roles);
|
this.SendRolesList(context, rolesArray);
|
||||||
} else {
|
} else {
|
||||||
await this.ToggleRole(context, roles);
|
await this.ToggleRole(context, rolesArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue