Skip to content

Commit

Permalink
Fixed an issue with automatic music playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maseshi committed Feb 13, 2022
1 parent 927c337 commit a37a3f6
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 18 deletions.
4 changes: 2 additions & 2 deletions source/commands/music/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.autoplay.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.autoplay.not_queue_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.autoplay.not_queue_owner);

const mode = client.music.toggleAutoplay(message);

message.channel.send(client.translate.commands.autoplay.auto_playing.replace("%s", (mode ? client.translate.commands.autoplay.on : client.translate.commands.autoplay.off)));
};

Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports.run = (client, message, args) => {
const filterList = Object.keys(client.music.filters);

if (!queue) return message.reply(client.translate.commands.filter.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.filter.not_queue_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.filter.not_queue_owner);
if (!inputType) return message.reply({
"content": client.translate.commands.filter.sound_filtering,
"embeds": [
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports.run = (client, message, args) => {
const inputChannel = args.join(" ");
const queue = client.music.getQueue(message);

if (queue && message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.join.another_player_is_playing);
if (queue && message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.join.another_player_is_playing);
if (!inputChannel) {
const voiceChannel = message.member.voice.channel;
const meChannel = message.guild.me.voice.channel;
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.jump.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.jump.not_queue_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.jump.not_queue_owner);
if (!inputAmount) return message.reply(client.translate.commands.jump.no_input);
if (inputAmount <= 0) return message.reply(client.translate.commands.jump.too_low);
if (inputAmount > queue.songs.length) return message.reply(client.translate.commands.jump.too_much);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports.run = (client, message, args) => {
const inputChannel = args.join(" ");
const queue = client.music.getQueue(message);

if (queue && message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.leave.another_player_is_playing);
if (queue && message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.leave.another_player_is_playing);
if (!inputChannel) {
const meChannel = message.guild.me.voice.channel;

Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.pause.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.pause.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.pause.not_owner);
if (!queue.paused) return message.reply(client.translate.commands.pause.not_paused);

client.music.pause(message);
Expand Down
6 changes: 5 additions & 1 deletion source/commands/music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ module.exports.run = (client, message, args) => {
"guildId": message.guild.id,
"adapterCreator": message.guild.voiceAdapterCreator
});
client.music.play(message, inputName);
client.music.play(voiceChannel, inputName, {
"member": message.member,
"textChannel": message.channel,
message
});
} catch (error) {
const connection = getVoiceConnection(voiceChannel.guild.id);

Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/previous.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.previous.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.previous.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.previous.not_owner);
if (!queue.previousSongs) return message.reply(client.translate.commands.previous.no_previous_song_queue);

client.music.previous(message);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.remove.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.remove.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.remove.not_owner);
if (!inputAmount) return message.reply(client.translate.commands.remove.remove_guide.replace("%s", (client.config.prefix + module.exports.help.name)));
if (inputAmount <= 0) return message.reply(client.translate.commands.remove.too_little);
if (inputAmount >= queue.songs.length) return message.reply(client.translate.commands.remove.too_much);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.repeat.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.repeat.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.repeat.not_owner);
if (!inputID) return message.reply(client.translate.commands.repeat.repeat_guide);
if (inputID <= 0) return message.reply(client.translate.commands.repeat.too_little);
if (inputID >= 2) return message.reply(client.translate.commands.repeat.too_much);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.resume.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.resume.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.resume.not_owner);
if (queue.paused) return message.reply(client.translate.commands.resume.now_playing);

client.music.resume(message);
Expand Down
6 changes: 5 additions & 1 deletion source/commands/music/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ module.exports.run = (client, message, args) => {
"guildId": message.guild.id,
"adapterCreator": message.guild.voiceAdapterCreator
});
client.music.play(message, inputSearch);
client.music.play(voiceChannel, inputSearch, {
"member": message.member,
"textChannel": message.channel,
message
});
} catch (error) {
const connection = getVoiceConnection(voiceChannel.guild.id);

Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/seek.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports.run = (client, message, args) => {
const queueDuration = queue.songs.map((song, id) => song.duration);
const queueFormatDuration = queue.songs.map((song, id) => song.formatDuration);

if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.seek.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.seek.not_owner);
if (!inputTime) return message.reply(client.translate.commands.seek.seek_guide.replace("%s", queueDuration));
if (inputTime <= 0) return message.reply(client.translate.commands.seek.too_little);
if (inputTime >= queueDuration) return message.reply(client.translate.commands.seek.too_much.replace("%s", queueFormatDuration));
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.shuffle.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.shuffle.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.shuffle.not_owner);

client.music.shuffle(message);
message.channel.send(client.translate.commands.shuffle.now_shuffle);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
let queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.skip.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.skip.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.skip.not_owner);

client.music.skip(message);
message.channel.send(client.translate.commands.skip.skipped);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports.run = (client, message, args) => {
const queue = client.music.getQueue(message);

if (!queue) return message.reply(client.translate.commands.stop.no_queue);
if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.stop.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.stop.not_owner);

client.music.stop(message);
message.channel.send(client.translate.commands.stop.stopped);
Expand Down
2 changes: 1 addition & 1 deletion source/commands/music/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports.run = (client, message, args) => {

const queueVolume = queue.volume;

if (message.author.id !== queue.songs[0].user.id) return message.reply(client.translate.commands.volume.not_owner);
if (message.author.id !== queue.songs[0].user.id && queue.autoplay === false) return message.reply(client.translate.commands.volume.not_owner);
if (!inputPercent) return message.reply(client.translate.commands.volume.this_volume.replace("%s", queueVolume));
if (inputPercent <= 0) return message.reply(client.translate.commands.volume.too_little);
if (inputPercent >= 101) return message.reply(client.translate.commands.volume.too_much);
Expand Down

0 comments on commit a37a3f6

Please sign in to comment.