Task was not found | plugin-scheduled-tasks
👋🏿 I'm getting "
[ScheduledTaskPlugin] There was no task found for "task_name"
" error for all my scheduled tasks. Sometimes they run successfully but mostly they giving me this error.
There is the code of how i'm declaring task:
And this is my configuration for "tasks"
Am I doing something wrong? :thinkPeepo:17 Replies
orderevent and violation are not the same name?
no
I just copied 1 error from 5, and random task just to show how I implement them
Can you share your exact file/folder structure?
yes sure
I also specify
main
in package.jsonstill can't figure out why this error happens. all tasks failing and sometimes randomly executes :NotLikeThis:
well I don't see tasks of those names in the folder...
becase they are split among 5 bots. That's like logs when I start all of them in 1 command. on my prev screen you can lottery task, and there is eventban and order event check
Solution
you should use a different logical redis database for every bot then
set
db:
in the connection settings
int value from 0 to 16you think problem might be in this? because those tasks doesn't overlap with each other
definitely. bullmq doesn't distinguish by some kind of process identifier
so it just sends to the event emitter that a task triggers then sapphire is like "I can't find that task" and logs it
ohhh, I think I gotchu. Like each bot thinks that he has that task, but it doesnt
okay will check db value, might help 👍🏿
oh also, is there a way to run tasks only when bot login? because I execute some utilities in them and it's impossible to use utility before bot's login state
uh dont call the plugin's register and write your own file very similar to this one except use the
registerPostLoginHook
hook where right now we have preGenericsInitialization
and postInitialization
(both the static methods and the code at the bottom). You can dump everything in registerPostLoginHook
https://github.com/sapphiredev/plugins/blob/9fbf980e603022c3e1cd61a9ad742cd43a60e7fa/packages/scheduled-tasks/src/register.ts
oh and then import it similar to how you import register now, of courseI see. Will play with that tomorrow 👍🏿 Right now I just added a check if utility exists in
utilities
property - if not just return...nice, changing
db
to different values for each redis client worked outtysm for help!