Mjölnir-for-all: Nicer display name

This commit is contained in:
David Teller 2023-01-06 14:24:16 +01:00 committed by David Teller
parent fa5fbee229
commit d83127ea8c
2 changed files with 11 additions and 6 deletions

View File

@ -65,8 +65,8 @@ export class MjolnirManager {
intentListener,
);
await managedMjolnir.start();
if (this.config.displayName) {
await client.setDisplayName(this.config.displayName);
if (this.config.bot.displayName) {
await client.setDisplayName(this.config.bot.displayName);
}
this.perMjolnirId.set(mjolnirUserId, managedMjolnir);
this.perOwnerId.set(requestingUserId, managedMjolnir);

View File

@ -75,16 +75,21 @@ export interface IConfig {
address: string;
}
},
/** a display name */
displayName?: string,
bot: {
/** a display name */
displayName?: string,
},
}
export function read(configPath: string): IConfig {
const content = fs.readFileSync(configPath, "utf8");
const parsed = load(content);
const config = (parsed as object) as IConfig;
if (!config.displayName) {
config.displayName = "Moderation Bot";
if (!config.bot) {
config.bot = {};
}
if (!config.bot.displayName) {
config.bot.displayName = "Moderation Bot";
}
return config;
}