Skip to content

Commit

Permalink
Fix volume display and load type in music commands
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Dec 26, 2023
1 parent 3e64d45 commit a65fdc6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/commands/music/Volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class Volume extends Command {
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(`Set the volume to ${(player.volume).toFixed()}`),
.setDescription(`Set the volume to ${player.player.volume}`),
],
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/events/client/SetupButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,35 @@ export default class SetupButtons extends Event {
if (message) {
switch (interaction.customId) {
case 'LOW_VOL_BUT': {
const vol = player.volume - 10;
const vol = player.player.volume - 10;
player.player.setGlobalVolume(vol);
await buttonReply(
interaction,
`Volume set to ${vol.toFixed()}%`,
`Volume set to ${vol}%`,
this.client.color.main
);
await message.edit({
embeds: [
embed.setFooter({
text: `Volume: ${vol.toFixed()}%`,
text: `Volume: ${vol}%`,
iconURL: interaction.member.displayAvatarURL({}),
}),
],
});
break;
}
case 'HIGH_VOL_BUT': {
const vol2 = player.volume + 10;
const vol2 = player.player.volume + 10;
player.player.setGlobalVolume(vol2);
await buttonReply(
interaction,
`Volume set to ${vol2.toFixed()}%`,
`Volume set to ${vol2}%`,
this.client.color.main
);
await message.edit({
embeds: [
embed.setFooter({
text: `Volume: ${vol2.toFixed()}%`,
text: `Volume: ${vol2}%`,
iconURL: interaction.member.displayAvatarURL({}),
}),
],
Expand Down
23 changes: 12 additions & 11 deletions src/utils/SetupSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ColorResolvable, EmbedBuilder, Message, TextChannel } from 'discord.js'
import { getButtons } from './Buttons.js';
import { Song } from '../structures/Dispatcher.js';
import { Dispatcher, Lavamusic } from '../structures/index.js';
import { LoadType } from 'shoukaku';

function neb(embed: EmbedBuilder, player: Dispatcher, client: Lavamusic): EmbedBuilder {
let iconUrl = client.config.icons[player.current.info.sourceName];
Expand Down Expand Up @@ -46,7 +47,7 @@ async function setupStart(
try {
let res = await client.queue.search(query);
switch (res.loadType) {
case 'LOAD_FAILED':
case LoadType.ERROR:
await message.channel
.send({
embeds: [
Expand All @@ -61,7 +62,7 @@ async function setupStart(
}, 5000);
});
break;
case 'NO_MATCHES':
case LoadType.EMPTY:
await message.channel
.send({
embeds: [
Expand All @@ -76,8 +77,8 @@ async function setupStart(
}, 5000);
});
break;
case 'TRACK_LOADED':
const track = player.buildTrack(res.tracks[0], message.author);
case LoadType.TRACK:
const track = player.buildTrack(res.data[0], message.author);

if (player.queue.length > client.config.maxQueueSize) {
await message.channel
Expand Down Expand Up @@ -105,7 +106,7 @@ async function setupStart(
embed
.setColor(client.color.main)
.setDescription(
`Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.`
`Added [${res.data[0].info.title}](${res.data[0].info.uri}) to the queue.`
),
],
})
Expand All @@ -117,7 +118,7 @@ async function setupStart(
neb(n, player, client);
if (m) await m.edit({ embeds: [n] }).catch(() => { });
break;
case 'PLAYLIST_LOADED':
case LoadType.PLAYLIST:
if (res.length > client.config.maxPlaylistSize) {
await message.channel
.send({
Expand All @@ -136,7 +137,7 @@ async function setupStart(
});
return;
}
for (const track of res.tracks) {
for (const track of res.data.tracks) {
const pl = player.buildTrack(track, message.author);
if (player.queue.length > client.config.maxQueueSize) {
await message.channel
Expand Down Expand Up @@ -165,7 +166,7 @@ async function setupStart(
embed
.setColor(client.color.main)
.setDescription(
`Added [${res.tracks.length}](${res.tracks[0].info.uri}) to the queue.`
`Added [${res.data.tracks.length}](${res.data.tracks[0].info.uri}) to the queue.`
),
],
})
Expand All @@ -177,8 +178,8 @@ async function setupStart(
neb(n, player, client);
if (m) await m.edit({ embeds: [n] }).catch(() => { });
break;
case 'SEARCH_RESULT':
const track2 = player.buildTrack(res.tracks[0], message.author);
case LoadType.SEARCH:
const track2 = player.buildTrack(res.data[0], message.author);
if (player.queue.length > client.config.maxQueueSize) {
await message.channel
.send({
Expand All @@ -205,7 +206,7 @@ async function setupStart(
embed
.setColor(client.color.main)
.setDescription(
`Added [${res.tracks[0].info.title}](${res.tracks[0].info.uri}) to the queue.`
`Added [${res.data[0].info.title}](${res.data[0].info.uri}) to the queue.`
),
],
})
Expand Down

0 comments on commit a65fdc6

Please sign in to comment.