Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions .github/workflows/changelog.yml

This file was deleted.

33 changes: 28 additions & 5 deletions examples/basic_client/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
const i18next = require("i18next");
const arox = require("../../dist/index");
const backend = require("i18next-fs-backend");
const path = require("node:path");
const { LogLevel } = require("../../dist/utils/logger/ILogger");

const myinstance = i18next.createInstance({
supportedLngs: ["en-US", "tr"],
fallbackLng: "en-US",
defaultNS: "translation",
ns: ["translation", "test"],
backend: {
loadPath: path.join(__dirname, "locales/{{lng}}/{{ns}}.json"),
},
interpolation: {
escapeValue: false,
},
});
myinstance.use(backend);

const client = new arox.Client({
intents: 37376,
prefix: { enabled: true, prefix: "a!" },
logger: {
depth: 0,
level: LogLevel.Trace,
},
autoRegisterCommands: false,
i18n: myinstance,
});

arox.setClient(client);
Expand All @@ -20,12 +39,16 @@ arox.clearClient();

command
.onMessage(function (ctx) {
const { message } = ctx;
void message.reply("Çalışıyom ulan şurda rahat bırak beni");
const { message, t, author } = ctx;
void message.reply(
t("test:hello", { user: author?.username ?? "Unknown" })
);
})
.onInteraction(function (ctx) {
const { interaction } = ctx;
void interaction.reply("Çalışıyom ulan şurda rahat bırak beni");
const { interaction, t, author } = ctx;
void interaction.reply(
t("test:hello", { user: author?.username ?? "Unknown" })
);
});

async function init() {
Expand Down
3 changes: 3 additions & 0 deletions examples/basic_client/locales/en-US/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "Hello {{user}}"
}
70 changes: 59 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"imports": {
"#types/*": "./types/*"
"#types/*": "./types/*",
"#utils": "./src/utils/index.ts",
"#structures": "./src/structures/index.ts",
"#ctx": "./src/context.ts"
Comment on lines +23 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Check for build config files
find . -maxdepth 2 -type f \( -name ".swcrc" -o -name "swc.config.*" -o -name "tsconfig.json" -o -name "tsconfig*.json" -o -name "webpack.config.*" -o -name "rollup.config.*" -o -name "vite.config.*" \) | head -20

Repository: AroxBot/framework

Length of output: 85


🏁 Script executed:

# Check package.json for build script and main/exports configuration
cat -n package.json | head -60

Repository: AroxBot/framework

Length of output: 2129


🏁 Script executed:

# Check if aliases are used in source
rg -n "#utils|#structures|#ctx" src -g "*.ts" | head -30

Repository: AroxBot/framework

Length of output: 1213


🏁 Script executed:

cat -n .swcrc

Repository: AroxBot/framework

Length of output: 449


🏁 Script executed:

cat -n tsconfig.json

Repository: AroxBot/framework

Length of output: 1566


Imports aliases must resolve to compiled output, not TypeScript sources.

The imports field points to ./src/.../*.ts files, but after the SWC build, the compiled JavaScript in dist/ will still contain unresolved #utils, #structures, and #ctx imports (SWC's config does not rewrite aliases). Consumers without TypeScript support will fail at runtime. Update imports to reference dist/ with types conditions for declaration files:

Example fix
"imports": {
   "#types/*": "./types/*",
-  "#utils": "./src/utils/index.ts",
-  "#structures": "./src/structures/index.ts",
-  "#ctx": "./src/context.ts"
+  "#utils": {
+    "types": "./dist/utils/index.d.ts",
+    "default": "./dist/utils/index.js"
+  },
+  "#structures": {
+    "types": "./dist/structures/index.d.ts",
+    "default": "./dist/structures/index.js"
+  },
+  "#ctx": {
+    "types": "./dist/context.d.ts",
+    "default": "./dist/context.js"
+  }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"#types/*": "./types/*",
"#utils": "./src/utils/index.ts",
"#structures": "./src/structures/index.ts",
"#ctx": "./src/context.ts"
"#types/*": "./types/*",
"#utils": {
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
},
"#structures": {
"types": "./dist/structures/index.d.ts",
"default": "./dist/structures/index.js"
},
"#ctx": {
"types": "./dist/context.d.ts",
"default": "./dist/context.js"
}
🤖 Prompt for AI Agents
In `@package.json` around lines 23 - 26, The imports field currently maps
"#utils", "#structures", and "#ctx" to "./src/…/*.ts" which leaves runtime
consumers pointing at TypeScript sources; update the package.json "imports"
entries to point to the compiled JavaScript in "dist/" for runtime (e.g.
"#utils" -> "./dist/utils/index.js", "#structures" ->
"./dist/structures/index.js", "#ctx" -> "./dist/context.js") and add a "types"
condition for each that points to the corresponding .d.ts in "dist/" (or your
types output) so TypeScript still resolves declarations; modify the imports
block (the "imports" field) to reference "dist/..." for runtime and "types" for
declarations accordingly.

},
"scripts": {
"prepare": "node scripts/prepareHusky.js",
Expand All @@ -38,12 +41,14 @@
"@swc/helpers": "^0.5.18",
"colorette": "^2.0.20",
"fast-glob": "^3.3.3",
"i18next": "^25.8.0",
"i18next-fs-backend": "^2.6.1",
"lodash": "^4.17.21"
},
"devDependencies": {
"@swc/cli": "^0.7.10",
"@types/lodash": "^4.17.23",
"@types/node": "^25.0.8",
"@types/node": "^25.0.9",
"husky": "^9.1.7",
"libnpmpack": "^9.0.12",
"oxfmt": "^0.24.0",
Expand Down
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client } from "./structures/Client";
import { Client } from "#structures";

// Birden fazla client olursa hata çıkartabilir ama aklıma gelen tek şey bu
export let currentClient: Client | null = null;
Expand Down
15 changes: 9 additions & 6 deletions src/events/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Events } from "discord.js";
import { EventBuilder } from "../structures/Event";
import { Context } from "../structures/Context";
import { Events, MessageFlags } from "discord.js";
import { EventBuilder, Context } from "#structures";

new EventBuilder(Events.InteractionCreate, false).onExecute(
async function (context, interaction) {
Expand All @@ -10,13 +9,17 @@ new EventBuilder(Events.InteractionCreate, false).onExecute(
if (!command || !command.supportsSlash) {
await interaction.reply({
content: "Command not found or disabled.",
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
return;
}

try {
const ctx = new Context(context.client, { interaction });
ctx.locale = interaction.locale;
context.logger.debug(
`${ctx.author?.tag ?? "Unknown"} used ${command.name}(interaction)`
);
if (command._onInteraction) await command._onInteraction(ctx.toJSON());
} catch (error) {
context.client.logger.error(
Expand All @@ -26,12 +29,12 @@ new EventBuilder(Events.InteractionCreate, false).onExecute(
if (interaction.replied || interaction.deferred) {
await interaction.followUp({
content: "There was an error while executing this command!",
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
} else {
await interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true,
flags: MessageFlags.Ephemeral,
});
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/events/message.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Events } from "discord.js";
import { EventBuilder } from "../structures/Event";
import { Context } from "../structures/Context";
import { deleteMessage } from "../utils/util";
import { EventBuilder, Context } from "#structures";
import { deleteMessageAfterSent } from "#utils";

new EventBuilder(
Events.MessageCreate,
Expand Down Expand Up @@ -31,7 +30,7 @@ new EventBuilder(
content: "Command not found or disabled.",
allowedMentions: { repliedUser: false },
})
.then(deleteMessage);
.then(deleteMessageAfterSent);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/events/ready.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Events } from "discord.js";
import { EventBuilder } from "../structures/Event";
import { EventBuilder } from "#structures";

new EventBuilder(Events.ClientReady).onExecute(async function (context) {
if (context.client.options.autoRegisterCommands) {
Expand Down
9 changes: 3 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export * from "./structures/Client";
export * from "./structures/Command";
export * from "./structures/Context";
export * from "./structures/Event";
export * from "./structures/Argument";
export * from "#structures";
export * from "./utils/logger/Logger";
export * from "./context";
export * from "#ctx";

export const version = "[VI]{{version}}[/VI]";
10 changes: 10 additions & 0 deletions src/structures/Argument.ts → src/structures/builder/Argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export class Argument {
}

public toJSON(): ApplicationCommandOptionData {
const choicesAllowedTypes = [
ApplicationCommandOptionType.String,
ApplicationCommandOptionType.Integer,
ApplicationCommandOptionType.Number,
];
if (this.choices && !choicesAllowedTypes.includes(this.type)) {
throw new Error(
`Choices are not allowed for option type ${ApplicationCommandOptionType[this.type]} (${this.type})`
);
}
return {
name: this.name,
description: this.description,
Expand Down
Loading
Loading