Skip to content

Commit

Permalink
Merge pull request #10 from Yusuf007R/develop
Browse files Browse the repository at this point in the history
merge a prod
  • Loading branch information
Yusuf007R authored Jul 6, 2024
2 parents 095f317 + 9f49138 commit a1eb405
Show file tree
Hide file tree
Showing 18 changed files with 792 additions and 1,073 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///home/yusuf/code/echidna-tan/.github/workflows/deploy.yml"
}
},
"cSpell.enabled": false
}
100 changes: 100 additions & 0 deletions bot/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
server: # REST and WS server
port: 2333
address: 0.0.0.0
http2:
enabled: false # Whether to enable HTTP/2 support
plugins:
# name: # Name of the plugin
# some_key: some_value # Some key-value pair for the plugin
# another_key: another_value
lavalink:
plugins:
- dependency: 'dev.lavalink.youtube:youtube-plugin:1.3.0'
snapshot: false # Set to true if you want to use a snapshot version.
# - dependency: "com.github.example:example-plugin:1.0.0" # required, the coordinates of your plugin
# repository: "https://maven.example.com/releases" # optional, defaults to the Lavalink releases repository by default
# snapshot: false # optional, defaults to false, used to tell Lavalink to use the snapshot repository instead of the release repository
# pluginsDir: "./plugins" # optional, defaults to "./plugins"
# defaultPluginRepository: "https://maven.lavalink.dev/releases" # optional, defaults to the Lavalink release repository
# defaultPluginSnapshotRepository: "https://maven.lavalink.dev/snapshots" # optional, defaults to the Lavalink snapshot repository
server:
password: 'youshallnotpass'
sources:
# The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
youtube: false
bandcamp: true
soundcloud: true
twitch: true
vimeo: true
nico: true
http: true # warning: keeping HTTP enabled without a proxy configured could expose your server's IP address.
local: false
filters: # All filters are enabled by default
volume: true
equalizer: true
karaoke: true
timescale: true
tremolo: true
vibrato: true
distortion: true
rotation: true
channelMix: true
lowPass: true
bufferDurationMs: 400 # The duration of the NAS buffer. Higher values fare better against longer GC pauses. Duration <= 0 to disable JDA-NAS. Minimum of 40ms, lower values may introduce pauses.
frameBufferDurationMs: 5000 # How many milliseconds of audio to keep buffered
opusEncodingQuality: 10 # Opus encoder quality. Valid values range from 0 to 10, where 10 is best quality but is the most expensive on the CPU.
resamplingQuality: LOW # Quality of resampling operations. Valid values are LOW, MEDIUM and HIGH, where HIGH uses the most CPU.
trackStuckThresholdMs: 10000 # The threshold for how long a track can be stuck. A track is stuck if does not return any audio data.
useSeekGhosting: true # Seek ghosting is the effect where whilst a seek is in progress, the audio buffer is read from until empty, or until seek is ready.
youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
youtubeSearchEnabled: true
soundcloudSearchEnabled: true
gc-warnings: true
#ratelimit:
#ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
#excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
#strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
#searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
#retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
#youtubeConfig: # Required for avoiding all age restrictions by YouTube, some restricted videos still can be played without.
#email: "" # Email of Google account
#password: "" # Password of Google account
#httpConfig: # Useful for blocking bad-actors from ip-grabbing your music node and attacking it, this way only the http proxy will be attacked
#proxyHost: "localhost" # Hostname of the proxy, (ip or domain)
#proxyPort: 3128 # Proxy port, 3128 is the default for squidProxy
#proxyUser: "" # Optional user for basic authentication fields, leave blank if you don't use basic auth
#proxyPassword: "" # Password for basic authentication

metrics:
prometheus:
enabled: false
endpoint: /metrics

sentry:
dsn: ''
environment: ''
# tags:
# some_key: some_value
# another_key: another_value

logging:
file:
path: ./logs/

level:
root: INFO
lavalink: INFO

request:
enabled: true
includeClientInfo: true
includeHeaders: false
includeQueryString: true
includePayload: true
maxPayloadLength: 10000

logback:
rollingpolicy:
max-file-size: 1GB
max-history: 30
32 changes: 32 additions & 0 deletions bot/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.8'

services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4.0.5
container_name: lavalink
restart: unless-stopped
environment:
- _JAVA_OPTIONS=-Xmx3G
- SERVER_PORT=2333
- LAVALINK_SERVER_PASSWORD=${LAVA_LINK_PASSWORD}
volumes:
- ./application.yml:/opt/Lavalink/application.yml
- ./plugins/:/opt/Lavalink/plugins/
ports:
- 2333:2333
db:
image: postgres:15.4-alpine
restart: always
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- 5432:5432
volumes:
- db:/var/lib/postgresql/data
networks:
lavalink:
name: lavalink
volumes:
db:
driver: local
2 changes: 1 addition & 1 deletion bot/docker-compose.yml → bot/docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'

services:
lavalink:
image: ghcr.io/lavalink-devs/lavalink:4
image: ghcr.io/lavalink-devs/lavalink:4.0.5
container_name: lavalink
restart: unless-stopped
environment:
Expand Down
36 changes: 18 additions & 18 deletions bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "yarn run build && node ./dist/index.js",
"build": "tsc && tsc-alias",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src/**/*.ts --fix",
"lint": "eslint \"src/**/*.ts\" --fix",
"prettier": "prettier --ignore-path .gitignore \"**/*.+(js|jsx|ts|tsx)\" --write",
"fix": "yarn run prettier && yarn run lint",
"prisma:migrate": "npx prisma migrate dev",
Expand All @@ -17,36 +17,35 @@
"author": "Yusuf Rawat",
"license": "ISC",
"dependencies": {
"@discordjs/builders": "^1.6.4",
"@discordjs/builders": "^1.8.1",
"@discordjs/opus": "^0.9.0",
"@discordjs/rest": "^2.0.0",
"@discordjs/voice": "^0.16.0",
"@discordjs/rest": "^2.3.0",
"@discordjs/voice": "^0.17.0",
"@prisma/client": "^5.3.1",
"@trpc/server": "^10.38.1",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/jsonwebtoken": "^9.0.2",
"@trpc/server": "^10.45.2",
"apisauce": "^3.0.1",
"bufferutil": "^4.0.8",
"cors": "^2.8.5",
"discord.js": "^14.12.1",
"discord.js": "^14.15.2",
"dotenv": "^16.3.1",
"ffmpeg-static": "^5.2.0",
"fluent-ffmpeg": "^2.1.2",
"fluent-ffmpeg": "^2.1.3",
"jsonwebtoken": "^9.0.2",
"langchain": "^0.0.127",
"nanoid": "5.0.6",
"nanoid": "5.0.7",
"patch-package": "^8.0.0",
"poru": "^5.0.0",
"poru": "^5.2.0",
"postinstall-postinstall": "^2.1.0",
"sharp": "^0.32.4",
"sharp": "^0.33.4",
"tseep": "^1.2.1",
"utf-8-validate": "^6.0.3",
"ws": "^8.13.0",
"utf-8-validate": "^6.0.4",
"ws": "^8.17.0",
"zlib-sync": "^0.1.9",
"zod": "^3.21.4"
"zod": "^3.23.8"
},
"devDependencies": {
"@types/cors": "^2.8.13",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/jsonwebtoken": "^9.0.2",
"@types/node": "^20.4.10",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
Expand All @@ -59,6 +58,7 @@
"ts-node-dev": "^2.0.0",
"tsc-alias": "^1.8.8",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.6"
}
"typescript": "5.3.3"
},
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/node_modules/fluent-ffmpeg/lib/processor.js b/node_modules/fluent-ffmpeg/lib/processor.js
index 5a8e56d..d74e94a 100644
index 36d980a..70a4f03 100644
--- a/node_modules/fluent-ffmpeg/lib/processor.js
+++ b/node_modules/fluent-ffmpeg/lib/processor.js
@@ -490,7 +490,7 @@ module.exports = function(proto) {
@@ -488,7 +488,7 @@ module.exports = function(proto) {
setTimeout(function() {
emitEnd(new Error('Output stream closed'));
ffmpegProc.kill();
Expand Down
Binary file added bot/plugins/youtube-plugin-1.3.0.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions bot/src/api/routers/music-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default router({
name: z.literal('pause'),
input: z.boolean().optional()
}),
z.object({
name: z.literal('stop'),
input: z.undefined()
}),
// z.object({
// name: z.literal('stop'),
// input: z.undefined()
// }),
z.object({
name: z.literal('seekTo'),
input: z.number()
Expand Down
2 changes: 1 addition & 1 deletion bot/src/commands/music/skip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Skip extends MusicCommand {
}

async run(interaction: CommandInteraction<CacheType>) {
this.player?.stop();
this.player?.skip();
await interaction.reply({ content: 'Skipped the current song.' });
}
}
2 changes: 1 addition & 1 deletion bot/src/events/ready-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class ReadyEvent extends DiscordEvent {
});
this.echidna.user?.setStatus('online');

this.echidna.musicPlayer.init(this.echidna);
this.echidna.musicPlayer.init();
console.log(`Logged in as ${this.echidna.user?.tag}`);

const guilds = this.echidna.guilds.cache.map((guild) => guild.id);
Expand Down
5 changes: 3 additions & 2 deletions bot/src/managers/command-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CacheType, Collection, CommandInteraction, REST, Routes } from 'discord
import { readdirSync } from 'fs';
import { join } from 'path';
import configs from '../config';
import { CmdType, Command, options } from '../structures/command';
import { CmdType, Command, Options } from '../structures/command';
import EventOptions from '../structures/event-options';

export default class CommandManager {
Expand Down Expand Up @@ -83,6 +83,7 @@ export default class CommandManager {
try {
await cmd.command._run(interaction);
} catch (error) {
console.log(error);
interaction.editReply('An error occured while executing the command.');
}
}
Expand All @@ -100,7 +101,7 @@ export default class CommandManager {
});
}

async optionBuilder(options: options[], slash: SlashCommandBuilder | SlashCommandSubcommandBuilder) {
async optionBuilder(options: Options[], slash: SlashCommandBuilder | SlashCommandSubcommandBuilder) {
options.forEach((element) => {
switch (element.type) {
case 'string':
Expand Down
20 changes: 11 additions & 9 deletions bot/src/structures/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import GetChoices from '../utils/get-choices';
import { CommandValidator } from './command-validator';
import EchidnaSingleton from './echidna-singleton';

export type options =
export type Options =
| {
type: 'string';
name: string;
Expand All @@ -29,7 +29,7 @@ export type options =
type: 'sub-command';
name: string;
description: string;
options?: options[];
options?: Options[];
}
| {
type: 'user';
Expand All @@ -49,7 +49,7 @@ export type CmdType = 'GUILD' | 'DM' | 'BOTH';
export type commandConfigs = {
name: string;
description: string;
options?: options[];
options?: Options[];
voiceChannelOnly?: boolean;
shouldDefer?: boolean;
validators?: Array<new () => CommandValidator>;
Expand All @@ -61,15 +61,17 @@ export abstract class Command extends EchidnaSingleton {

readonly description: string;

options?: options[];
readonly options?: Options[];

shouldDefer?: boolean;
readonly shouldDefer?: boolean;

readonly validators: Array<new () => CommandValidator>;
readonly cmdType!: CmdType;
private _choices!: GetChoices;

choices!: GetChoices;

cmdType!: CmdType;
get choices() {
return this._choices;
}

constructor(configs: commandConfigs) {
super();
Expand All @@ -88,7 +90,7 @@ export abstract class Command extends EchidnaSingleton {

if (!(await Promise.all(validators)).every((validator) => validator)) return;
if (this.shouldDefer) await interaction.deferReply();
this.choices = new GetChoices(interaction.options);
this._choices = new GetChoices(interaction.options);
await this.run(interaction, this.choices);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions bot/src/structures/custom-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import EchidnaSingleton from './echidna-singleton';

export type playerMethods = ExtractMethods<Player>;
export type playerMethodsKey = keyof playerMethods;
const PLAYER_METHODS_TO_LISTEN: playerMethodsKey[] = ['play', 'pause', 'stop', 'seekTo', 'setVolume', 'setLoop'];
const PLAYER_METHODS_TO_LISTEN: playerMethodsKey[] = ['play', 'pause', 'seekTo', 'setVolume', 'setLoop'];
export type Queue = Player['queue'];

export type playerData = {
Expand All @@ -14,7 +14,7 @@ export type playerData = {
isConnected: boolean;
loop: 'NONE' | 'TRACK' | 'QUEUE';
position: number;
timestamp: number;
timestamp: number | null;
volume: number;
queue: Queue;
};
Expand Down
Loading

0 comments on commit a1eb405

Please sign in to comment.