137 role command cannot read properties of undefined #141
2 changed files with 14 additions and 4 deletions
|
@ -28,14 +28,15 @@ export default class Role extends Command {
|
|||
const rolesArray = roles.split(",");
|
||||
|
||||
if (context.args.length == 0) {
|
||||
this.SendRolesList(context, rolesArray);
|
||||
await this.SendRolesList(context, rolesArray, context.message.guild.id);
|
||||
} else {
|
||||
await this.ToggleRole(context, rolesArray);
|
||||
}
|
||||
}
|
||||
|
||||
public SendRolesList(context: ICommandContext, roles: String[]): ICommandReturnContext {
|
||||
const description = `Do ${process.env.BOT_PREFIX}role <role> to get the role!\n${roles.join('\n')}`;
|
||||
public async SendRolesList(context: ICommandContext, roles: String[], serverId: string): Promise<ICommandReturnContext> {
|
||||
const botPrefix = await SettingsHelper.GetServerPrefix(serverId);
|
||||
const description = `Do ${botPrefix}role <role> to get the role!\n${roles.join('\n')}`;
|
||||
|
||||
const embed = new PublicEmbed(context, "Roles", description);
|
||||
embed.SendToCurrentChannel();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { getConnection } from "typeorm";
|
||||
import DefaultValues from "../constants/DefaultValues";
|
||||
import Server from "../entity/Server";
|
||||
import Setting from "../entity/Setting";
|
||||
|
@ -47,4 +46,14 @@ export default class SettingsHelper {
|
|||
await server.Save(Server, server);
|
||||
}
|
||||
}
|
||||
|
||||
public static async GetServerPrefix(serverId: string): Promise<string> {
|
||||
const setting = await this.GetSetting("bot.prefix", serverId);
|
||||
|
||||
if (!setting) {
|
||||
return "v!";
|
||||
}
|
||||
|
||||
|
||||
return setting;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue
Not needed