prepare new template

This commit is contained in:
Jacob Nguyen
2023-12-23 16:07:19 -06:00
parent 15edc07f29
commit fa3b220a87
9 changed files with 105 additions and 15 deletions

View File

@@ -1,8 +1,13 @@
[
{
{
"title": "Typescript Integrated (uses sern cli)",
"value": "ts-integrated"
},
{
"title": "Typescript",
"value": "ts"
},
{
"title": "Typescript with ESM",
"value": "ts-esm"
@@ -15,4 +20,4 @@
"title": "Javascript with ESM",
"value": "js-esm"
}
]
]

View File

@@ -11,23 +11,21 @@ const client = new Client({
});
/**
* Where all of your dependencies are composed.
* '@sern/client' is usually your Discord Client.
* View documentation for pluggable dependencies
* Configure your dependency root to your liking.
* It follows the npm package iti https://itijs.org/.
* Use this function to access all of your dependencies.
* This is used for external event modules as well
*/
await makeDependencies({
build: (root) => root.add({ '@sern/client': single(() => client) }),
* Where all of your dependencies are composed.
* '@sern/client' is usually your Discord Client.
* Use this function to access all of your dependencies.
* This is used for external event modules as well
*/
await makeDependencies(({ add }) => {
add('@sern/client', single(() => client));
});
//View docs for all options
Sern.init({
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
commands: 'dist/commands',
// events: 'dist/events', //(optional)
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
commands: 'dist/commands',
// events: 'dist/events', //(optional)
});
client.login();

View File

@@ -0,0 +1,3 @@
DISCORD_TOKEN=YOUR_DISCORD_TOKEN
APPLICATION_ID=YOUR_DISCORD_BOT_USER_ID
NODE_ENV=<production OR development>

3
template-ts-integrated/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/node_modules
/dist
.env

View File

@@ -0,0 +1,10 @@
# How to use
1.) Build
```
npm run build
```
2.)
```
node .
```

View File

@@ -0,0 +1,26 @@
{
"name": "ts-example",
"version": "1.0.0",
"private": true,
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "sern build",
"start": "node .",
"commands:publish": "sern commands publish"
},
"keywords": [
"typescript",
"sern",
"discord.js"
],
"dependencies": {
"@sern/handler": "^3.0.3",
"discord.js": "latest"
},
"devDependencies": {
"@types/node": "^17.0.25",
"typescript": "^5.0"
},
"type": "module"
}

View File

@@ -0,0 +1,11 @@
import { commandModule, CommandType } from '@sern/handler';
export default commandModule({
type: CommandType.Both,
plugins: [],
description: 'A ping command',
//alias : [],
execute: async (ctx, args) => {
await ctx.reply('Pong 🏓');
},
});

View File

@@ -0,0 +1,31 @@
import { Client, GatewayIntentBits } from 'discord.js';
import { Sern, single, makeDependencies } from '@sern/handler';
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent, //Make sure this is enabled for text commands!
],
});
/**
* Where all of your dependencies are composed.
* '@sern/client' is usually your Discord Client.
* Use this function to access all of your dependencies.
* This is used for external event modules as well
*/
await makeDependencies(({ add }) => {
add('@sern/client', single(() => client));
});
//View docs for all options
Sern.init({
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
commands: 'dist/commands',
// events: 'dist/events', //(optional)
});
await client.login()

View File

@@ -0,0 +1,3 @@
{
"extends": "./.sern/tsconfig.json"
}