diff --git a/template-js/package.json b/template-js/package.json index 1054475..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", @@ -16,7 +17,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/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 69e328f..813ab2d 100644 --- a/template-js/src/index.js +++ b/template-js/src/index.js @@ -1,7 +1,9 @@ /// import 'dotenv/config' +import * as config from './config.js' 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,14 +21,12 @@ 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 -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/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/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 f86abe2..67b47e7 100644 --- a/template-ts/src/index.ts +++ b/template-ts/src/index.ts @@ -1,7 +1,8 @@ import 'dotenv/config' +import * as config from './config.js' 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,14 +20,11 @@ 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 -Sern.init({ - defaultPrefix: '!', // removing defaultPrefix will shut down text commands - commands: 'dist/commands', - // events: 'dist/events', //(optional) -}); +Sern.init(config); await client.login()