Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thegears/djs-template-v14
A template for discord.js v14 bot
https://github.com/thegears/djs-template-v14
discord discord-bot discord-js discordjs template
Last synced: 21 days ago
JSON representation
A template for discord.js v14 bot
- Host: GitHub
- URL: https://github.com/thegears/djs-template-v14
- Owner: thegears
- Created: 2024-06-16T01:43:42.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-06-16T13:42:46.000Z (8 months ago)
- Last Synced: 2024-11-17T02:38:14.165Z (3 months ago)
- Topics: discord, discord-bot, discord-js, discordjs, template
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# djs-template-v14
This is a template project for [Discord.js v14](https://github.com/discordjs/discord.js).
I am recommending using this project with [Bun](https://bun.sh)
To install dependencies:
```bash
bun install
```To register Slash Commands:
```bash
bun registerSlashCommands
```To run:
```bash
bun start
```## Examples
### Example for interactions/button
#### With params
```ts
import type { Interaction } from '../../typings'/**
new ButtonBuilder()
.setCustomId(`[example]{thegears}`)
.setStyle(ButtonStyle.Secondary)
.setLabel('Example')
*/const button: Interaction = {
customId: 'example',
withParams: true,
run: async ({ interaction, params }) => {
interaction.reply({
content: `${params[0]}` // thegears
})
}
}export default button;
```#### Without params
```ts
import type { Interaction } from '../../typings'/**
new ButtonBuilder()
.setCustomId(`example`)
.setStyle(ButtonStyle.Secondary)
.setLabel('Example')
*/const button: Interaction = {
customId: 'example',
run: async ({ interaction }) => {
interaction.reply({
content: 'hello'
})
}
}export default button;
```### Example for interactions/modal
```ts
import type { Interaction } from '../../typings'const button: Interaction = {
customId: 'example',
run: async ({ interaction }) => {
interaction.reply({
content: 'hello'
})
}
}export default button;
```### Example for commands/message
```ts
import type { MessageCommand } from "../../typings";const command: MessageCommand = {
name: "example",
withPrefix: true,
aliases: ["e"],
description: "An example command",
run: async ({ message }) => {
message.reply({
content: "This is an example command with prefix"
})
}
}export default command;
```### Example for commands/slash
```ts
import { SlashCommandBuilder } from "discord.js";
import type { SlashCommand } from "../../typings";const slash: SlashCommand = {
build: new SlashCommandBuilder().setName('example').setDescription('Example command'),
run: async ({ interaction }) => {
interaction.reply({
content: "This is an example slash command"
})
}
}export default slash;
```### Example for events
```ts
import type { Event } from "../typings";const event: Event = {
name: "ready",
once: true,
async run({ client }) {
console.log(`Logged in as ${client.user?.tag}!`);
}
}export default event
```