Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 85f7b36

Browse files
committed
feat!: v6.0.0
1 parent 0520557 commit 85f7b36

File tree

94 files changed

+728
-5792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+728
-5792
lines changed

.env.example

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
1-
# This file contains all the environment variables that are used by the bot.
1+
# This file contains all the environment variables used by the application.
2+
# Copy this to a new file named ".env" in the same location, and fill in the values for the variables.
23

3-
# For production use, set NODE_ENV to production
4-
# For development use, set NODE_ENV to development
4+
# Required: For production use, set NODE_ENV to production, for local development, set it to development
55
NODE_ENV=development
66

77
# Required: Login credentials for the bot
88
# Retrieve your bot token and application id from https://discordapp.com/developers/applications/me
9+
# Do NOT share your bot token with anyone, as it can be used to control your bot.
910
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN
1011
DISCORD_APPLICATION_ID=YOUR_DISCORD_BOT_APPLICATION_ID
1112

12-
# Follow steps in README.md here to get authentication string: https://github.com/retrouser955/discord-player-youtubei
13+
# Run `npx --no discord-player-youtubei` to get authentication string
14+
# Follow steps in README.md here for more details: https://github.com/retrouser955/discord-player-youtubei#readme
1315
YT_EXTRACTOR_AUTH=
14-
15-
# Optional: Authentication tokens for botlist websites to automatically update server count, etc.
16-
# See /src/utils/postBotStats.js for more information
17-
BOTLIST_TOP_GG_API_TOKEN=
18-
BOTLIST_DISCORD_BOT_LIST_COM_API_TOKEN=
19-
BOTLIST_DISCORDS_COM_API_TOKEN=
20-
BOTLIST_DISCORD_BOTS_GG_API_TOKEN=
21-
BOTLIST_BOTLIST_ME_API_TOKEN=
22-
BOTLIST_DISCORDLIST_GG_API_TOKEN=
23-
BOTLIST_DISCORD_BOTLIST_EU_API_TOKEN=
24-
25-
# Optional: Only change this if you know what you are doing
26-
NODE_OPTIONS=
27-
UV_THREADPOOL_SIZE=
28-
29-
# Optional: Password/token for pushing logs to Loki
30-
LOKI_HOST=
31-
LOKI_AUTH_USERNAME=
32-
LOKI_AUTH_PASSWORD=

.prettierignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 12 deletions
This file was deleted.

Dockerfile

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,37 @@
44

55
ARG NODE_VERSION=20.12
66

7-
# Stage 1: Build and transpile TypeScript
8-
FROM node:${NODE_VERSION}-bookworm-slim as builder
7+
# Use Node.js image as the base image
8+
FROM node:${NODE_VERSION}-bookworm-slim
99

1010
# Set working directory
1111
WORKDIR /app
1212

1313
# Install build dependencies necessary for native modules and clean up in one layer
14-
RUN apt-get update && apt-get install -y python3 make build-essential \
14+
RUN apt-get update && apt-get install -y python3 make build-essential ffmpeg ca-certificates \
1515
&& apt-get clean && rm -rf /var/lib/apt/lists/*
1616

17+
# Install pnpm globally
18+
RUN npm install -g pnpm
19+
1720
# Copy only necessary source files
18-
COPY package*.json ./
19-
COPY tsconfig.json ./
20-
COPY src/ ./src/
21-
COPY config/ ./config/
22-
COPY locales/ ./locales/
21+
COPY package*.json ./
22+
COPY tsconfig.json ./
23+
COPY src/ ./src/
24+
COPY config/ ./config/
25+
COPY locales/ ./locales/
2326

2427
# Install node dependencies
25-
RUN npm ci
26-
27-
# Build the application
28-
RUN npm run build
29-
30-
# Remove development dependencies
31-
RUN npm prune --omit=dev
32-
33-
# Stage 2: Production environment
34-
FROM node:${NODE_VERSION}-bookworm-slim as production
35-
36-
# Set working directory
37-
WORKDIR /app
38-
39-
# Install runtime dependencies necessary for the application
40-
RUN apt-get update && apt-get install -y ffmpeg ca-certificates \
41-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
42-
43-
# Copy built artifacts from builder stage
44-
COPY --from=builder /app/node_modules ./node_modules
45-
COPY --from=builder /app/package.json ./package.json
46-
COPY --from=builder /app/dist ./dist
47-
COPY --from=builder /app/config ./config
48-
COPY --from=builder /app/locales ./locales
49-
50-
# Rebuild native dependencies
51-
RUN npm rebuild && npm cache clean --force
28+
RUN pnpm install
5229

5330
# Install mediaplex
54-
RUN npm install mediaplex
31+
RUN pnpm install mediaplex
32+
33+
# Build the application
34+
RUN pnpm build
5535

5636
# Cleanup unnecessary packages to minimize image size
5737
RUN apt-get purge -y python3 && apt-get autoremove -y
5838

5939
# Start the application
60-
CMD /bin/sh -c "npm run deploy && npm run start"
40+
CMD ["/bin/sh", "-c", "pnpm run deploy && pnpm start"]

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ Cadence offers an enriching audio experience on Discord with features such as:
5353
**Self-Hosting Steps**:
5454

5555
1. Install [Node.js](https://nodejs.org/en/download/) v20.x LTS and latest version of [FFmpeg](https://ffmpeg.org/download.html).
56-
2. Clone this repository and run `npm install` (use `npm install --legacy-peer-deps` if errors occur).
57-
3. Build the project with `npm run build`.
58-
4. Configure `.env` file in the root directory with your bot token and client id (details in `.env.example`).
59-
5. Deploy slash commands using `npm run deploy`.
60-
6. Start the bot with `npm start`, the bot should now appear online and be operational.
56+
2. Install `pnpm` using `npm install -g pnpm`.
57+
3. Clone this repository and run `pnpm install`.
58+
4. Build the project with `pnpm build`.
59+
5. Create a `.env` file in with your bot token and client id (see details in `.env.example`).
60+
6. Deploy slash commands using `pnpm run deploy`.
61+
7. Start the bot with `pnpm start`, the bot should now appear online and be operational.
6162

6263
**Note:** Refer to [Adding your bot to servers](https://discordjs.guide/preparations/adding-your-bot-to-servers.html#bot-invite-links) for help on inviting the bot to your server.
6364

6465
### Configuration and Logging:
6566

66-
- Override default configuration by creating `/config/local.js`.
67-
- Install [pino-pretty](https://www.npmjs.com/package/pino-pretty) for formatted, colorized console output, this is included in optional dependencies.
67+
- Override default configuration by creating `/config/local.ts`, copy over settings from `/config/default.ts`.
68+
- Have [pino-pretty](https://www.npmjs.com/package/pino-pretty) installed for formatted, colorized console output.
6869
- Logs are stored in `/logs` folder. Configure the logging level in the config file.
69-
- For production, usage of `pm2` or similar to manage the bot process is recommended.
7070

7171
<br>
7272

biome.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"files": {
4+
"ignore": ["**/dist/", "**/coverage/*", "**/node_modules/", "**/dist/**/*.js"]
5+
},
6+
"formatter": {
7+
"enabled": true,
8+
"formatWithErrors": false,
9+
"indentStyle": "space",
10+
"indentWidth": 4,
11+
"lineEnding": "crlf",
12+
"lineWidth": 120,
13+
"attributePosition": "auto"
14+
},
15+
"organizeImports": {
16+
"enabled": true
17+
},
18+
"linter": {
19+
"enabled": true,
20+
"rules": {
21+
"recommended": true,
22+
"correctness": {
23+
"noUnusedImports": {
24+
"level": "error",
25+
"fix": "safe"
26+
}
27+
},
28+
"nursery": {
29+
"noConsole": "warn",
30+
"noDuplicateJsonKeys": "warn",
31+
"noUselessStringConcat": "warn",
32+
"noUnusedFunctionParameters": "warn",
33+
"noUselessUndefinedInitialization": "warn",
34+
"useDateNow": "warn",
35+
"useDefaultSwitchClause": "warn",
36+
"useErrorMessage": "warn",
37+
"useExplicitLengthCheck": "warn",
38+
"useNumberToFixedDigitsArgument": "warn",
39+
"useThrowNewError": "warn",
40+
"useThrowOnlyError": "warn",
41+
"useTopLevelRegex": "warn"
42+
},
43+
"performance": {
44+
"noBarrelFile": "warn",
45+
"noReExportAll": "warn"
46+
},
47+
"style": {
48+
"noDefaultExport": "off",
49+
"noNegationElse": "warn",
50+
"useBlockStatements": "error",
51+
"useCollapsedElseIf": "error",
52+
"useConsistentArrayType": "warn",
53+
"useForOf": "warn",
54+
"useNamingConvention": {
55+
"level": "warn",
56+
"options": {
57+
"strictCase": false,
58+
"enumMemberCase": "PascalCase"
59+
},
60+
"fix": "safe"
61+
},
62+
"noNonNullAssertion": "off"
63+
},
64+
"suspicious": {
65+
"noConfusingVoidType": "off"
66+
}
67+
},
68+
"ignore": ["**/locales/**/*.d.ts", "**/src/common/services/logger.ts"]
69+
},
70+
"javascript": {
71+
"formatter": {
72+
"arrowParentheses": "always",
73+
"attributePosition": "auto",
74+
"bracketSameLine": false,
75+
"bracketSpacing": true,
76+
"jsxQuoteStyle": "double",
77+
"quoteProperties": "asNeeded",
78+
"quoteStyle": "single",
79+
"semicolons": "always",
80+
"trailingCommas": "none"
81+
}
82+
}
83+
}

config/default.js renamed to config/default.ts

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,34 @@
11
// Import Discord.js types for TypeScript support.
2-
const { ActivityType, PresenceUpdateStatus } = require('discord.js');
2+
import { ActivityType, PresenceUpdateStatus } from 'discord.js';
33

4-
// Description: Config file for Cadence Discord bot.
5-
6-
// General metadata about the bot displayed in certain embeds.
7-
module.exports.botOptions = {
4+
export const botOptions = {
85
name: 'Cadence',
96
botInviteUrl: '',
107
serverInviteUrl: '',
118
openSourceUrl: ''
129
};
1310

14-
// Configuration for bot sharding. Refers to splitting a Discord bot into multiple processes.
15-
// For more information, refer to Discord.js sharding documentation: https://discordjs.guide/sharding/
16-
module.exports.shardingOptions = {
11+
export const shardingOptions = {
1712
totalShards: 'auto',
1813
shardList: 'auto',
1914
mode: 'process',
2015
respawn: true
2116
};
2217

23-
// Configuration for logging bot actions.
24-
// You can set logging level to file and console separately.
25-
module.exports.loggerOptions = {
26-
minimumLogLevel: 'debug',
18+
export const loggerOptions = {
19+
minimumLogLevel: 'info',
2720
minimumLogLevelConsole: 'info',
2821
discordPlayerDebug: false
2922
};
3023

31-
// Options for identifying specific system command.
32-
module.exports.systemOptions = {
33-
// List of guild IDs where system commands can be executed. e.g. ['123456789012345678', '123456789012345678']
34-
systemGuildIds: [],
24+
export const systemOptions = {
3525
// Channel for sending system messages, such as bot errors and disconnect events. e.g. '123456789012345678'
3626
systemMessageChannelId: '',
3727
// Bot administrator user ID for specific notifications through mentions in system channel. e.g. '123456789012345678'
3828
systemUserId: ''
3929
};
4030

41-
// Configuration for the bot's presence and activity status.
42-
// Incude const { ActivityType, PresenceUpdateStatus } = require('discord.js'); at the top of config file.
43-
module.exports.presenceStatusOptions = {
31+
export const presenceStatusOptions = {
4432
status: PresenceUpdateStatus.Online,
4533
activities: [
4634
{
@@ -50,10 +38,7 @@ module.exports.presenceStatusOptions = {
5038
]
5139
};
5240

53-
// Configurations for visual embed messages.
54-
// Includes design elements like colors and custom emojis/symbols.
55-
// Also includes behavior options like button labels and player start messages.
56-
module.exports.embedOptions = {
41+
export const embedOptions = {
5742
info: {
5843
fallbackThumbnailUrl:
5944
'https://raw.githubusercontent.com/mariusbegby/cadence-discord-bot/main/assets/logo-rounded-128px.png',
@@ -122,8 +107,7 @@ module.exports.embedOptions = {
122107
}
123108
};
124109

125-
// Configuration for the audio player. Includes behavior upon various events and UI components.
126-
module.exports.playerOptions = {
110+
export const playerOptions = {
127111
leaveOnEmpty: true,
128112
leaveOnEmptyCooldown: 600_000,
129113
leaveOnEnd: false,
@@ -145,15 +129,13 @@ module.exports.playerOptions = {
145129
}
146130
};
147131

148-
// Configuration for ip rotation. Used for avoiding rate limits on certain APIs.
149-
module.exports.ipRotationConfig = {
132+
export const ipRotationConfig = {
150133
blocks: [],
151134
exclude: [],
152135
maxRetries: 3
153136
};
154137

155-
// Configuration for ffmpeg filters for audio processing.
156-
module.exports.ffmpegFilterOptions = {
138+
export const ffmpegFilterOptions = {
157139
threadAmount: '2',
158140
forceNormalizerByBassBoost: true,
159141
maxFilters: 10,
@@ -227,7 +209,7 @@ module.exports.ffmpegFilterOptions = {
227209
]
228210
};
229211

230-
module.exports.biquadFilterOptions = {
212+
export const biquadFilterOptions = {
231213
availableFilters: [
232214
{
233215
label: 'Basic low pass (approx.)',
@@ -292,7 +274,7 @@ module.exports.biquadFilterOptions = {
292274
]
293275
};
294276

295-
module.exports.equalizerFilterOptions = {
277+
export const equalizerFilterOptions = {
296278
availableFilters: [
297279
{
298280
label: 'Flat',
@@ -405,9 +387,7 @@ module.exports.equalizerFilterOptions = {
405387
]
406388
};
407389

408-
// Configuration for load testing. Enables the bot to simulate certain behaviors for testing purposes.
409-
// If enabled, the bot will join the specified channels and play specified track.
410-
module.exports.loadTestOptions = {
390+
export const loadTestOptions = {
411391
enabled: false,
412392
trackUrl: 'https://www.youtube.com/watch?v=tTR4D9h3zAE',
413393
channelIdsToJoin: []

0 commit comments

Comments
 (0)