feat: add templates

This commit is contained in:
Jacob Nguyen
2023-06-09 00:16:12 -05:00
parent 5485cbeca9
commit 82c84a725f
28 changed files with 381 additions and 14 deletions

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

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

1
template-ts/README.md Normal file
View File

@@ -0,0 +1 @@
# TODO

25
template-ts/package.json Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "ts-example",
"version": "1.0.0",
"private": true,
"description": "",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"start": "tsc && node ./dist/index.js"
},
"keywords": [
"typescript",
"sern",
"discord.js"
],
"dependencies": {
"@sern/handler": "^3.0.0",
"discord.js": "latest"
},
"devDependencies": {
"@types/node": "^17.0.25",
"typescript": "^5.0"
}
}

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 🏓');
},
});

41
template-ts/src/index.ts Normal file
View File

@@ -0,0 +1,41 @@
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.
* 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
*/
async function init() {
await makeDependencies({
build: (root) =>
root.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),
});
}
client.login();

16
template-ts/tsconfig.json Normal file
View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"target": "ESNext",
"module": "CommonJS",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"esModuleInterop": true,
"noImplicitAny": true,
"strictNullChecks": true,
"importsNotUsedAsValues": "error",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}