mirror of
https://github.com/sern-handler/create-bot
synced 2026-06-06 01:16:53 +00:00
antoher template
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
"title": "Typescript w/ sern cli & ESM",
|
||||
"value": "ts+cli"
|
||||
},
|
||||
{
|
||||
"title": "Javascript w/ sern cli & ESM",
|
||||
"value": "js+cli"
|
||||
},
|
||||
|
||||
{
|
||||
"title": "Typescript",
|
||||
"value": "ts"
|
||||
|
||||
3
template-js+cli/.env.example
Normal file
3
template-js+cli/.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
DISCORD_TOKEN=YOUR_DISCORD_TOKEN
|
||||
APPLICATION_ID=YOUR_DISCORD_BOT_USER_ID
|
||||
NODE_ENV=<production OR development>
|
||||
2
template-js+cli/.gitignore
vendored
Normal file
2
template-js+cli/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/node_modules
|
||||
.env
|
||||
15
template-js+cli/README.md
Normal file
15
template-js+cli/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# How to use
|
||||
|
||||
1.) Build
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
2.) Run
|
||||
```
|
||||
node .
|
||||
```
|
||||
3.) Publish
|
||||
```
|
||||
npm run commands:publish
|
||||
```
|
||||
|
||||
3
template-js+cli/jsconfig.json
Normal file
3
template-js+cli/jsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "./.sern/tsconfig.json"
|
||||
}
|
||||
26
template-js+cli/package.json
Normal file
26
template-js+cli/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "js-example",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "sern build",
|
||||
"start": "node .",
|
||||
"install": "sern build",
|
||||
"commands:publish": "sern commands publish"
|
||||
},
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"sern",
|
||||
"discord.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sern/handler": "^3.0.3",
|
||||
"discord.js": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.25"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
11
template-js+cli/src/commands/ping.js
Normal file
11
template-js+cli/src/commands/ping.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { CommandType, commandModule } from '@sern/handler';
|
||||
|
||||
export default commandModule({
|
||||
type: CommandType.Both,
|
||||
plugins: [], //optional
|
||||
description: 'A ping command',
|
||||
//alias : [],
|
||||
execute: async (ctx, args) => {
|
||||
await ctx.reply('Pong 🏓');
|
||||
},
|
||||
});
|
||||
32
template-js+cli/src/index.js
Normal file
32
template-js+cli/src/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference path="dependencies.d.ts" />
|
||||
|
||||
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.
|
||||
* Use this function to access all of your dependencies.
|
||||
* This is used for external event modules as well
|
||||
*/
|
||||
await makeDependencies(({ add }) => {
|
||||
add('@sern/client', single(() => client));
|
||||
});
|
||||
|
||||
//View docs for all options
|
||||
Sern.init({
|
||||
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
|
||||
commands: 'src/commands',
|
||||
// events: 'src/events', //(optional)
|
||||
});
|
||||
|
||||
client.login();
|
||||
@@ -4,7 +4,12 @@
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
2.)
|
||||
2.) Run
|
||||
```
|
||||
node .
|
||||
```
|
||||
3.) Publish
|
||||
```
|
||||
npm run commands:publish
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user