Skip to content

Commit

Permalink
3.5.1
Browse files Browse the repository at this point in the history
Fixed bugs when getGuildOption* returns undefined instead of default values.
Fixed bug when bot doesn't start the finish timer.
  • Loading branch information
AlexInCube committed Aug 6, 2024
1 parent 27fa04e commit a8a0673
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aicbot",
"version": "3.5.0",
"version": "3.5.1",
"description": "Discord Bot for playing music",
"main": "build/main.js",
"scripts": {
Expand All @@ -27,9 +27,9 @@
"@distube/file": "^1.0.1",
"@distube/soundcloud": "^2.0.3",
"@distube/spotify": "^2.0.2",
"@distube/youtube": "^1.0.2",
"@distube/youtube": "^1.0.4",
"@distube/yt-dlp": "^2.0.1",
"@distube/ytdl-core": "^4.14.1",
"@distube/ytdl-core": "^4.14.3",
"@distube/ytsr": "^2.0.4",
"@eslint/js": "^9.8.0",
"cross-env": "7.0.3",
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/audioplayer/AudioPlayersManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ export class AudioPlayersManager {

const player = this.playersManager.get(queue.id);
if (player) {
player.embedBuilder.setLeaveOnEmpty(await getGuildOptionLeaveOnEmpty(queue.id));
const leaveOnEmpty = await getGuildOptionLeaveOnEmpty(queue.id);
await player.setLeaveOnEmpty(leaveOnEmpty);
await player.init();
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export async function AudioPlayerEventVoiceChannelUpdate(
const messagePlayer = client.audioPlayer.playersManager.get(oldState.guild.id);
if (!messagePlayer) return;

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

if (isVoiceChannelEmpty(oldState)) {
await messagePlayer.startAfkTimer();
await client.audioPlayer.pause(oldState.guild);
} else if (!isVoiceChannelEmpty(newState) && messagePlayer.getState() === 'pause') {
await messagePlayer.stopAfkTimer();
await client.audioPlayer.resume(oldState.guild);
if (await getGuildOptionLeaveOnEmpty(oldState.guild.id)) {
if (isVoiceChannelEmpty(oldState)) {
await messagePlayer.startAfkTimer();
await client.audioPlayer.pause(oldState.guild);
} else if (!isVoiceChannelEmpty(newState) && messagePlayer.getState() === 'pause') {
await messagePlayer.stopAfkTimer();
await client.audioPlayer.resume(oldState.guild);
}
}
}
4 changes: 2 additions & 2 deletions src/schemas/SchemaGuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function deleteGuildSettings(guildID: string): Promise<void> {

export async function getGuildOptionPrefix(guildID: string): Promise<string> {
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
return guild.options.prefix;
return guild.options.prefix ?? ENV.BOT_COMMAND_PREFIX;
}

export async function setGuildOptionPrefix(guildID: string, prefix: string): Promise<void> {
Expand All @@ -60,5 +60,5 @@ export async function setGuildOptionLeaveOnEmpty(guildID: string, mode: boolean)

export async function getGuildOptionLeaveOnEmpty(guildID: string): Promise<boolean> {
const guild: GuildModelClass = await getOrCreateGuildSettings(guildID);
return guild.options.leaveOnEmpty;
return guild.options.leaveOnEmpty ?? true;
}

0 comments on commit a8a0673

Please sign in to comment.