137 role command cannot read properties of undefined #141

Merged
Vylpes merged 5 commits from 137-role-command-cannot-read-properties-of-undefined into develop 2022-04-23 18:43:30 +01:00
2 changed files with 14 additions and 4 deletions
Showing only changes of commit ae1b5f237c - Show all commits

View file

@ -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();

View file

@ -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!";
}
VylpesTester commented 2022-04-23 18:31:11 +01:00 (Migrated from github.com)
Review

Not needed

Not needed
return setting;
}
}