From fa3b220a872e696a5e02d6db2a46f99d493c431a Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 23 Dec 2023 16:07:19 -0600 Subject: [PATCH] prepare new template --- metadata/templateChoices.json | 9 ++++-- template-ts-esm/src/index.ts | 24 ++++++++-------- template-ts-integrated/.env.example | 3 ++ template-ts-integrated/.gitignore | 3 ++ template-ts-integrated/README.md | 10 +++++++ template-ts-integrated/package.json | 26 +++++++++++++++++ template-ts-integrated/src/commands/ping.ts | 11 ++++++++ template-ts-integrated/src/index.ts | 31 +++++++++++++++++++++ template-ts-integrated/tsconfig.json | 3 ++ 9 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 template-ts-integrated/.env.example create mode 100644 template-ts-integrated/.gitignore create mode 100644 template-ts-integrated/README.md create mode 100644 template-ts-integrated/package.json create mode 100644 template-ts-integrated/src/commands/ping.ts create mode 100644 template-ts-integrated/src/index.ts create mode 100644 template-ts-integrated/tsconfig.json diff --git a/metadata/templateChoices.json b/metadata/templateChoices.json index 28a3e4b..cac0dd5 100644 --- a/metadata/templateChoices.json +++ b/metadata/templateChoices.json @@ -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" } -] \ No newline at end of file +] diff --git a/template-ts-esm/src/index.ts b/template-ts-esm/src/index.ts index d79c84b..d7e44ea 100644 --- a/template-ts-esm/src/index.ts +++ b/template-ts-esm/src/index.ts @@ -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(); diff --git a/template-ts-integrated/.env.example b/template-ts-integrated/.env.example new file mode 100644 index 0000000..88ef9fd --- /dev/null +++ b/template-ts-integrated/.env.example @@ -0,0 +1,3 @@ +DISCORD_TOKEN=YOUR_DISCORD_TOKEN +APPLICATION_ID=YOUR_DISCORD_BOT_USER_ID +NODE_ENV= diff --git a/template-ts-integrated/.gitignore b/template-ts-integrated/.gitignore new file mode 100644 index 0000000..c7fb7a4 --- /dev/null +++ b/template-ts-integrated/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/dist +.env \ No newline at end of file diff --git a/template-ts-integrated/README.md b/template-ts-integrated/README.md new file mode 100644 index 0000000..d36ee06 --- /dev/null +++ b/template-ts-integrated/README.md @@ -0,0 +1,10 @@ +# How to use + +1.) Build +``` +npm run build +``` +2.) +``` +node . +``` diff --git a/template-ts-integrated/package.json b/template-ts-integrated/package.json new file mode 100644 index 0000000..1f8459c --- /dev/null +++ b/template-ts-integrated/package.json @@ -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" +} diff --git a/template-ts-integrated/src/commands/ping.ts b/template-ts-integrated/src/commands/ping.ts new file mode 100644 index 0000000..18a7d3a --- /dev/null +++ b/template-ts-integrated/src/commands/ping.ts @@ -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 🏓'); + }, +}); diff --git a/template-ts-integrated/src/index.ts b/template-ts-integrated/src/index.ts new file mode 100644 index 0000000..ec0a1db --- /dev/null +++ b/template-ts-integrated/src/index.ts @@ -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() diff --git a/template-ts-integrated/tsconfig.json b/template-ts-integrated/tsconfig.json new file mode 100644 index 0000000..8e3c033 --- /dev/null +++ b/template-ts-integrated/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./.sern/tsconfig.json" +}