mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
fix calculation of word mute
This commit is contained in:
parent
4dc82cad62
commit
a46887d05f
1 changed files with 7 additions and 2 deletions
|
@ -330,8 +330,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
if (ps.chatScope !== undefined) updates.chatScope = ps.chatScope;
|
||||
|
||||
function checkMuteWordCount(mutedWords: (string[] | string)[], limit: number) {
|
||||
// TODO: ちゃんと数える
|
||||
const length = JSON.stringify(mutedWords).length;
|
||||
const length = mutedWords.reduce((sum, word) => {
|
||||
const wordLength = Array.isArray(word)
|
||||
? word.reduce((l, w) => l + w.length, 0)
|
||||
: word.length;
|
||||
return sum + wordLength;
|
||||
}, 0);
|
||||
|
||||
if (length > limit) {
|
||||
throw new ApiError(meta.errors.tooManyMutedWords);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue