mirror of
https://github.com/sern-handler/templates
synced 2026-06-05 17:06:56 +00:00
feat!: templates for sern v2 (#19)
This commit is contained in:
2
.github/workflows/linter.yml
vendored
2
.github/workflows/linter.yml
vendored
@@ -29,4 +29,4 @@ jobs:
|
||||
run: npm i
|
||||
|
||||
- name: Run linters
|
||||
run: npm run format
|
||||
run: npm run format
|
||||
|
||||
2
templates/javascript-esm/.gitignore
vendored
2
templates/javascript-esm/.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
/node_modules
|
||||
/node_modules
|
||||
.env
|
||||
@@ -13,8 +13,8 @@
|
||||
],
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^1.0.0",
|
||||
"discord.js": "^14.2.0"
|
||||
"@sern/handler": "^2.0.0",
|
||||
"discord.js": "^14.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import { Sern } from '@sern/handler';
|
||||
import { Sern, single, DefaultLogging } from '@sern/handler';
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
@@ -9,12 +9,31 @@ const client = new Client({
|
||||
GatewayIntentBits.MessageContent, // Make sure this is enabled for text commands!
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export const useContainer = Sern.makeDependencies({
|
||||
build: (root) =>
|
||||
root
|
||||
.add({ '@sern/client': single(client) })
|
||||
.add({ '@sern/logger': single(new DefaultLogging()) }),
|
||||
});
|
||||
|
||||
//View docs for all options
|
||||
Sern.init({
|
||||
client,
|
||||
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
|
||||
commands: 'src/commands',
|
||||
// events: 'src/events' (optional),
|
||||
containerConfig: {
|
||||
get: useContainer,
|
||||
},
|
||||
});
|
||||
|
||||
client.login();
|
||||
|
||||
2
templates/javascript/.gitignore
vendored
2
templates/javascript/.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
/node_modules
|
||||
/node_modules
|
||||
.env
|
||||
@@ -13,8 +13,8 @@
|
||||
],
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^1.0.0",
|
||||
"discord.js": "^14.2.0"
|
||||
"@sern/handler": "^2.0.0",
|
||||
"discord.js": "^14.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const { Sern } = require('@sern/handler');
|
||||
const { Sern, single, DefaultLogging } = require('@sern/handler');
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
@@ -9,12 +9,31 @@ const client = new Client({
|
||||
GatewayIntentBits.MessageContent, // Make sure this is enabled for text commands!
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export const useContainer = Sern.makeDependencies({
|
||||
build: (root) =>
|
||||
root
|
||||
.add({ '@sern/client': single(client) })
|
||||
.add({ '@sern/logger': single(new DefaultLogging()) }),
|
||||
});
|
||||
|
||||
//View docs for all options
|
||||
Sern.init({
|
||||
client,
|
||||
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
|
||||
commands: 'src/commands',
|
||||
// events: 'src/events' (optional),
|
||||
containerConfig: {
|
||||
get: useContainer,
|
||||
},
|
||||
});
|
||||
|
||||
client.login();
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
],
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^1.0.0",
|
||||
"discord.js": "^14.2.0"
|
||||
"@sern/handler": "^2.0.0",
|
||||
"discord.js": "^14.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25",
|
||||
"typescript": "^4.6.3"
|
||||
"typescript": "^4.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import { Sern } from '@sern/handler';
|
||||
import {
|
||||
Dependencies,
|
||||
Sern,
|
||||
single,
|
||||
Singleton,
|
||||
DefaultLogging,
|
||||
} from '@sern/handler';
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
@@ -9,12 +15,36 @@ const client = new Client({
|
||||
GatewayIntentBits.MessageContent, //Make sure this is enabled for text commands!
|
||||
],
|
||||
});
|
||||
|
||||
//With typescript, you can customize / augment your typings.
|
||||
interface MyDependencies extends Dependencies {
|
||||
'@sern/client': Singleton<Client>;
|
||||
'@sern/logger': Singleton<DefaultLogging>;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export const useContainer = Sern.makeDependencies<MyDependencies>({
|
||||
build: (root) =>
|
||||
root
|
||||
.add({ '@sern/client': single(client) })
|
||||
.add({ '@sern/logger': single(new DefaultLogging()) }),
|
||||
});
|
||||
|
||||
//View docs for all options
|
||||
Sern.init({
|
||||
client,
|
||||
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
|
||||
commands: 'dist/commands',
|
||||
// events: 'dist/events' (optional),
|
||||
containerConfig: {
|
||||
get: useContainer,
|
||||
},
|
||||
});
|
||||
|
||||
client.login();
|
||||
|
||||
Reference in New Issue
Block a user