From c5de36bfcadd3c3dfa48717aafbc79f0a1350b6a Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 24 Dec 2023 00:25:19 -0600 Subject: [PATCH] antoher template --- metadata/templateChoices.json | 5 +++++ template-js+cli/.env.example | 3 +++ template-js+cli/.gitignore | 2 ++ template-js+cli/README.md | 15 +++++++++++++ template-js+cli/jsconfig.json | 3 +++ template-js+cli/package.json | 26 ++++++++++++++++++++++ template-js+cli/src/commands/ping.js | 11 ++++++++++ template-js+cli/src/index.js | 32 ++++++++++++++++++++++++++++ template-ts+cli/README.md | 7 +++++- 9 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 template-js+cli/.env.example create mode 100644 template-js+cli/.gitignore create mode 100644 template-js+cli/README.md create mode 100644 template-js+cli/jsconfig.json create mode 100644 template-js+cli/package.json create mode 100644 template-js+cli/src/commands/ping.js create mode 100644 template-js+cli/src/index.js diff --git a/metadata/templateChoices.json b/metadata/templateChoices.json index aa137f5..b9b72c6 100644 --- a/metadata/templateChoices.json +++ b/metadata/templateChoices.json @@ -3,6 +3,11 @@ "title": "Typescript w/ sern cli & ESM", "value": "ts+cli" }, + { + "title": "Javascript w/ sern cli & ESM", + "value": "js+cli" + }, + { "title": "Typescript", "value": "ts" diff --git a/template-js+cli/.env.example b/template-js+cli/.env.example new file mode 100644 index 0000000..88ef9fd --- /dev/null +++ b/template-js+cli/.env.example @@ -0,0 +1,3 @@ +DISCORD_TOKEN=YOUR_DISCORD_TOKEN +APPLICATION_ID=YOUR_DISCORD_BOT_USER_ID +NODE_ENV= diff --git a/template-js+cli/.gitignore b/template-js+cli/.gitignore new file mode 100644 index 0000000..7af7f04 --- /dev/null +++ b/template-js+cli/.gitignore @@ -0,0 +1,2 @@ +/node_modules +.env \ No newline at end of file diff --git a/template-js+cli/README.md b/template-js+cli/README.md new file mode 100644 index 0000000..872c0ab --- /dev/null +++ b/template-js+cli/README.md @@ -0,0 +1,15 @@ +# How to use + +1.) Build +``` +npm run build +``` +2.) Run +``` +node . +``` +3.) Publish +``` +npm run commands:publish +``` + diff --git a/template-js+cli/jsconfig.json b/template-js+cli/jsconfig.json new file mode 100644 index 0000000..8e3c033 --- /dev/null +++ b/template-js+cli/jsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./.sern/tsconfig.json" +} diff --git a/template-js+cli/package.json b/template-js+cli/package.json new file mode 100644 index 0000000..508308c --- /dev/null +++ b/template-js+cli/package.json @@ -0,0 +1,26 @@ +{ + "name": "js-example", + "version": "1.0.0", + "private": true, + "description": "", + "main": "dist/index.js", + "scripts": { + "build": "sern build", + "start": "node .", + "install": "sern build", + "commands:publish": "sern commands publish" + }, + "keywords": [ + "javascript", + "sern", + "discord.js" + ], + "dependencies": { + "@sern/handler": "^3.0.3", + "discord.js": "latest" + }, + "devDependencies": { + "@types/node": "^17.0.25" + }, + "type": "module" +} diff --git a/template-js+cli/src/commands/ping.js b/template-js+cli/src/commands/ping.js new file mode 100644 index 0000000..1bed7ca --- /dev/null +++ b/template-js+cli/src/commands/ping.js @@ -0,0 +1,11 @@ +import { CommandType, commandModule } from '@sern/handler'; + +export default commandModule({ + type: CommandType.Both, + plugins: [], //optional + description: 'A ping command', + //alias : [], + execute: async (ctx, args) => { + await ctx.reply('Pong 🏓'); + }, +}); diff --git a/template-js+cli/src/index.js b/template-js+cli/src/index.js new file mode 100644 index 0000000..067e083 --- /dev/null +++ b/template-js+cli/src/index.js @@ -0,0 +1,32 @@ +/// + +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: 'src/commands', + // events: 'src/events', //(optional) +}); + +client.login(); diff --git a/template-ts+cli/README.md b/template-ts+cli/README.md index d36ee06..872c0ab 100644 --- a/template-ts+cli/README.md +++ b/template-ts+cli/README.md @@ -4,7 +4,12 @@ ``` npm run build ``` -2.) +2.) Run ``` node . ``` +3.) Publish +``` +npm run commands:publish +``` +