Halfbroken fixes

This commit is contained in:
Myx
2023-06-28 03:02:41 +02:00
parent 6a001604ab
commit f533e38333
18 changed files with 545 additions and 421 deletions

View File

@@ -1,34 +1,34 @@
const musicQueue = require("../musicQueue");
const musicQueue = require('../musicQueue');
async function enableLooping(interaction) {
await interaction.deferReply();
const guildId = interaction.guild.id;
musicQueue.enableLooping(guildId);
interaction.followUp("Enabled looping for the current queue.");
await interaction.deferReply();
const guildId = interaction.guild.id;
musicQueue.enableLooping(guildId);
interaction.followUp('Enabled looping for the current queue.');
}
async function unloopCommand(interaction) {
await interaction.deferReply();
const guildId = interaction.guild.id;
await interaction.deferReply();
const guildId = interaction.guild.id;
musicQueue.disableLooping(guildId);
interaction.followUp("Disabled looping for the current queue.");
musicQueue.disableLooping(guildId);
interaction.followUp('Disabled looping for the current queue.');
}
async function toggleLoopCommand(interaction) {
await interaction.deferReply();
const guildId = interaction.guild.id;
await interaction.deferReply();
const guildId = interaction.guild.id;
if (musicQueue.looping.has(guildId) && musicQueue.looping.get(guildId)) {
musicQueue.disableLooping(guildId, false);
interaction.followUp("Disabled looping for the current queue.");
} else {
musicQueue.enableLooping(guildId, true);
interaction.followUp("Enabled looping for the current queue.");
}
if (musicQueue.looping.has(guildId) && musicQueue.looping.get(guildId)) {
musicQueue.disableLooping(guildId, false);
interaction.followUp('Disabled looping for the current queue.');
} else {
musicQueue.enableLooping(guildId, true);
interaction.followUp('Enabled looping for the current queue.');
}
}
module.exports.toggleLoopCommand = toggleLoopCommand;
module.exports.unloopCommand = unloopCommand;
module.exports.enableLooping = enableLooping;
module.exports.enableLooping = enableLooping;

View File

@@ -1,34 +1,34 @@
const { getVoiceConnection } = require("@discordjs/voice");
const { getVoiceConnection } = require('@discordjs/voice');
async function pauseCommand(interaction) {
await interaction.deferReply();
await interaction.deferReply();
const connection = getVoiceConnection(interaction.guild.id);
const connection = getVoiceConnection(interaction.guild.id);
if (!connection) {
return interaction.followUp(
"There is no active music player in this server."
);
}
if (!connection) {
return interaction.followUp(
'There is no active music player in this server.',
);
}
connection.state.subscription.player.pause();
interaction.followUp("Paused the music.");
connection.state.subscription.player.pause();
return interaction.followUp('Paused the music.');
}
async function unpauseCommand(interaction) {
await interaction.deferReply();
await interaction.deferReply();
const connection = getVoiceConnection(interaction.guild.id);
const connection = getVoiceConnection(interaction.guild.id);
if (!connection) {
return interaction.followUp(
"There is no active music player in this server."
);
}
if (!connection) {
return interaction.followUp(
'There is no active music player in this server.',
);
}
connection.state.subscription.player.unpause();
interaction.followUp("Resumed the music.");
connection.state.subscription.player.unpause();
return interaction.followUp('Resumed the music.');
}
module.exports.pauseCommand = pauseCommand;
module.exports.unpauseCommand = unpauseCommand;
module.exports.unpauseCommand = unpauseCommand;

View File

@@ -1,32 +1,41 @@
const { getMusicStream } = require("./../utils/getMusicStream");
const musicQueue = require("../musicQueue");
const { musicPlayer } = require("../utils/musicPlayer");
const { joinVoiceChannel } = require("@discordjs/voice");
/* eslint-disable consistent-return */
const { joinVoiceChannel } = require('@discordjs/voice');
const { getMusicStream } = require('../utils/getMusicStream');
const musicQueue = require('../musicQueue');
const { musicPlayer } = require('../utils/musicPlayer');
async function playCommand(interaction) {
await interaction.deferReply();
await interaction.deferReply();
const query = interaction.options.getString("input");
const voiceChannel = interaction.member.voice.channel;
const query = interaction.options.getString('input');
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.followUp(
"You must be in a voice channel to use this command."
);
}
const song = await getMusicStream(query);
if (!voiceChannel) {
return interaction.followUp(
'You must be in a voice channel to use this command.',
);
}
const song = await getMusicStream(query);
musicQueue.addToQueue(interaction.guild.id, song);
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: interaction.guild.id,
adapterCreator: interaction.guild.voiceAdapterCreator,
selfDeaf: false,
selfMute: false,
});
if (musicQueue.getQueue(interaction.guild.id).length > 0) {
musicQueue.removeFromQueue(interaction.guild.id);
}
musicPlayer(interaction.guild.id, connection, interaction);
musicQueue.addToQueue(interaction.guild.id, song);
musicPlayer(
interaction.guild.id,
connection,
interaction,
);
}
module.exports.playCommand = playCommand;
module.exports.playCommand = playCommand;

View File

@@ -1,27 +1,27 @@
const musicQueue = require("../musicQueue");
const { getMusicStream } = require("../utils/getMusicStream");
const musicQueue = require('../musicQueue');
const { getMusicStream } = require('../utils/getMusicStream');
async function queueCommand(interaction) {
await interaction.deferReply();
await interaction.deferReply();
const query = interaction.options.getString("song");
const voiceChannel = interaction.member.voice.channel;
const query = interaction.options.getString('song');
const voiceChannel = interaction.member.voice.channel;
if (!voiceChannel) {
return interaction.followUp(
"You must be in a voice channel to use this command."
);
}
if (!voiceChannel) {
return interaction.followUp(
'You must be in a voice channel to use this command.',
);
}
const song = await getMusicStream(query);
if (!song) {
return interaction
.followUp("Error finding song. Try Again.")
.then((msg) => setTimeout(() => msg.delete(), 10000));
}
const song = await getMusicStream(query);
if (!song) {
return interaction
.followUp('Error finding song. Try Again.')
.then((msg) => setTimeout(() => msg.delete(), 10000));
}
musicQueue.addToQueue(interaction.guild.id, song);
interaction.followUp(`Added ${song.title} to the queue.`);
musicQueue.addToQueue(interaction.guild.id, song);
return interaction.followUp(`Added ${song.title} to the queue.`);
}
module.exports.queueCommand = queueCommand;
module.exports.queueCommand = queueCommand;

View File

@@ -1,30 +1,30 @@
const musicQueue = require("../musicQueue");
const { getVoiceConnection } = require("@discordjs/voice");
const { getVoiceConnection } = require('@discordjs/voice');
const musicQueue = require('../musicQueue');
async function stopCommand(interaction) {
await interaction.deferReply();
await interaction.deferReply();
const voiceChannel = interaction.member.voice.channel;
const connection = getVoiceConnection(interaction.guild.id);
const voiceChannel = interaction.member.voice.channel;
const connection = getVoiceConnection(interaction.guild.id);
if (!voiceChannel) {
return interaction.followUp(
"You must be in a voice channel to use this command."
);
}
if (!voiceChannel) {
return interaction.followUp(
'You must be in a voice channel to use this command.',
);
}
const guildId = interaction.guild.id;
const guildId = interaction.guild.id;
if (!connection.state.subscription.player) {
return interaction.followUp(
"I am not currently playing music in a voice channel."
);
}
if (!connection.state.subscription.player) {
return interaction.followUp(
'I am not currently playing music in a voice channel.',
);
}
connection.state.subscription.player.stop();
musicQueue.clearQueue(guildId);
connection.state.subscription.player.stop();
musicQueue.clearQueue(guildId);
interaction.followUp("Stopped the music and cleared the queue.");
return interaction.followUp('Stopped the music and cleared the queue.');
}
module.exports.stopCommand = stopCommand;
module.exports.stopCommand = stopCommand;