mirror of
https://github.com/sern-handler/create-bot
synced 2026-06-06 01:16:53 +00:00
feat: add templates
This commit is contained in:
3
template-ts/.gitignore
vendored
Normal file
3
template-ts/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/node_modules
|
||||
/dist
|
||||
.env
|
||||
1
template-ts/README.md
Normal file
1
template-ts/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# TODO
|
||||
25
template-ts/package.json
Normal file
25
template-ts/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "ts-example",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc",
|
||||
"start": "tsc && node ./dist/index.js"
|
||||
},
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"sern",
|
||||
"discord.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sern/handler": "^3.0.0",
|
||||
"discord.js": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25",
|
||||
"typescript": "^5.0"
|
||||
}
|
||||
}
|
||||
11
template-ts/src/commands/ping.ts
Normal file
11
template-ts/src/commands/ping.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { commandModule, CommandType } from '@sern/handler';
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Both,
|
||||
plugins: [],
|
||||
description: 'A ping command',
|
||||
//alias : [],
|
||||
execute: async (ctx, args) => {
|
||||
await ctx.reply('Pong 🏓');
|
||||
},
|
||||
});
|
||||
41
template-ts/src/index.ts
Normal file
41
template-ts/src/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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.
|
||||
* 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
|
||||
*/
|
||||
async function init() {
|
||||
await makeDependencies({
|
||||
build: (root) =>
|
||||
root.add({ '@sern/client': single(() => client) })
|
||||
});
|
||||
|
||||
//View docs for all options
|
||||
Sern.init({
|
||||
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
|
||||
commands: 'dist/commands',
|
||||
// events: 'dist/events' (optional),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
client.login();
|
||||
16
template-ts/tsconfig.json
Normal file
16
template-ts/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"target": "ESNext",
|
||||
"module": "CommonJS",
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"importsNotUsedAsValues": "error",
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user