Added fartreverb, added shuffle, fixed reload error messages, fixed some possible bugs

This commit is contained in:
Essem 2021-09-20 12:26:40 -05:00
parent b07c0e389e
commit 264b59ba59
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
10 changed files with 57 additions and 13 deletions

BIN
assets/audio/fart2.ogg Normal file

Binary file not shown.

View file

@ -15,7 +15,7 @@ class ReloadCommand extends Command {
this.ipc.register("reloadFail", (message) => { this.ipc.register("reloadFail", (message) => {
this.ipc.unregister("reloadSuccess"); this.ipc.unregister("reloadSuccess");
this.ipc.unregister("reloadFail"); this.ipc.unregister("reloadFail");
resolve(message); resolve(message.msg.result);
}); });
}); });
} }

View file

@ -6,7 +6,7 @@ class LoopCommand extends MusicCommand {
if (!this.message.channel.guild) return "This command only works in servers!"; if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!"; if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!"; if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can loop the music!"; if (this.connection.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) return "Only the current voice session host can loop the music!";
const object = this.connection; const object = this.connection;
object.loop = !object.loop; object.loop = !object.loop;
players.set(this.message.channel.guild.id, object); players.set(this.message.channel.guild.id, object);

View file

@ -5,7 +5,7 @@ class PauseCommand extends MusicCommand {
if (!this.message.channel.guild) return "This command only works in servers!"; if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!"; if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!"; if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can pause/resume the music!"; if (this.connection.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) return "Only the current voice session host can pause/resume the music!";
const player = this.connection.player; const player = this.connection.player;
player.pause(!player.paused ? true : false); player.pause(!player.paused ? true : false);
return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`; return `🔊 The player has been ${!player.paused ? "paused" : "resumed"}.`;

20
commands/music/shuffle.js Normal file
View file

@ -0,0 +1,20 @@
import { players } from "../../utils/soundplayer.js";
import MusicCommand from "../../classes/musicCommand.js";
class ShuffleCommand extends MusicCommand {
async run() {
if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can shuffle the music!";
const object = this.connection;
object.shuffle = !object.shuffle;
players.set(this.message.channel.guild.id, object);
return object.shuffle ? "🔊 The player is now shuffling." : "🔊 The player is no longer shuffling.";
}
static description = "Shuffles the music";
static aliases = ["toggleshuffle"];
}
export default ShuffleCommand;

View file

@ -6,7 +6,7 @@ class StopCommand extends MusicCommand {
if (!this.message.channel.guild) return "This command only works in servers!"; if (!this.message.channel.guild) return "This command only works in servers!";
if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!"; if (!this.message.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!"; if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.message.author.id) return "Only the current voice session host can stop the music!"; if (this.connection.host !== this.message.author.id && !this.message.member.permissions.has("manageChannels")) return "Only the current voice session host can stop the music!";
manager.leave(this.message.channel.guild.id); manager.leave(this.message.channel.guild.id);
const connection = this.connection.player; const connection = this.connection.player;
connection.destroy(); connection.destroy();

View file

@ -0,0 +1,14 @@
// shoutouts to dairyorange, you're a real one
import { play } from "../../utils/soundplayer.js";
import MusicCommand from "../../classes/musicCommand.js";
class FartReverbCommand extends MusicCommand {
async run() {
return await play(this.client, "./assets/audio/fart2.ogg", this.message);
}
static description = "Plays a fart sound effect with extra reverb";
static aliases = ["fart2"];
}
export default FartReverbCommand;

View file

@ -13,7 +13,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
awaitRejoin.on("end", (rejoined, member) => { awaitRejoin.on("end", (rejoined, member) => {
if (rejoined) { if (rejoined) {
connection.player.pause(false); connection.player.pause(false);
players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: member.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel }); players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: member.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel, loop: connection.loop, shuffle: connection.shuffle, playMessage: connection.playMessage });
waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`); waitMessage.edit(`🔊 ${member.mention} is the new voice channel host.`);
} else { } else {
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete(); if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
@ -45,7 +45,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
client.createMessage(connection.originalChannel.id, "🔊 The current voice channel session has ended."); client.createMessage(connection.originalChannel.id, "🔊 The current voice channel session has ended.");
} else { } else {
const randomMember = random(members); const randomMember = random(members);
players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: randomMember.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel }); players.set(connection.voiceChannel.guild.id, { player: connection.player, type: connection.type, host: randomMember.id, voiceChannel: connection.voiceChannel, originalChannel: connection.originalChannel, loop: connection.loop, shuffle: connection.shuffle, playMessage: connection.playMessage });
waitMessage.edit(`🔊 ${randomMember.mention} is the new voice channel host.`); waitMessage.edit(`🔊 ${randomMember.mention} is the new voice channel host.`);
} }
} }

View file

@ -64,7 +64,9 @@ class Shard extends BaseClusterWorker {
} }
this.ipc.register("reload", async (message) => { this.ipc.register("reload", async (message) => {
const result = await load(paths.get(message.msg)); const path = paths.get(message.msg);
if (!path) return this.ipc.broadcast("reloadFail", { result: "I couldn't find that command!" });
const result = await load(path, await checkStatus());
if (result) return this.ipc.broadcast("reloadFail", { result }); if (result) return this.ipc.broadcast("reloadFail", { result });
return this.ipc.broadcast("reloadSuccess"); return this.ipc.broadcast("reloadSuccess");
}); });

View file

@ -80,12 +80,12 @@ export async function play(client, sound, message, music = false) {
if (oldQueue && music) { if (oldQueue && music) {
return `Your ${playlistInfo.name ? "playlist" : "tune"} \`${playlistInfo.name ? playlistInfo.name : (tracks[0].info.title !== "" ? tracks[0].info.title : "(blank)")}\` has been added to the queue!`; return `Your ${playlistInfo.name ? "playlist" : "tune"} \`${playlistInfo.name ? playlistInfo.name : (tracks[0].info.title !== "" ? tracks[0].info.title : "(blank)")}\` has been added to the queue!`;
} else { } else {
nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false); nextSong(client, message, connection, tracks[0].track, tracks[0].info, music, voiceChannel, player ? player.loop : false, player ? player.shuffle : false);
return; return;
} }
} }
export async function nextSong(client, message, connection, track, info, music, voiceChannel, loop = false, lastTrack = null) { export async function nextSong(client, message, connection, track, info, music, voiceChannel, loop = false, shuffle = false, lastTrack = null) {
skipVotes.delete(voiceChannel.guild.id); skipVotes.delete(voiceChannel.guild.id);
const parts = Math.floor((0 / info.length) * 10); const parts = Math.floor((0 / info.length) * 10);
let playingMessage; let playingMessage;
@ -131,7 +131,7 @@ export async function nextSong(client, message, connection, track, info, music,
connection.removeAllListeners("end"); connection.removeAllListeners("end");
await connection.play(track); await connection.play(track);
await connection.volume(75); await connection.volume(75);
players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel, loop: loop, playMessage: playingMessage }); players.set(voiceChannel.guild.id, { player: connection, type: music ? "music" : "sound", host: message.author.id, voiceChannel: voiceChannel, originalChannel: message.channel, loop: loop, shuffle: shuffle, playMessage: playingMessage });
connection.once("error", (error) => { connection.once("error", (error) => {
if (playingMessage.channel.messages.get(playingMessage.id)) playingMessage.delete(); if (playingMessage.channel.messages.get(playingMessage.id)) playingMessage.delete();
const playMessage = players.get(voiceChannel.guild.id).playMessage; const playMessage = players.get(voiceChannel.guild.id).playMessage;
@ -145,10 +145,18 @@ export async function nextSong(client, message, connection, track, info, music,
}); });
connection.on("end", async (data) => { connection.on("end", async (data) => {
if (data.reason === "REPLACED") return; if (data.reason === "REPLACED") return;
const queue = queues.get(voiceChannel.guild.id); let queue = queues.get(voiceChannel.guild.id);
const player = players.get(voiceChannel.guild.id); const player = players.get(voiceChannel.guild.id);
let newQueue; let newQueue;
if (player && player.loop) { if (player && player.shuffle) {
if (player.loop) {
queue.push(queue.shift());
} else {
queue = queue.slice(1);
}
queue.unshift(queue.splice(Math.floor(Math.random() * queue.length), 1)[0]);
newQueue = queue;
} else if (player && player.loop) {
queue.push(queue.shift()); queue.push(queue.shift());
newQueue = queue; newQueue = queue;
} else { } else {
@ -170,7 +178,7 @@ export async function nextSong(client, message, connection, track, info, music,
} }
} else { } else {
const newTrack = await Rest.decode(connection.node, newQueue[0]); const newTrack = await Rest.decode(connection.node, newQueue[0]);
nextSong(client, message, connection, newQueue[0], newTrack, music, voiceChannel, player.loop, track); nextSong(client, message, connection, newQueue[0], newTrack, music, voiceChannel, player.loop, player.shuffle, track);
try { try {
if (newQueue[0] !== track && playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete(); if (newQueue[0] !== track && playingMessage.channel.messages.get(playingMessage.id)) await playingMessage.delete();
if (newQueue[0] !== track && player.playMessage.channel.messages.get(player.playMessage.id)) await player.playMessage.delete(); if (newQueue[0] !== track && player.playMessage.channel.messages.get(player.playMessage.id)) await player.playMessage.delete();