]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/twitch-bot/Controls.js
adlib chat
[alttp.git] / resources / js / components / twitch-bot / Controls.js
index f64ee62712a658da228c4ebacbc895d55931bf35..394f5464c6369ec4049d342861a287396bb468f1 100644 (file)
@@ -68,6 +68,18 @@ const Controls = () => {
                }
        }, [channel, chatText, t]);
 
+       const adlibChat = React.useCallback(async () => {
+               try {
+                       await axios.post(`/api/channels/${channel.id}/chat`, {
+                               bot_nick: 'horstiebot',
+                               adlib: true,
+                       });
+                       toastr.success(t('twitchBot.chatSuccess'));
+               } catch (e) {
+                       toastr.error(t('twitchBot.chatError'));
+               }
+       }, [channel, chatText, t]);
+
        const join = React.useCallback(async (bot_nick) => {
                try {
                        const rsp = await axios.post(`/api/channels/${channel.id}/join`, { bot_nick });
@@ -247,6 +259,16 @@ const Controls = () => {
                                                        </Button>
                                                )}
                                        </div>
+                                       <div className="mt-3">
+                                               <Button
+                                                       onClick={() => { adlibChat(); }}
+                                                       title={t('twitchBot.adlibChatDesc')}
+                                                       variant="outline-secondary"
+                                               >
+                                                       {t('twitchBot.adlibChat')}
+                                               </Button>
+                                               <p className="text-muted">{t('twitchBot.adlibChatNote')}</p>
+                                       </div>
                                </Col>
                                <Col className="mt-5" md={6}>
                                        <div className="d-flex justify-content-between">