Fix server prefix not showing

This commit is contained in:
Ethan Lane 2022-04-23 17:34:37 +01:00
parent 62dc3a8d6e
commit ae1b5f237c
Signed by: Vylpes
GPG key ID: EED233CC06D12504
2 changed files with 14 additions and 4 deletions

View file

@ -28,14 +28,15 @@ export default class Role extends Command {
const rolesArray = roles.split(","); const rolesArray = roles.split(",");
if (context.args.length == 0) { if (context.args.length == 0) {
this.SendRolesList(context, rolesArray); await this.SendRolesList(context, rolesArray, context.message.guild.id);
} else { } else {
await this.ToggleRole(context, rolesArray); await this.ToggleRole(context, rolesArray);
} }
} }
public SendRolesList(context: ICommandContext, roles: String[]): ICommandReturnContext { public async SendRolesList(context: ICommandContext, roles: String[], serverId: string): Promise<ICommandReturnContext> {
const description = `Do ${process.env.BOT_PREFIX}role <role> to get the role!\n${roles.join('\n')}`; 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); const embed = new PublicEmbed(context, "Roles", description);
embed.SendToCurrentChannel(); embed.SendToCurrentChannel();

View file

@ -1,4 +1,3 @@
import { getConnection } from "typeorm";
import DefaultValues from "../constants/DefaultValues"; import DefaultValues from "../constants/DefaultValues";
import Server from "../entity/Server"; import Server from "../entity/Server";
import Setting from "../entity/Setting"; import Setting from "../entity/Setting";
@ -47,4 +46,14 @@ export default class SettingsHelper {
await server.Save(Server, server); 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;
}
} }