Skip to content

Commit

Permalink
fixed file handler logs with native files
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Nov 17, 2024
1 parent 923a9b0 commit 4430e16
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const buttonHandler = new handler.Handler<IButton>(
throw new Error(`${filepath}: default export must be a Button instance`)
},
onLoad: async (filepath, button) => {
button.native = filepath.endsWith(".native.js")
button.native = /.native.[jt]s$/.test(filepath)
button.filepath = filepath
buttons.add(button)
},
Expand Down
4 changes: 3 additions & 1 deletion src/core/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const commandHandler = new handler.Handler<ICommand>(
throw new Error(`${filepath}: default export must be a Command instance`)
},
onLoad: async (filepath, command) => {
command.native = filepath.endsWith(".native.js")
command.native = /.native.[jt]s$/.test(filepath)
command.filepath = filepath
return commands.add(command)
},
Expand Down Expand Up @@ -317,6 +317,8 @@ export function validateCommand(
command.parent = parent
command.filepath ??= parent?.filepath

if (parent?.native) command.native = true

if (command.options.isDefault) {
if (defaultCommand)
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion src/core/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const cronHandler = new handler.Handler<Cron>(util.srcPath("cron"), {
throw new CRON_Error(`${filepath}: default export must be a Cron instance`)
},
onLoad: async (filepath, button) => {
button.native = filepath.endsWith(".native.js")
button.native = /.native.[jt]s$/.test(filepath)
button.filepath = filepath
cronList.add(button)
},
Expand Down
4 changes: 2 additions & 2 deletions src/core/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export const listenerHandler = new handler.Handler<Listener<any>>(
},
)

const isNative = filepath.includes(".native.")
const isNative = /.native.[jt]s$/.test(filepath)

const category = path
.basename(filepath, ".js")
.basename(filepath.replace(/.[jt]s$/, ""))
.replace(`${listener.options.event}.`, "")
.split(".")
.filter((x) => x !== "native" && x !== listener.options.event)
Expand Down
2 changes: 1 addition & 1 deletion src/core/slash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const slashCommandHandler = new handler.Handler<ISlashCommand>(
)
},
onLoad: async (filepath, command) => {
command.native = filepath.endsWith("native.js")
command.native = /.native.[jt]s$/.test(filepath)
command.filepath = filepath
return slashCommands.add(command)
},
Expand Down

0 comments on commit 4430e16

Please sign in to comment.