mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-18 01:50:50 +00:00
parent
d4e99bfe10
commit
fd9dbedfdb
3 changed files with 31 additions and 4 deletions
|
@ -109,7 +109,8 @@
|
|||
"streamer": "Streamer only"
|
||||
},
|
||||
"remove-command-title": "Remove command {{name}}?",
|
||||
"no-commands": "Chatbot has no commands configured"
|
||||
"no-commands": "Chatbot has no commands configured",
|
||||
"command-already-in-use": "Command name already in use"
|
||||
},
|
||||
"bottimers": {
|
||||
"title": "Bot timers",
|
||||
|
@ -126,7 +127,8 @@
|
|||
"timer-activity": "Minimul chat activity (0 to disable)",
|
||||
"timer-activity-desc": "messages in the last 5 minutes",
|
||||
"timer-messages": "Messages",
|
||||
"no-timers": "There are no timers configured"
|
||||
"no-timers": "There are no timers configured",
|
||||
"name-already-in-use": "Timer name already in use"
|
||||
},
|
||||
"auth": {
|
||||
"title": "Authentication required",
|
||||
|
|
|
@ -189,6 +189,7 @@ function CommandDialog({
|
|||
item?: TwitchBotCustomCommand;
|
||||
onSubmit?: (name: string, item: TwitchBotCustomCommand) => void;
|
||||
}) {
|
||||
const [commands] = useModule(modules.twitchBotCommands);
|
||||
const [commandName, setCommandName] = useState(name ?? '');
|
||||
const [description, setDescription] = useState(item?.description ?? '');
|
||||
const [response, setResponse] = useState(item?.response ?? '');
|
||||
|
@ -226,7 +227,17 @@ function CommandDialog({
|
|||
id="command-name"
|
||||
value={commandName}
|
||||
required={true}
|
||||
onChange={(e) => setCommandName(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setCommandName(e.target.value);
|
||||
// If command name is different but matches another defined command, set as invalid
|
||||
if (e.target.value !== name && e.target.value in commands) {
|
||||
(e.target as HTMLInputElement).setCustomValidity(
|
||||
t('pages.botcommands.command-already-in-use'),
|
||||
);
|
||||
} else {
|
||||
(e.target as HTMLInputElement).setCustomValidity('');
|
||||
}
|
||||
}}
|
||||
placeholder={t('pages.botcommands.command-name-placeholder')}
|
||||
/>
|
||||
</Field>
|
||||
|
|
|
@ -200,6 +200,7 @@ function TimerDialog({
|
|||
item?: TwitchBotTimer;
|
||||
onSubmit?: (name: string, item: TwitchBotTimer) => void;
|
||||
}) {
|
||||
const [timerConfig] = useModule(modules.twitchBotTimers);
|
||||
const [timerName, setName] = useState(name ?? '');
|
||||
const [messages, setMessages] = useState(item?.messages ?? ['']);
|
||||
const [minDelay, setMinDelay] = useState(item?.minimum_delay ?? 300);
|
||||
|
@ -234,7 +235,20 @@ function TimerDialog({
|
|||
<InputBox
|
||||
id="timer-name"
|
||||
value={timerName}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setName(e.target.value);
|
||||
// If timer name is different but matches another defined timer, set as invalid
|
||||
if (
|
||||
e.target.value !== name &&
|
||||
e.target.value in timerConfig.timers
|
||||
) {
|
||||
(e.target as HTMLInputElement).setCustomValidity(
|
||||
t('pages.bottimers.name-already-in-use'),
|
||||
);
|
||||
} else {
|
||||
(e.target as HTMLInputElement).setCustomValidity('');
|
||||
}
|
||||
}}
|
||||
placeholder={t('pages.bottimers.timer-name-placeholder')}
|
||||
required={true}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue