forked from WildH0g/Medium-GAS-bypassing-max-exec-time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigger.js
26 lines (25 loc) · 773 Bytes
/
trigger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// jshint esversion: 9
// jshint laxbreak: true
const Trigger = (function () {
class Trigger {
constructor(functionName, everyMinutes) {
return ScriptApp.newTrigger(functionName)
.timeBased()
.everyMinutes(everyMinutes)
.create();
}
static deleteTrigger(e) {
if (typeof e !== 'object')
return console.log(`${e} is not an event object`);
if (!e.triggerUid)
return console.log(`${JSON.stringify(e)} doesn't have a triggerUid`);
ScriptApp.getProjectTriggers().forEach(trigger => {
if (trigger.getUniqueId() === e.triggerUid) {
console.log('deleting trigger', e.triggerUid);
return ScriptApp.deleteTrigger(trigger);
}
});
}
}
return Trigger;
})();