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
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ src
scripts
tsconfig.json
.oxfmtrc.json
.prettierrc
package-lock.json
.swcrc
.swcrc
23 changes: 23 additions & 0 deletions examples/basic_client/commands/ping.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const {
Command,
ApplicationCommandBuilder,
} = require("../../../dist/index.cjs");

module.exports = new Command({
data: new ApplicationCommandBuilder()
.setName("ping")
.setDescription("Replies with pong")
.setAliases("p")
.setPrefixSupport(true)
.setSlashSupport(true),
onMessage: (ctx) =>
ctx.message.reply(
ctx.t("test:hello", {
user: ctx.message.author.username,
})
),
onInteraction: (ctx) =>
ctx.interaction.reply(
ctx.t("test:hello", { user: ctx.interaction.user.username })
),
});
6 changes: 6 additions & 0 deletions examples/basic_client/events/ready.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { EventBuilder } = require("../../../dist/index.cjs");

module.exports = new EventBuilder("clientReady", false, (context) => {
context.logger.log("Client connected!");
context.logger.warn(`Current user: ${context.client.user.username}`);
});
7 changes: 0 additions & 7 deletions examples/basic_client/events/ready.js

This file was deleted.

31 changes: 6 additions & 25 deletions examples/basic_client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const myinstance = i18next.createInstance({
supportedLngs: ["en-US", "tr"],
supportedLngs: ["en-US", "tr"], // Required to be `${Locale}` (LocaleString)
fallbackLng: "en-US",
defaultNS: "translation",
ns: ["translation", "test", "error"],
Expand All @@ -28,37 +28,18 @@ const client = new arox.Client({
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
prefix: { enabled: true, prefix: "a!" },
prefix: () => "a!",
includePaths: [
path.join(__dirname, "events"),
path.join(__dirname, "commands"),
],
logger: {
level: arox.LogLevel.Debug,
},
autoRegisterCommands: false,
i18n: myinstance,
});

arox.setClient(client);
const command = new arox.CommandBuilder(
new arox.ApplicationCommandBuilder()
.setName("arox")
.setDescription("Arox Test Command")
.addAliases("a")
);
arox.clearClient();

command
.onMessage(function (ctx) {
const { message, t, author } = ctx;
void message.reply(
t("test:hello", { user: author?.username ?? "Unknown" })
);
})
.onInteraction(function (ctx) {
const { interaction, t, author } = ctx;
void interaction.reply(
t("test:hello", { user: author?.username ?? "Unknown" })
);
});

async function init() {
const token = process.env.DISCORD_TOKEN ?? process.env.BOT_TOKEN;
await client.login(token);
Expand Down
6 changes: 4 additions & 2 deletions examples/basic_client/locales/en-US/error.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"command.notfound": "Command not found or disabled1",
"command.disabled": "Command not found or disabled2"
"command": {
"notfound": "Command not found or disabled1",
"disabled": "Command not found or disabled2"
}
}
Loading