From 26de63dc4b7660cdd960f6da4e7bf6aaa6013df2 Mon Sep 17 00:00:00 2001 From: jacob Date: Mon, 1 Jul 2024 21:38:37 -0500 Subject: [PATCH 1/3] y --- template-js/package.json | 3 ++- template-js/src/index.js | 6 ++++-- template-ts/package.json | 3 ++- template-ts/src/index.ts | 7 ++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/template-js/package.json b/template-js/package.json index 1054475..4446ee8 100644 --- a/template-js/package.json +++ b/template-js/package.json @@ -16,7 +16,8 @@ "dependencies": { "@sern/handler": "^3.0.3", "discord.js": "latest", - "dotenv": "^16.3.1" + "dotenv": "^16.3.1", + "@sern/publisher": "^1.0.0" }, "devDependencies": { "@types/node": "^18.0.25" diff --git a/template-js/src/index.js b/template-js/src/index.js index 69e328f..b9cf272 100644 --- a/template-js/src/index.js +++ b/template-js/src/index.js @@ -1,7 +1,8 @@ /// import 'dotenv/config' import { Client, GatewayIntentBits } from 'discord.js'; -import { Sern, single, makeDependencies } from '@sern/handler'; +import { Sern, makeDependencies } from '@sern/handler'; +import { Publisher } from '@sern/publisher' const client = new Client({ intents: [ @@ -19,7 +20,8 @@ const client = new Client({ * This is used for external event modules as well */ await makeDependencies(({ add }) => { - add('@sern/client', single(() => client)); + add('@sern/client', client); + add('publisher', new Publisher()); }); //View docs for all options diff --git a/template-ts/package.json b/template-ts/package.json index 23c392d..85155ef 100644 --- a/template-ts/package.json +++ b/template-ts/package.json @@ -18,7 +18,8 @@ "dependencies": { "@sern/handler": "^3.0.3", "discord.js": "latest", - "dotenv": "^16.3.1" + "dotenv": "^16.3.1", + "@sern/publisher": "^1.0.0" }, "devDependencies": { "@types/node": "^17.0.25", diff --git a/template-ts/src/index.ts b/template-ts/src/index.ts index f86abe2..5b0d9f3 100644 --- a/template-ts/src/index.ts +++ b/template-ts/src/index.ts @@ -1,7 +1,7 @@ import 'dotenv/config' import { Client, GatewayIntentBits } from 'discord.js'; -import { Sern, single, makeDependencies } from '@sern/handler'; - +import { Sern, makeDependencies } from '@sern/handler'; +import { Publisher } from '@sern/publisher' const client = new Client({ intents: [ GatewayIntentBits.Guilds, @@ -19,7 +19,8 @@ const client = new Client({ * This is used for external event modules as well */ await makeDependencies(({ add }) => { - add('@sern/client', single(() => client)); + add('@sern/client', client); + add('publisher', new Publisher()); }); //View docs for all options From 1a7df4d29298175650fe1d9e46432c43a4c32f1c Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 16 Jul 2024 23:38:14 -0500 Subject: [PATCH 2/3] add config file setup, more flexible --- template-js/package.json | 5 +++-- template-js/src/config.js | 13 +++++++++++++ template-js/src/index.js | 8 +++----- template-ts/src/config.ts | 13 +++++++++++++ template-ts/src/index.ts | 7 ++----- 5 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 template-js/src/config.js create mode 100644 template-ts/src/config.ts diff --git a/template-js/package.json b/template-js/package.json index 4446ee8..b93100e 100644 --- a/template-js/package.json +++ b/template-js/package.json @@ -3,10 +3,11 @@ "version": "1.0.0", "private": true, "description": "", - "main": "src/index.js", + "main": "dist/index.js", "scripts": { "start": "node .", - "commands:publish": "sern commands publish" + "commands:publish": "sern commands publish", + "build": "sern build" }, "keywords": [ "javascript", diff --git a/template-js/src/config.js b/template-js/src/config.js new file mode 100644 index 0000000..31bdebe --- /dev/null +++ b/template-js/src/config.js @@ -0,0 +1,13 @@ +//CONFIG FILE: export only data here and do not cause side effects. Feel free to add your own configuration to this file. + +//commands directory. REQUIRED +export const commands = './dist/commands' +// events directory. +export const events = './dist/events' + +// schedule tasks and declare them here +export const tasks = './dist/tasks' + +// defaultPrefix: if omitted, sern will disable all text/prefix commands +export const defaultPrefix = '?' + diff --git a/template-js/src/index.js b/template-js/src/index.js index b9cf272..db04931 100644 --- a/template-js/src/index.js +++ b/template-js/src/index.js @@ -1,5 +1,6 @@ /// import 'dotenv/config' +import * as config from './config.js' import { Client, GatewayIntentBits } from 'discord.js'; import { Sern, makeDependencies } from '@sern/handler'; import { Publisher } from '@sern/publisher' @@ -21,14 +22,11 @@ const client = new Client({ */ await makeDependencies(({ add }) => { add('@sern/client', client); + add('publisher', new Publisher()); }); //View docs for all options -Sern.init({ - defaultPrefix: '!', // removing defaultPrefix will shut down text commands - commands: 'src/commands', - // events: 'src/events', //(optional) -}); +Sern.init(config); client.login(); diff --git a/template-ts/src/config.ts b/template-ts/src/config.ts new file mode 100644 index 0000000..31bdebe --- /dev/null +++ b/template-ts/src/config.ts @@ -0,0 +1,13 @@ +//CONFIG FILE: export only data here and do not cause side effects. Feel free to add your own configuration to this file. + +//commands directory. REQUIRED +export const commands = './dist/commands' +// events directory. +export const events = './dist/events' + +// schedule tasks and declare them here +export const tasks = './dist/tasks' + +// defaultPrefix: if omitted, sern will disable all text/prefix commands +export const defaultPrefix = '?' + diff --git a/template-ts/src/index.ts b/template-ts/src/index.ts index 5b0d9f3..67b47e7 100644 --- a/template-ts/src/index.ts +++ b/template-ts/src/index.ts @@ -1,4 +1,5 @@ import 'dotenv/config' +import * as config from './config.js' import { Client, GatewayIntentBits } from 'discord.js'; import { Sern, makeDependencies } from '@sern/handler'; import { Publisher } from '@sern/publisher' @@ -24,10 +25,6 @@ await makeDependencies(({ add }) => { }); //View docs for all options -Sern.init({ - defaultPrefix: '!', // removing defaultPrefix will shut down text commands - commands: 'dist/commands', - // events: 'dist/events', //(optional) -}); +Sern.init(config); await client.login() From aa7fc6b627439bcff7fb245a89b7222d4d002a97 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:40:08 -0500 Subject: [PATCH 3/3] yea --- template-js/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template-js/src/index.js b/template-js/src/index.js index db04931..813ab2d 100644 --- a/template-js/src/index.js +++ b/template-js/src/index.js @@ -3,7 +3,7 @@ import 'dotenv/config' import * as config from './config.js' import { Client, GatewayIntentBits } from 'discord.js'; import { Sern, makeDependencies } from '@sern/handler'; -import { Publisher } from '@sern/publisher' +import { Publisher } from '@sern/publisher' const client = new Client({ intents: [