From 18d459e486fd391ce2737e444759983a6b99da1d Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 13 Aug 2022 11:26:08 -0500 Subject: [PATCH] feat: add esm template (#13) --- templates/javascript-esm/.gitignore | 1 + templates/javascript-esm/README.md | 1 + templates/javascript-esm/package.json | 23 +++++++++++++++++++ templates/javascript-esm/src/commands/ping.js | 11 +++++++++ templates/javascript-esm/src/index.js | 20 ++++++++++++++++ templates/javascript/package.json | 4 ++-- templates/typescript/package.json | 4 ++-- 7 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 templates/javascript-esm/.gitignore create mode 100644 templates/javascript-esm/README.md create mode 100644 templates/javascript-esm/package.json create mode 100644 templates/javascript-esm/src/commands/ping.js create mode 100644 templates/javascript-esm/src/index.js diff --git a/templates/javascript-esm/.gitignore b/templates/javascript-esm/.gitignore new file mode 100644 index 0000000..30bc162 --- /dev/null +++ b/templates/javascript-esm/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/templates/javascript-esm/README.md b/templates/javascript-esm/README.md new file mode 100644 index 0000000..4640904 --- /dev/null +++ b/templates/javascript-esm/README.md @@ -0,0 +1 @@ +# TODO diff --git a/templates/javascript-esm/package.json b/templates/javascript-esm/package.json new file mode 100644 index 0000000..fc4d346 --- /dev/null +++ b/templates/javascript-esm/package.json @@ -0,0 +1,23 @@ +{ + "name": "js-esm-example", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "javacsript", + "sern", + "discord.js" + ], + "license": "UNLICENSED", + "dependencies": { + "@sern/handler": "^1.1.9-beta", + "discord.js": "^14.2.0" + }, + "devDependencies": { + "@types/node": "^17.0.25" + }, + "type": "module" +} diff --git a/templates/javascript-esm/src/commands/ping.js b/templates/javascript-esm/src/commands/ping.js new file mode 100644 index 0000000..6f2d40b --- /dev/null +++ b/templates/javascript-esm/src/commands/ping.js @@ -0,0 +1,11 @@ +import { CommandType, commandModule } 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/templates/javascript-esm/src/index.js b/templates/javascript-esm/src/index.js new file mode 100644 index 0000000..e61e213 --- /dev/null +++ b/templates/javascript-esm/src/index.js @@ -0,0 +1,20 @@ +import { Client, GatewayIntentBits } from 'discord.js'; +import { Sern } from '@sern/handler'; + +const client = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, // Make sure this is enabled for text commands! + ], +}); +//View docs for all options +Sern.init({ + client, + defaultPrefix: '!', // removing defaultPrefix will shut down text commands + commands: 'src/commands', + // events: 'src/events' (optional), +}); + +client.login(); diff --git a/templates/javascript/package.json b/templates/javascript/package.json index 1da2fa1..fd41535 100644 --- a/templates/javascript/package.json +++ b/templates/javascript/package.json @@ -13,8 +13,8 @@ ], "license": "UNLICENSED", "dependencies": { - "@sern/handler": "^1.1.5-beta", - "discord.js": "^14.0.3" + "@sern/handler": "^1.1.9-beta", + "discord.js": "^14.2.0" }, "devDependencies": { "@types/node": "^17.0.25" diff --git a/templates/typescript/package.json b/templates/typescript/package.json index e0a4943..161ac1b 100644 --- a/templates/typescript/package.json +++ b/templates/typescript/package.json @@ -13,8 +13,8 @@ ], "license": "UNLICENSED", "dependencies": { - "@sern/handler": "^1.1.5-beta", - "discord.js": "^14.0.3" + "@sern/handler": "^1.1.9-beta", + "discord.js": "^14.2.0" }, "devDependencies": { "@types/node": "^17.0.25",