Skip to content

Commit

Permalink
Bugfix: incorrect removal of custom pronunciation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZBAGI committed Mar 27, 2024
1 parent b29775b commit 5039110
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ if(SAY_COMMAND_PRONOUNCE) {
return;
}

const msg = "Moderator "+user+" changed pronunciation of; " + pronunciation.apply(args[0]) + "; to; " + args[1];
const removed = args[0].toLowerCase() == args[1].toLowerCase() || args[0].toLowerCase() == "remove";

if(removed) {
if(!pronunciation.remove(args[1])) {
console.log("Moderator "+user+" failed to removed unknown pronunciation of " + args[1]);
return;
}
} else {
pronunciation.set(args[0], args[1]);
}

const msg = removed ? "Moderator "+user+" removed pronunciation of; " + args[1] :
"Moderator "+user+" changed pronunciation of; " + args[0] + "; to; " + args[1];
console.log(msg);
await audio.say(msg, SAY_DEFAULT_VOICE, SAY_VOLUME);
if(args[0] == args[1])
pronunciation.remove(args[0]);
else
pronunciation.set(args[0], args[1])
}
});
}
9 changes: 3 additions & 6 deletions src/pronunciation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ export class Pronunciation {
}

public remove(key: string): boolean {
if (this.map.has(key)) {
this.map.delete(key);
this.save();
return true;
}
const result = this.map.delete(key.toLowerCase());
this.save();

return false;
return result;
}
}

0 comments on commit 5039110

Please sign in to comment.