MCPcopy Create free account
hub / github.com/Botloader/botloader / createTaskBucket

Method createTaskBucket

components/runtime/src/ts/script.ts:218–250  ·  view source on GitHub ↗
(
        options: {
            name: string,
            customScope?: CustomScope,
        },
        cb: (task: Tasks.Task<T>) => any
    )

Source from the content-addressed store, hash-verified

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

Callers 3

emoji.tsFile · 0.80

Calls 1

onMethod · 0.45

Tested by

no test coverage detected