(
options: {
name: string,
customScope?: CustomScope,
},
cb: (task: Tasks.Task<T>) => any
)
| 216 | } |
| 217 | |
| 218 | createTaskBucket<T = undefined>( |
| 219 | options: { |
| 220 | name: string, |
| 221 | customScope?: CustomScope, |
| 222 | }, |
| 223 | cb: (task: Tasks.Task<T>) => any |
| 224 | ) { |
| 225 | const pluginId = options.customScope |
| 226 | ? options.customScope.kind === "Guild" |
| 227 | ? null |
| 228 | : options.customScope.pluginId |
| 229 | : this.pluginId |
| 230 | |
| 231 | this.taskHandlers.push({ |
| 232 | name: options.name, |
| 233 | pluginId: pluginId, |
| 234 | }); |
| 235 | |
| 236 | this.events.on("BOTLOADER_SCHEDULED_TASK_FIRED", async (evt) => { |
| 237 | if (evt.namespace === options.name && evt.pluginId === pluginId) { |
| 238 | await cb({ |
| 239 | ...evt, |
| 240 | pluginId: pluginId, |
| 241 | data: evt.data as T, |
| 242 | }); |
| 243 | } |
| 244 | }) |
| 245 | |
| 246 | return new Tasks.TaskBucket<T>({ |
| 247 | name: options.name, |
| 248 | pluginId, |
| 249 | }) |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Register a handler for button interactions |
no test coverage detected