secre
secre
Explore posts from servers
SIASapphire - Imagine a framework
Created by secre on 6/13/2024 in #sapphire-support
Timezone option for Scheduled Tasks
What timezone format do I need to use for task when creating it? For example I want to run task in ukranian timezone, (UTC+2) what am I supposed to put in? A bit confused because all the time here like different types and kinds of timezones that you need to provide...
6 replies
SIASapphire - Imagine a framework
Created by secre on 6/9/2024 in #sapphire-support
Attachment drop box
Is there a way to create a drop box for attachments like that one in slash commands? I want to give users ability to change role icon, so they can click button then this "drop box" will appear and user can drop their local image and then we process it via code
7 replies
SIASapphire - Imagine a framework
Created by secre on 5/15/2024 in #sapphire-support
Sapphire Scheduled Tasks | When do they launch after bot restarts?
I have a task that disables all message components. But this fails to run after bot restarts and trying to run it Logs:
2024-05-15 02:54:54 - INFO - @yume/sapphire-utilities registered successfully! // preInit
2024-05-15 02:54:55 - ERROR - [ScheduledTaskPlugin] There was no task found for "DisableMessageComponents"
2024-05-15 02:54:56 - INFO - @yume/sapphire-utilities/tasks registered successfully! // postLogin
2024-05-15 02:54:54 - INFO - @yume/sapphire-utilities registered successfully! // preInit
2024-05-15 02:54:55 - ERROR - [ScheduledTaskPlugin] There was no task found for "DisableMessageComponents"
2024-05-15 02:54:56 - INFO - @yume/sapphire-utilities/tasks registered successfully! // postLogin
I setup it to load only on postLogin because in task I need to fetch channel & message, and obv I can't do that when bot is not ready. Seems like ScheduledTaskPlugin trying to run tasks that was on redis before postLogin step if you restart your bot Is there a way to change that? :Hmm: My custom plugin that loads this task to my bots:
export class CustomSapphireScheduledTasks extends Plugin {
public static [postLogin](this: SapphireClient) {
loadScheduledTasks()

container.logger.info(`@yume/sapphire-utilities/tasks registered successfully!`)
}
}

SapphireClient.plugins.registerPostLoginHook(
CustomSapphireScheduledTasks[postLogin],
"CustomSapphireScheduledTasks-postLogin"
)
export class CustomSapphireScheduledTasks extends Plugin {
public static [postLogin](this: SapphireClient) {
loadScheduledTasks()

container.logger.info(`@yume/sapphire-utilities/tasks registered successfully!`)
}
}

SapphireClient.plugins.registerPostLoginHook(
CustomSapphireScheduledTasks[postLogin],
"CustomSapphireScheduledTasks-postLogin"
)
12 replies
SIASapphire - Imagine a framework
Created by secre on 4/15/2024 in #sapphire-support
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:
import { ApplyOptions } from "@sapphire/decorators"
import { ScheduledTask } from "@sapphire/plugin-scheduled-tasks"
import { Time } from "@sapphire/time-utilities"

@ApplyOptions<ScheduledTask.Options>({ interval: Time.Minute, name: "violation" })
export class ViolationCheckTask extends ScheduledTask {
public async run() {
this.container.utilities.violation.check()
}
}
import { ApplyOptions } from "@sapphire/decorators"
import { ScheduledTask } from "@sapphire/plugin-scheduled-tasks"
import { Time } from "@sapphire/time-utilities"

@ApplyOptions<ScheduledTask.Options>({ interval: Time.Minute, name: "violation" })
export class ViolationCheckTask extends ScheduledTask {
public async run() {
this.container.utilities.violation.check()
}
}
And this is my configuration for "tasks"
tasks: {
bull: {
defaultJobOptions: {
removeOnComplete: true,
},
connection: {
host: "localhost",
port: 6379,
},
},
},
tasks: {
bull: {
defaultJobOptions: {
removeOnComplete: true,
},
connection: {
host: "localhost",
port: 6379,
},
},
},
Am I doing something wrong? :thinkPeepo:
26 replies
SIASapphire - Imagine a framework
Created by secre on 4/7/2024 in #sapphire-support
Share sapphire stuff with multiple bots & possible monorepo setup
The question is what the better way to share sapphire stuff like utilities, handlers, commands folders with multiple bots? I need to have different bots for each category for example: economy, moderation, tickets, events, bots. Right now my project structure looks like this:
- bots
- config
- lib
- package.json
- pnpm-workspace.yaml
- bots
- config
- lib
- package.json
- pnpm-workspace.yaml
I have utilities under lib folder, and I have some shared typings in it too. Using workspace I have this "package" in my bots. Also I got node_modules at this folder and all bots is using the same packages from it. Also because of that I wanna ask how exactly sapphire works. Will it be the problem that all bots will use the same node_modules? Because as I understood from container thing you do your magic under the hood in package folder. So it might be a problem when different bots will try to use the same package. Each bot is independent project with their tsconfig, etc.. and they only share same node_modules from root folder as I said before. Will appreciate any tips/links to topics about better structure to implement, first time doing something like that
12 replies