Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

on is not defined

i want to write a script that if i chat "!OptionA" will return: Option A: write option A and if i chat "!OptionB" will return: Option B, write option B I have done this: On('ready', () =>{     On('chat:message', (msg) =>{         if ('api' === msg.type && msg.content.match(/^!OptionA/)){             {sendChat('Option A', `write option A`)}         }              })     On('chat:message', (msg) =>{             if ('api' === msg.type && msg.content.match(/^!OptionB/)){             sendChat('Option B', `write option B`)}         })     }) but the system say me "on is not defined). Where i'm wrong?
1610101031

Edited 1610101161
GiGs
Pro
Sheet Author
API Scripter
Your On is using a capital letter. In coding case matters - this should be lower case on. Also you have some extra curly brackets in your sendChat lines. Try this: on('ready', () => {     on('chat:message', (msg) => {         if ('api' === msg.type && msg.content.match(/^!OptionA/)) {             sendChat('Option A', `write option A`);         }     });     on('chat:message', (msg) => {         if ('api' === msg.type && msg.content.match(/^!OptionB/)) {             sendChat('Option B', `write option B`);         }     }); }); note also the semicolons to mark line endings. They aren't always necessary, but are sometimes, and are handy for layout purposes.