mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
feat: create-discord-bot (#9420)
* feat: basic initialisation * fix: no scope * chore: add options for issues * feat: good word, Monbrey * feat: basic README.md * fix: no documentation for this * feat: install for them * chore: update licencing * chore: fix year * fix: build tsup * feat: add TypeScript option * feat: add `name` option * chore: ignore annoying errors * chore: add tsconfig.json * refactor: remove name We can just use the name of the directory instead. * chore: update cliff jumper rc * chore: bump dependencies * chore: bump dependencies * fix: build in prepack * fix: configure ESLint correctly * feat: infer package manager * docs(packageManager): document `install()` * fix(packageManager): do not emit a warning for `npm` * refactor: change project name colour to yellow * docs(constants): basic documentation * feat: add link * chore: add `verbatimModuleSyntax` * chore: bump discord.js * refactor: switch to @sapphire/ts-config * refactor: file name changes * refactor: tweak description * chore: update yarn.lock * fix: add .env * chore: bump dependencies * feat: event handler * refactor: use `default` * refactor: simpler event * chore: bump discord.js * fix: add release script and reorder * style: reorder package.json * chore: remove unneeded ignores * chore: bump minimum Node.js version * chore: add @types/node to TypeScript package.json * chore: apply requested changes Co-authored-by: Noel <buechler.noel@outlook.com> * style: run ESLint + Prettier * refactor: prefer "the" * refactor: remove some comments * feat: add ESLint + Prettier * chore: requested changes Co-authored-by: Noel <buechler.noel@outlook.com> * chore: more requested changes Co-authored-by: Noel <buechler.noel@outlook.com> --------- Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
1
packages/create-discord-bot/template/JavaScript/.env
Normal file
1
packages/create-discord-bot/template/JavaScript/.env
Normal file
@@ -0,0 +1 @@
|
||||
DISCORD_TOKEN=
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": ["neon/common", "neon/node", "neon/prettier"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"quoteProps": "as-needed",
|
||||
"trailingComma": "all",
|
||||
"endOfLine": "lf"
|
||||
}
|
||||
21
packages/create-discord-bot/template/JavaScript/package.json
Normal file
21
packages/create-discord-bot/template/JavaScript/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "[REPLACE-NAME]",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"lint": "prettier --check . && eslint src --ext .js,.cjs --format=pretty",
|
||||
"format": "prettier --write . && eslint src --ext .js,.cjs --fix --format=pretty",
|
||||
"start": "node --require dotenv/config index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"discord.js": "^14.11.0",
|
||||
"dotenv": "^16.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.40.0",
|
||||
"eslint-config-neon": "^0.1.47",
|
||||
"eslint-formatter-pretty": "^5.0.0",
|
||||
"prettier": "^2.8.8"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Events } from 'discord.js';
|
||||
|
||||
export default {
|
||||
name: Events.ClientReady,
|
||||
once: true,
|
||||
async execute(client) {
|
||||
console.log(`Ready! Logged in as ${client.user.tag}`);
|
||||
},
|
||||
};
|
||||
15
packages/create-discord-bot/template/JavaScript/src/index.js
Normal file
15
packages/create-discord-bot/template/JavaScript/src/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { readdir } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
||||
const eventsPath = fileURLToPath(new URL('events', import.meta.url));
|
||||
const eventFiles = await readdir(eventsPath).then((files) => files.filter((file) => file.endsWith('.js')));
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const event = (await import(join(eventsPath, file))).default;
|
||||
client[event.data.once ? 'once' : 'on'](event.data.name, async (...args) => event.data.execute(...args));
|
||||
}
|
||||
|
||||
void client.login();
|
||||
Reference in New Issue
Block a user