Manual task not executing
Hiya,
One of the tasks for a temp ban doesn't seem to execute after the amount of time I specified in the command.
I've played around with other tasks that have worked before and still do work, updated the modules that are related to this and also delete the redis database after. I've also looked around and I don't think it's related to this: https://discord.com/channels/737141877803057244/1074660009117499413 because other pattern tasks have been working for a while, and I've gotten other called tasks to execute after 9 seconds.
Versions of the modules:
@sapphire/framework:
4.1.0
@sapphire/plugin-scheduled-tasks: 6.0.0
bullmq: 3.6.6
I'm also not using any modules that are currently in any betas/alphas.
Snippets of the code:
Snippet of the code in the application command:
I am also using Duration
from @sapphire/time-utilities for the variable time
.
This command also works, it does ban the user and sends a log in a channel.
Scheduled Task:
This is the only log I got in the console:
I would be happy to provide the code for the entire git repo with commands that work, or make a git repo with snippets of the code only related to temp bans.Solution:Jump to solution
I feel slightly silly with how simple of a problem/fix it was. I used event listeners to find out that
tempBan
was not found but the name of the file was tempban.ts
, so it wouldn't run because the file name was all lowercase.5 Replies
Can you start by implement event listeners for the events https://github.com/sapphiredev/plugins/blob/1f0ca075501324013b7a79410ee4bc04ebad9720/packages/scheduled-tasks/src/lib/types/ScheduledTaskEvents.ts#L11-L35 to confirm that the scheduled task is being ran correctly and such?
Solution
I feel slightly silly with how simple of a problem/fix it was. I used event listeners to find out that
tempBan
was not found but the name of the file was tempban.ts
, so it wouldn't run because the file name was all lowercase.I don't know if I just don't understand TypeScript that well or if the documentation was potentially misleading? But I thought the name would be retrieved from
declare module '@sapphire/plugin-scheduled-tasks' { ... }
, so I didn't think the file name would've been the issue ðŸ˜
But thank you so much for your help :))
Oh yeah, I forgot to mention this, one of the reasons I thought it didn't have much to do with the naming is that I didn't get an error like TS2345: Argument of type '"tempban"' is not assignable to parameter of type 'keyof ScheduledTasks'.
because of the file name, which is also why I thought tasks were ran like I thought they were.File names are always leading for the names of the Pieces. Same goes for commands, listeners, etc. If you want to set a custom name that diverts from the file name you set it through the constructor options. This is addressed in plenty on our user guide.
And by using module augmentation you can tell TS that you have a Piece called thisisaverynicepiecethattotallyexistsandisnotfake but that doesn't mean it'll actually exist at runtime.
Ohhh that makes sense, thank you for explaining it to me :)
And yeah my bad about the way I've read the documentation, I have a very strange way of learning which is usually skimming through documentation and going through trial and error... which is not the best imo, but I struggle to read slowly, and I think this is where my downfall is, even though I spent hours trying to debug it ðŸ˜
but I think it's also why I don't ask a lot of questions as it's usually down to me being silly for the reasons above haha