Skip to content

Commit

Permalink
Revert "3.4.0" (#41)
Browse files Browse the repository at this point in the history
* Revert "3.4.0-dev-23 Linter fixes 2"

This reverts commit 28fa198.

* Revert "3.4.0-dev-22 Linter fixes"

This reverts commit a3f9fd6.

* Revert "3.4.0-dev-21 Added linter action"

This reverts commit 6ef499c.

* Revert "3.4.0-dev-20 Client intents now is separated from the main.ts file"

This reverts commit 4d52cf5.

* Revert "3.4.0-dev-19 Added BOT_MAX_SONGS_IN_QUEUE env var. Pushing to Docker does not work only when tests runs not by pull request."

This reverts commit dc81b6d.

* Revert "3.4.0-dev-18 Remove failing test"

This reverts commit 14a9808.

* Revert "3.4.0-dev-17 Test failing test"

This reverts commit 9c4189f.

* Revert "3.4.0-dev-16 Fix never ending tests"

This reverts commit 4cf5e79.

* Revert "3.4.0-dev-15 Fix in action"

This reverts commit 3156976.

* Revert "3.4.0-dev-14 Added yt-cookies to action"

This reverts commit 9a2a301.

* Revert "3.4.0-dev-13 Fix in test action"

This reverts commit 63b3907.

* Revert "3.4.0-dev-12 Fix in test action"

This reverts commit d00b077.

* Revert "3.4.0-dev-11 Fix in test action"

This reverts commit 8553d90.

* Revert "3.4.0-dev-10 Fix in test action"

This reverts commit 9cce71d.

* Revert "3.4.0-dev-9 Process of loading environment variables now is cleaner"

This reverts commit 058c78a.

* Revert "3.4.0-dev-8 Added display of files in bot directory in tests action."

This reverts commit 3047269.

* Revert "3.4.0-dev-7 Added display of a current path of making env file"

This reverts commit 1ce1347.

* Revert "3.4.0-dev-6 Changed "make env file" code in tests action."

This reverts commit c231312.

* Revert "3.4.0-dev-5 Fix a wrong path in test action for creating .env file 5"

This reverts commit a068399.

* Revert "3.4.0-dev-4 Fix a wrong path in test action for creating .env file 4"

This reverts commit 832586f.

* Revert "3.4.0-dev-3 Fix a wrong path in test action for creating .env file 3"

This reverts commit 914076c.

* Revert "3.4.0-dev-1 Fix a wrong path in test action for creating .env file 2"

This reverts commit 6f8a546.

* Revert "3.4.0-dev-1 Fix a wrong path in test action for creating .env file"

This reverts commit d15f292.

* Revert "3.4.0-dev-0 Added tests for audio services Added GitHub Action for running tests. Now Docker Image building depends on tests completion."

This reverts commit b81aeb6.
  • Loading branch information
AlexInCube authored Aug 3, 2024
1 parent 28fa198 commit 990fbc7
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 310 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ BOT_FFMPEG_LOGGING=false
BOT_COMMAND_PREFIX=//
BOT_LANGUAGE=en

BOT_MAX_SONGS_IN_QUEUE=500

BOT_DISCORD_TOKEN=undefined
BOT_DISCORD_CLIENT_ID=undefined
BOT_DISCORD_OVERPOWERED_ID=undefined
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/publish-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Publish Docker image

on:
workflow_run:
workflows: [ "tests", "linters" ]
types: ['completed']
push:
branches: ['master']
paths-ignore:
- '**/wiki/**'
- '/wiki/**'
- 'docker-compose.yml'
- '.env'
- '*.sh'

env:
IMAGE_TAG: alexincube/aicotest

jobs:
push_to_registry:
if: github.event.workflow_run.event == 'push'
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
Expand Down
36 changes: 0 additions & 36 deletions .github/workflows/quality.yaml

This file was deleted.

55 changes: 0 additions & 55 deletions .github/workflows/tests.yaml

This file was deleted.

11 changes: 5 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.r
plugins: {
'typescript-eslint': ParserTypeScript,
prettier: prettierPlugin
},
ignores: ['build', 'node_modules', 'coverage', 'eslint.config.js'],
}, ignores: ['build', 'node_modules', 'coverage', 'eslint.config.js'],
languageOptions: {
globals: {
...globals.node,
Expand All @@ -21,12 +20,12 @@ export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.r
}
},
rules: {
...prettierPlugin.configs.recommended.rules,
...eslintConfigPrettier.rules,
...prettierPlugin.configs.recommended.rules,
...eslintConfigPrettier.rules,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-explicit-any': "warn",
'prettier/prettier': ['error', { endOfLine: 'auto' }],
'no-constant-binary-expression': 'off'
'no-constant-binary-expression': "off"
}
});
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "aicbot",
"version": "3.4.0",
"version": "3.3.1",
"description": "Discord Bot for playing music",
"main": "build/main.js",
"scripts": {
"build": "tsc",
"development": "tsc&& cross-env NODE_ENV=development node build/main.js",
"production": "cross-env NODE_ENV=production node build/main.js",
"cookies_grabbing": "cross-env NODE_ENV=development node build/Script_getCookie.js",
"test": "tsc&& cross-env NODE_ENV=development node --test",
"eslint": "eslint \"src/**/*.{ts,js}\"",
"prettier:format": "prettier --write \"**/*.{ts,js}\"",
"prettier:check": "prettier --check \"**/*.{ts,js}\""
"cookies_grabbing": "cross-env NODE_ENV=development node build/Script_getCookie.js"
},
"type": "module",
"keywords": [],
Expand Down
13 changes: 0 additions & 13 deletions src/ClientIntents.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/CookiesAutomation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function getYoutubeCookie() {

const browser = await puppeteer.launch({
headless: true,
slowMo: 2000,
args: ['--remote-debugging-port=9222', '--remote-debugging-address=0.0.0.0', '--no-sandbox']
});
const page = await browser.newPage();
Expand Down
25 changes: 3 additions & 22 deletions src/EnvironmentVariables.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
import { z } from 'zod';
import * as dotenv from 'dotenv';
import { loggerSend } from './utilities/logger.js';
import path from 'path';
import fs from 'fs';

const loggerPrefixEnv = 'ENV';

const envPath = path.resolve(process.cwd(), `.env.${process.env.NODE_ENV}`);

loggerSend(`Checking environment variables in ${envPath}`, loggerPrefixEnv);
if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath });
loggerSend(`Environment variables is found in ${envPath}`, loggerPrefixEnv);
} else {
loggerSend(
`Environment variables are not found in ${envPath}, trying to load variables from OS environment variables`,
loggerPrefixEnv
);
}
dotenv.config({ path: `.env.${process.env.NODE_ENV}` });

const envVariables = z.object({
NODE_ENV: z.enum(['development', 'production']).default('development'),
NODE_ENV: z.enum(['development', 'production']),

BOT_VERBOSE_LOGGING: z
.preprocess(
Expand Down Expand Up @@ -50,8 +37,6 @@ const envVariables = z.object({
BOT_LANGUAGE: z.enum(['en', 'ru']).optional().default('en'),
BOT_COMMAND_PREFIX: z.string().min(1),

BOT_MAX_SONGS_IN_QUEUE: z.coerce.number().positive().min(1).optional().default(500),

MONGO_URI: z.string(),
MONGO_DATABASE_NAME: z.string(),

Expand All @@ -76,8 +61,4 @@ const envVariables = z.object({

export const ENV = envVariables.parse(process.env);

if (fs.existsSync(envPath)) {
loggerSend(`Environment variables is loaded from ${envPath}`, loggerPrefixEnv);
} else {
loggerSend(`Environment variables is loaded from OS environment variables`, loggerPrefixEnv);
}
loggerSend(`Loaded .env.${process.env.NODE_ENV}`, loggerPrefixEnv);
30 changes: 11 additions & 19 deletions src/audioplayer/AudioPlayerCore.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
DisTube,
PlayOptions,
Queue,
RepeatMode,
Song,
Events as DistubeEvents,
Playlist
} from 'distube';
import { DisTube, PlayOptions, Queue, RepeatMode, Song, Events as DistubeEvents, Playlist } from 'distube';
import { AudioPlayersManager } from './AudioPlayersManager.js';
import { pagination } from '../utilities/pagination/pagination.js';
import { ButtonStyles, ButtonTypes } from '../utilities/pagination/paginationTypes.js';
Expand All @@ -33,6 +25,8 @@ import { joinVoiceChannel } from '@discordjs/voice';
import { generateWarningEmbed } from '../utilities/generateWarningEmbed.js';
import { generateLyricsEmbed } from './Lyrics.js';

export const queueSongsLimit = 500;

export const loggerPrefixAudioplayer = `Audioplayer`;

const plugins = await LoadPlugins();
Expand Down Expand Up @@ -64,7 +58,7 @@ export class AudioPlayerCore {
options?: PlayOptions
) {
try {
const playableThing: Song | Playlist = await this.distube.handler.resolve(song);
const playableThing: Song | Playlist = await this.distube.handler.resolve(song)

// I am need manual connect user to a voice channel, because when I am using only Distube "play"
// method, getVoiceConnection in @discordjs/voice is not working
Expand All @@ -78,15 +72,13 @@ export class AudioPlayerCore {
} catch (e) {
if (ENV.BOT_VERBOSE_LOGGING) loggerError(e);
await textChannel.send({
embeds: [
generateErrorEmbed(`${song}\n${e.message}`, i18next.t('audioplayer:play_error') as string)
]
embeds: [generateErrorEmbed(`${song}\n${e.message}`, i18next.t('audioplayer:play_error') as string)]
});

const queue = this.distube.getQueue(voiceChannel.guildId);
const queue = this.distube.getQueue(voiceChannel.guildId)

if (!queue) return;
if (queue.songs.length === 0) await this.stop(voiceChannel.guild);
if (!queue) return
if (queue.songs.length === 0) await this.stop(voiceChannel.guild)
}
}

Expand Down Expand Up @@ -370,17 +362,17 @@ export class AudioPlayerCore {
if (!queue.textChannel) return;

await queue.textChannel.send({ embeds: [generateAddedPlaylistMessage(playlist)] });
if (queue.songs.length >= ENV.BOT_MAX_SONGS_IN_QUEUE) {
if (queue.songs.length >= queueSongsLimit) {
await queue.textChannel.send({
embeds: [
generateWarningEmbed(
i18next.t('audioplayer:event_add_list_limit', {
queueLimit: ENV.BOT_MAX_SONGS_IN_QUEUE
queueLimit: queueSongsLimit
}) as string
)
]
});
queue.songs.length = ENV.BOT_MAX_SONGS_IN_QUEUE;
queue.songs.length = queueSongsLimit;
}

const player = this.playersManager.get(queue.id);
Expand Down
Loading

0 comments on commit 990fbc7

Please sign in to comment.