https://github.com/commonly-ts/trivious
Discord.js Framework
https://github.com/commonly-ts/trivious
discord-js framework
Last synced: 18 days ago
JSON representation
Discord.js Framework
- Host: GitHub
- URL: https://github.com/commonly-ts/trivious
- Owner: commonly-ts
- License: apache-2.0
- Created: 2025-11-23T10:17:18.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-02-13T12:19:17.000Z (about 2 months ago)
- Last Synced: 2026-02-13T19:22:40.366Z (about 2 months ago)
- Topics: discord-js, framework
- Language: TypeScript
- Homepage:
- Size: 291 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Trivious
Discord.js framework
---
### Installation
```bash
npm install trivious
yarn add trivious
pnpm add trivious
```
> Requires Node.js 18+
---
### Quick Start
```ts
// src/index.ts
import { TriviousClient } from "trivious";
import { GatewayIntentBits } from "discord.js";
const client = new TriviousClient({
credentials: {
tokenReference: "BOT_TOKEN",
clientIdReference: "CLIENT_ID",
},
corePath: "core", // Folder containing your bot's processes
intents: [GatewayIntentBits.Guilds],
ownerUserIds: ["1234"],
});
(async () => {
try {
await client.start();
// Registers all commands, events, components, modules;
// Deploys slash commands globally and then logs into the bot
// To separately deploy commands - use client.deploy() followed by client.login()
} catch (err: unknown) {
const error = err as Error;
console.error("Failed to start bot:", error);
}
})();
```
---
### Included Default Events
Trivious automatically includes and inserts `clientReady` and `interactionCreate` handlers, which can be overwritten.
It is recommended to use the default interactionCreate handler, which requires zero setup in your own code.
These default events can be found in `src/features/events/presets` in the Trivious repository.
---
### Creating a Slash Command
```ts
// commands/debug/index.ts
import { ApplicationCommandType, SlashCommandBuilder } from "discord.js";
import { SlashCommandData } from "trivious";
export default {
active: true,
context: "SlashCommand",
commandType: ApplicationCommandType.ChatInput,
flags: ["Cached", "EphemeralReply", "DeferReply"],
data: new SlashCommandBuilder().setName("debug").setDescription("Debug commands"),
} satisfies SlashCommandData;
```
### Creating a Subcommand Group
```ts
// commands/debug/config/index.ts
import { Collection, SlashCommandSubcommandGroupBuilder } from "discord.js";
import { SlashSubcommandGroupData } from "trivious";
export default {
context: "SlashSubcommandGroup",
data: new SlashCommandSubcommandGroupBuilder()
.setName("config")
.setDescription("Config commands"),
subcommands: new Collection(),
} satisfies SlashSubcommandGroupData;
```
> Subcommands go in the same directory as the subcommand group file and are auto-detected.
---
### Creating a Subcommand
```ts
// commands/debug/ping.ts
import { ApplicationCommandType, SlashCommandSubcommandBuilder } from "discord.js";
import { interactionReply, SlashSubcommandData } from "trivious";
export default {
active: true,
context: "SlashSubcommand",
commandType: ApplicationCommandType.ChatInput,
data: new SlashCommandSubcommandBuilder().setName("ping").setDescription("Ping pong!"),
async execute(client, interaction) {
const ping = (await interaction.fetchReply()).createdTimestamp - interaction.createdTimestamp;
await interactionReply({
interaction,
replyPayload: {
content: `Pong!\nBot latency: ${ping}ms, API latency: ${client.ws.ping.toString()}ms`,
},
flags: ["EphemeralReply"],
});
},
} satisfies SlashSubcommandData;
```
---
### Project Structure
Any project structure (e.g. type-based, feature-based) is acceptable as long as everything you expect to be registered is within the core directory.
For example, if all of your commands, components, events and modules are anywhere inside src/features, assuming they export the correct data, they will be detected and registered to the client.
The only required specific structure are for slash commands, as shown below.
```
command/
├── index.ts
├── subcommand.ts
└── subcommand-group/
├── index.ts
└──subcommand.ts
```