https://github.com/matteopolak/framecord
A template to create a modular and extensible Discord bot.
https://github.com/matteopolak/framecord
command discord discordjs framecord framework library
Last synced: 9 months ago
JSON representation
A template to create a modular and extensible Discord bot.
- Host: GitHub
- URL: https://github.com/matteopolak/framecord
- Owner: matteopolak
- License: mit
- Created: 2022-10-13T00:50:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T16:11:50.000Z (almost 3 years ago)
- Last Synced: 2025-06-30T03:04:49.544Z (9 months ago)
- Topics: command, discord, discordjs, framecord, framework, library
- Language: TypeScript
- Homepage: https://matteopolak.com/docs/framecord
- Size: 158 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Framecord 🤖



[framecord](https://github.com/matteopolak/framecord) is a modular and extensible framework for creating Discord bots, created with [discord.js](https://github.com/discordjs/discord.js).
## Documentation
Check out the documentation at **[matteopolak.com/docs/framecord](https://matteopolak.com/docs/framecord)**.
## "Hello, world!"
The setup below will do the following:
1. Create a slash command called `/helloworld` that outputs the message `Hello {user}!`
2. Print `I just logged in as {username}!` to the console when the `ready` event is fired
`src/index.ts`
```typescript
import { join } from 'node:path';
import { IntentsBitField } from 'discord.js';
import { Client, Command } from '@matteopolak/framecord';
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds
]
});
// Client#compileCommandDirectory takes an *absolute path* to the
// command directory, and will construct a tree of commands.
//
// Commands in nested folders will be grouped under the command by the
// same name as the folder (which *must* exist)
//
// By default, commands are added relative to the root command node,
// but you can provide the subcommand Collection of any command to start
// there instead.
await client.compileCommandDirectory(join(__dirname, 'commands'));
// Client#init must complete (i.e. await it) *before* the client is logged in.
await client.init();
client.login(process.env.TOKEN);
```
`src/commands/helloworld.ts`
```typescript
import {
Command,
CommandOptions,
CommandResponse,
CommandSource,
EventHandler
} from '@matteopolak/framecord';
// *Must* be a default export in order to work properly when
// adding an entire command directory
export default class HelloWorld extends Command {
// *Must* be an asynchronous function
public async run(source: CommandSource): CommandResponse {
return `Hello, ${source.user.username}!`;
}
// The @EventHandler decorator is used to define when
// a method should be treated as an event listener
//
// It currently only has the `once` option, which (when true)
// will stop listening to the event after it is fired once
@EventHandler({ once: true })
public async ready() {
// `client` is a reference to the Client
console.log(`I just logged in as ${this.client.user.username}!`);
}
}
```