Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dependencies, configs, and examples #5

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"$schema": "https://json.schemastore.org/commitlintrc.json",
"extends": ["@commitlint/config-angular"],
"rules": {
"type-enum": [
2,
"always",
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types", "typings"]
["chore", "build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test", "types"]
],
"scope-case": [0]
}
Expand Down
7 changes: 2 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"root": true,
"extends": "marine/prettier/node",
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"ignorePatterns": ["**/dist/*"],
"env": {
"jest": true
}
"ignorePatterns": ["**/dist/*"]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto eol=lf
pnpm-lock.yaml linguist-generated=true text=auto eol=lf
2 changes: 1 addition & 1 deletion .github/COMMIT_CONVENTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Messages must be matched by the following regex:

```js
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/;
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore|types)(\(.+\))?: .{1,72}/;
```

#### Examples
Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ is a great boon to your development process.
To get ready to work on the codebase, please do the following:

1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `npm clean-install` ([install](https://docs.npmjs.com/cli/v10/commands/npm-ci))
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Code your heart out!
4. Run `npm run format && npm run lint` to make sure your changes follow our coding style
4. Run `pnpm run format && pnpm run lint` to make sure your changes follow our coding style
5. [Submit a pull request](https://github.com/discordjs/voice-examples/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/voice-examples/blob/main/.github/COMMIT_CONVENTION.md))
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ body:
- type: input
id: djs-voice-version
attributes:
label: "@discordjs/version version"
label: '@discordjs/version version'
description: Which version of @discordjs/voice are you using? Run `npm list <package>` in your project directory and paste the output.
validations:
required: true
Expand All @@ -57,7 +57,7 @@ body:
description: |
Which version of Node.js are you using? Run `node --version` in your project directory and paste the output.
If you are using TypeScript, please include its version (`npm list typescript`) as well.
placeholder: Node.js version 16.9+ is required for version 14.0.0+
placeholder: Node.js version 18+ is required
sdanialraza marked this conversation as resolved.
Show resolved Hide resolved
validations:
required: true
- type: input
Expand Down
File renamed without changes.
16 changes: 9 additions & 7 deletions .github/workflows/test.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install node.js v16
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js v20
uses: actions/setup-node@v4
with:
node-version: 16
cache: 'npm'
cache-dependency-path: package-lock.json
node-version: 20
cache: 'pnpm'

- name: Turbo cache
id: turbo-cache
Expand All @@ -25,10 +27,10 @@ jobs:
turbo-${{ github.job }}-${{ github.ref_name }}-

- name: Install dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: ESLint
run: npm run lint -- --cache-dir=".turbo"
run: pnpm run lint --concurrency=4 -- --format=compact

- name: Build
run: npm run build -- --cache-dir=".turbo"
run: pnpm run build --concurrency=4
27 changes: 18 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Packages
node_modules/
node_modules

# Log files
logs/
logs
*.log
npm-debug.log*

Expand All @@ -15,18 +15,29 @@ pids
.env

# Dist
dist/
dist
dist-docs

# Miscellaneous
.tmp/
.tmp
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea/
.idea
.DS_Store
.turbo
tsconfig.tsbuildinfo
coverage/
coverage
out
package.tgz
tsup.config.bundled*
vitest.config.ts.timestamp*

# Deno
deno.lock

# Bun
bun.lockb

# yarn
.pnp.*
Expand All @@ -40,6 +51,4 @@ coverage/
# Cache
.prettiercache
.eslintcache

# Possible config files
config.json
.vercel
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
pnpm exec commitlint --edit $1
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run build:check && npm run lint
pnpm run build:check && pnpm run lint
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A list of ready-to-run examples for `@discordjs/voice`.

## How to try them out

All you have to do is copy the example directory of your choosing, install the dependencies, fill in the `config.json` file, and run `npm run start`.
All you have to do is copy the example directory of your choosing, install the dependencies, fill in the `.env` file, and run `npm run start`.

## Links

Expand Down
1 change: 1 addition & 0 deletions _base/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOKEN=
7 changes: 2 additions & 5 deletions _base/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"root": true,
"extends": "marine/prettier/node",
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"ignorePatterns": ["**/dist/*"],
"env": {
"jest": true
}
"ignorePatterns": ["**/dist/*"]
}
2 changes: 1 addition & 1 deletion _base/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
config.json
.env
tsconfig.tsbuildinfo
dist
1 change: 1 addition & 0 deletions _base/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
Expand Down
6 changes: 3 additions & 3 deletions _base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The template to use when creating a new example for voice. Steps to follow:
$ npm install
$ npm run build

# Set a bot token (see config.example.json)
$ cp config.example.json config.json
$ nano config.json
# Set a bot token (see .env.example)
$ cp .env.example .env
$ nano .env

# Start the bot!
$ npm start
Expand Down
3 changes: 0 additions & 3 deletions _base/config.example.json

This file was deleted.

36 changes: 16 additions & 20 deletions _base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,30 @@
"name": "@discordjs/voice-examples-base",
"version": "0.0.1",
"description": "An example receiver bot written using @discordjs/voice",
"main": "dist/bot.js",
"main": "dist/index.js",
"type": "module",
"scripts": {
"start": "npm run build && node dist/bot",
"build": "rimraf dist && tsc",
"build:check": "tsc --noEmit --incremental false",
"lint": "prettier --cache --check . && eslint src --ext mjs,js,ts --cache",
"format": "prettier --cache --write . && eslint src --ext mjs,js,ts --fix --cache",
"build": "rimraf dist && tsc",
"build:check": "tsc --noEmit --incremental false"
"start": "npm run build && node --env-file=.env dist/index.js"
},
"author": "Amish Shah <[email protected]>",
"author": "Amish Shah <[email protected]>",
"license": "MIT",
"dependencies": {
"@discordjs/opus": "^0.8.0",
"@discordjs/voice": "^0.11.0",
"discord-api-types": "^0.33.5",
"discord.js": "^13.10.3",
"libsodium-wrappers": "^0.7.10",
"@discordjs/opus": "^0.9.0",
"@discordjs/voice": "^0.17.0",
"discord.js": "^14.15.3",
"libsodium-wrappers": "^0.7.13",
"prism-media": "^2.0.0-alpha.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"eslint": "^8.23.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.5.0",
"eslint-plugin-import": "^2.26.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "^4.8.2"
"@types/node": "^20.14.7",
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.62",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"typescript": "5.4.5"
}
}
12 changes: 0 additions & 12 deletions _base/src/bot.ts

This file was deleted.

8 changes: 8 additions & 0 deletions _base/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import process from 'node:process';
import { Client, GatewayIntentBits } from 'discord.js';

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates],
});

await client.login(process.env.TOKEN);
38 changes: 23 additions & 15 deletions _base/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
// Mapped from https://www.typescriptlang.org/tsconfig
"compilerOptions": {
// Type Checking
Expand All @@ -8,39 +9,46 @@
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"useUnknownInCatchVariables": true,
"noUncheckedIndexedAccess": true,
"skipLibCheck": true,

// Modules
"module": "CommonJS",
"moduleResolution": "node",
"allowArbitraryExtensions": false,
"allowImportingTsExtensions": false,
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,

// Emit
"declaration": true,
"importHelpers": true,
"importsNotUsedAsValues": "error",
"inlineSources": true,
"declarationMap": true,
"importHelpers": false,
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"preserveConstEnums": true,
"removeComments": false,
"sourceMap": true,
"esModuleInterop": true,

// Interop Constraints
"allowSyntheticDefaultImports": true,
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,

// Language and Environment
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["ESNext"],
"target": "ES2021",
"useDefineForClassFields": true
"lib": ["ESNext", "esnext.disposable"],
"target": "ESNext",
"useDefineForClassFields": true,

// Completeness
"skipLibCheck": true
},
"include": ["src/*.ts"],
"exclude": []
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions basic/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOKEN=
7 changes: 2 additions & 5 deletions basic/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"root": true,
"extends": "marine/prettier/node",
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"ignorePatterns": ["**/dist/*"],
"env": {
"jest": true
}
"ignorePatterns": ["**/dist/*"]
}
2 changes: 1 addition & 1 deletion basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
config.json
.env
tsconfig.tsbuildinfo
dist
1 change: 1 addition & 0 deletions basic/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,
Expand Down
Loading