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

api-heartbeat problem

I love The Aaron's api-heartbeat! Unfortunately I used the --histogram without understanding it. The macro created didn't do anything (apparently I should have dowloaded directly instead of using 1click.) So I opened the macro and deleted it. It then recreated itself and then began recreating itself again once every second. Foolishly I went to research what was going on rather than immediately disabling the mod. There is now an enormous number of useless macros at the top of my macro list before you reach a large number of useful macros. The only way of removing a macro (that I know of) is click on the macro to open it, move to the open macro, pull down of the scroll bar to expose Delete Macro, click on Delete Macro , move down to the confirm window and click Delete Macro there, and then do it all over again. Two questions: First, does anyone know of a way I could do this faster? Second, does anyone know if once I get rid of the useless repeated macros, I can safely enable the api-heartbeat mod?
1677730755
The Aaron
Roll20 Production Team
API Scripter
Oh no!!!!!  If you want to PM me an invite, I can come clean that up and see what the problem was. 
1677730923
timmaugh
Pro
API Scripter
Here, James... try this: /* ========================================================= Name            :  MacroCleanup GitHub          : Roll20 Contact  :  timmaugh Version         :  1.0.0 Last Update     :  3/1/2023 ========================================================= */ on('ready', () => {     on('chat:message', msg => {         // expected command line: !macrocleanup [--starts=''[ --ends=''[ --contains='']]]         if (msg.type !== 'api' || !/^!macrocleanup\b/i.test(msg.content)) return;         let args = msg.content.split(/\s+--/).slice(1).map(a => a.split(/=/));         if (!args.length) {             sendChat('Moderator', `&{template:default}{{name=Invalid Syntax}}{{ =MacroCleanup requires at least one of **starts**, **ends**, or **contains** as an argument.}}{{Example=!macrocleanup --starts=Token --contains=Maze}}`);             return;         }         let macros = args.reduce((m, a) => {             m = m.filter(o => {                 switch (a[0].toLowerCase()) {                     case 'starts':                         return o.get('name').startsWith(a[1]);                     case 'ends':                         return o.get('name').endsWith(a[1]);                     case 'contains':                         return o.get('name').includes(a[1]);                     default:                         return true;                 }             });             return m;         }, findObjs({ type: 'macro' }));         let allIds = `{{ **REMOVE ALL**=[Delete All](!
!macrodelete ${macros.map(m => m.id).join(' ')})}}`;         if (macros.length) {             macros = macros.map(m => `{{ ${m.get('name')}=[Delete](!
!macrodelete ${m.id})}}`);         } else {             macros.push(`{{ =No scripts found that match that criteria.}}`)         }         sendChat('Moderator', `&{template:default}{{name=Matching Macros}}${macros.join('')}${allIds}`);     });     on('chat:message', msg => {         if (msg.type !== 'api' || !/^!macrodelete\b/i.test(msg.content)) return;         msg.content.split(/\s+/).slice(1).forEach(a => {             let m = findObjs({ type: 'macro', id: a })[0];             if (m) {                 log(`Deleting... ${m.get('name')}`);                 log(m.get('action'));                 m.remove();             }         })     }); }); B asic usage is to run: !macrocleanup ...and include at least one argument in the form of: --starts=starting text --ends=ending text --contains=text All arguments will serve as filters, so you can look for macros that start with a combination of characters and also include some other group of characters, etc. The script will return a list of the macros with the ability to delete them individually or to click a button that will delete them all.
1677730960
timmaugh
Pro
API Scripter
Though now that I see Aaron is on the case, maybe consult with him, first!