Skip to content

Commit

Permalink
3.5.0-dev-2
Browse files Browse the repository at this point in the history
Changed GitHub Action for linters, to run ESLint and Prettier in parallel.
Linters fix to pass code quality test.
Little fix in setLeaveOnEmpty in PlayerInstance.ts
  • Loading branch information
AlexInCube committed Aug 5, 2024
1 parent 0e823e2 commit 9ff6372
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 14 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: ['**']

jobs:
linters:
name: Run Linters
prettier:
name: Run Prettier
runs-on: ubuntu-latest

steps:
Expand All @@ -32,5 +32,27 @@ jobs:
- name: Run Prettier
run: pnpm run prettier:check

eslint:
name: Run ESLint
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Setup PNPM
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "pnpm"

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

- name: Run ESLint
run: pnpm run eslint
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default tseslint.config(eslint.configs.recommended, ...tseslint.configs.r
...eslintConfigPrettier.rules,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'prettier/prettier': ['error', { endOfLine: 'auto' }],
'no-constant-binary-expression': 'off'
Expand Down
1 change: 1 addition & 0 deletions src/audioplayer/PlayerInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class PlayerInstance {
}

async setLeaveOnEmpty(mode: boolean) {
this.leaveOnEmpty = mode;
this.embedBuilder.setLeaveOnEmpty(mode);

if (this.state === 'waiting') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function AudioPlayerEventVoiceChannelUpdate(
const messagePlayer = client.audioPlayer.playersManager.get(oldState.guild.id);
if (!messagePlayer) return;

if (!await getGuildOptionLeaveOnEmpty(oldState.guild.id)) return;
if (!(await getGuildOptionLeaveOnEmpty(oldState.guild.id))) return;

if (isVoiceChannelEmpty(oldState)) {
await messagePlayer.startAfkTimer();
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/Mongo.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default async function mongoHandler() {
mongoose.set('strictQuery', 'throw');
mongoose.pluralize(null);

loggerSend("Connecting to MongoDB, please wait", loggerPrefixMongo);
loggerSend('Connecting to MongoDB, please wait', loggerPrefixMongo);

try {
await mongoose.connect(`${MONGO_URI}/${ENV.MONGO_DATABASE_NAME}`);
Expand Down
17 changes: 10 additions & 7 deletions src/schemas/SchemaGuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export async function getGuildOptionPrefix(guildID: string): Promise<string> {
}

export async function setGuildOptionPrefix(guildID: string, prefix: string): Promise<void> {
let guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { prefix: prefix } })
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { prefix: prefix } });
await guild.save();
}

export async function setGuildOptionLeaveOnEmpty(guildID: string, mode: boolean): Promise<void> {
let guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { leaveOnEmpty: mode } })
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { leaveOnEmpty: mode } });
await guild.save();
}

Expand All @@ -65,9 +65,12 @@ export async function getGuildOptionLeaveOnEmpty(guildID: string): Promise<boole
return guild.options.leaveOnEmpty;
}

export async function setGuildOptionVoiceStatus(guildID: string, voiceStatus: boolean): Promise<void> {
let guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { voiceStatus: voiceStatus } })
export async function setGuildOptionVoiceStatus(
guildID: string,
voiceStatus: boolean
): Promise<void> {
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
guild.set({ options: { voiceStatus: voiceStatus } });
await guild.save();
}

Expand Down
5 changes: 2 additions & 3 deletions src/schemas/SchemaSongsHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface ISongHistoryUnit {
const SchemaSongsHistoryUnit = new Schema<ISongHistoryUnit>({
name: String,
timestamp: Date,
requester: String,
})
requester: String
});

export interface ISchemaSongsHistory {
songsHistory: Array<ISongHistoryUnit>;
Expand All @@ -22,4 +22,3 @@ export const SchemaSongsHistoryList = new Schema<ISchemaSongsHistory>({

const SongsHistoryListModel = model<ISchemaSongsHistory>('song_history', SchemaSongsHistoryList);
class SongsHistoryListModelClass extends SongsHistoryListModel {}

Check warning on line 24 in src/schemas/SchemaSongsHistory.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'SongsHistoryListModelClass' is defined but never used

0 comments on commit 9ff6372

Please sign in to comment.