Proper button validation, bugfix for voice move spam

This commit is contained in:
Dark 2021-07-01 00:30:48 +02:00
parent 1ad70ffe1a
commit bb9b8cfe06
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
2 changed files with 12 additions and 1 deletions

View file

@ -63,6 +63,11 @@ const configPreprocessor: ConfigPreprocessorFn<ReactionRolesPluginType> = option
`Invalid value for default_buttons/${defaultButtonNames[i]}/role_or_menu: ${defBtn.role_or_menu} is neither an existing menu nor a valid snowflake.`,
]);
}
if (!defBtn.label && !defBtn.emoji) {
throw new StrictValidationError([
`Invalid values for default_buttons/${defaultButtonNames[i]}/(label|emoji): Must have label, emoji or both set for the button to be valid.`,
]);
}
}
for (const [menuName, menuButtonEntries] of Object.entries(group.button_menus ?? [])) {
@ -83,6 +88,11 @@ const configPreprocessor: ConfigPreprocessorFn<ReactionRolesPluginType> = option
`Invalid value for button_menus/${menuButtonNames[i]}/role_or_menu: ${menuBtn.role_or_menu} is neither an existing menu nor a valid snowflake.`,
]);
}
if (!menuBtn.label && !menuBtn.emoji) {
throw new StrictValidationError([
`Invalid values for default_buttons/${defaultButtonNames[i]}/(label|emoji): Must have label, emoji or both set for the button to be valid.`,
]);
}
}
}
}

View file

@ -7,7 +7,8 @@ export const SpamVoiceStateUpdateEvt = spamEvt({
async listener(meta) {
const member = meta.args.newState.member;
if (!member) return;
const channel = meta.args.newState.channel!;
const channel = meta.args.newState.channel;
if (!channel) return;
const config = await meta.pluginData.config.getMatchingConfig({ member, channelId: channel.id });
const maxVoiceMoves = config.max_voice_moves;