More music/sound work

This commit is contained in:
TheEssem 2020-07-06 16:39:56 -05:00
parent 59c2c230fb
commit 8e5c0aa2ac
17 changed files with 26 additions and 21 deletions

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/boi.ogg", message);
return await soundPlayer.play("./assets/audio/boi.ogg", message);
};
exports.aliases = ["boy", "neutron", "hugh"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/boom.ogg", message);
return await soundPlayer.play("./assets/audio/boom.ogg", message);
};
exports.aliases = ["thud", "vine"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/bruh.ogg", message);
return await soundPlayer.play("./assets/audio/bruh.ogg", message);
};
exports.aliases = ["bro"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/explosion.ogg", message);
return await soundPlayer.play("./assets/audio/explosion.ogg", message);
};
exports.category = 6;

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/ping.ogg", message);
return await soundPlayer.play("./assets/audio/ping.ogg", message);
};
exports.aliases = ["notification", "notif"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/fart.ogg", message);
return await soundPlayer.play("./assets/audio/fart.ogg", message);
};
exports.aliases = ["toot"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/fbi.ogg", message);
return await soundPlayer.play("./assets/audio/fbi.ogg", message);
};
exports.aliases = ["openup"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/mail.ogg", message);
return await soundPlayer.play("./assets/audio/mail.ogg", message);
};
exports.aliases = ["yougotmail", "youvegotmail", "aol"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
soundPlayer.playing(message);
await soundPlayer.playing(message);
};
exports.aliases = ["playing", "np"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/oof.ogg", message);
return await soundPlayer.play("./assets/audio/oof.ogg", message);
};
exports.aliases = ["roblox", "commitdie"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
soundPlayer.pause(message);
await soundPlayer.pause(message);
};
exports.aliases = ["resume"];

View File

@ -1,8 +1,12 @@
const soundPlayer = require("../utils/soundplayer.js");
const urlRegex = /(?:\w+:)?\/\/(\S+)/;
const searchRegex = /^(sc|yt)search:/;
exports.run = async (message, args) => {
if (!args[0]) return `${message.author.mention}, you need to provide what you want to play!`;
soundPlayer.play(encodeURIComponent(args.join(" ").trim()), message, true);
const query = args.join(" ").trim();
const search = urlRegex.test(query) ? query : (searchRegex.test(query) ? query : `ytsearch:${query}`);
await soundPlayer.play(encodeURIComponent(search), message, true);
};
exports.aliases = ["p"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
soundPlayer.queue(message);
await soundPlayer.queue(message);
};
exports.aliases = ["q"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
soundPlayer.skip(message);
await soundPlayer.skip(message);
};
exports.category = 7;

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
soundPlayer.stop(message);
await soundPlayer.stop(message);
};
exports.aliases = ["disconnect"];

View File

@ -1,7 +1,7 @@
const soundPlayer = require("../utils/soundplayer.js");
exports.run = async (message) => {
return soundPlayer.play("./assets/audio/winxp.ogg", message);
return await soundPlayer.play("./assets/audio/winxp.ogg", message);
};
exports.aliases = ["windows", "xp"];

View File

@ -51,14 +51,14 @@ exports.play = async (sound, message, music = false) => {
if (!music && this.manager.voiceStates.has(message.channel.guild.id) && this.players.get(message.channel.guild.id).type === "music") return client.createMessage(message.channel.id, `${message.author.mention}, I can't play a sound effect while playing music!`);
const node = this.manager.idealNodes[0];
const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
const oldQueue = queues.get(voiceChannel.guild.id);
if (tracks.length === 0) return client.createMessage(message.channel.id, `${message.author.mention}, I couldn't find that song!`);
queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]);
const connection = await this.manager.join({
guild: voiceChannel.guild.id,
channel: voiceChannel.id,
node: node.id
});
const oldQueue = queues.get(voiceChannel.guild.id);
console.log(tracks);
queues.set(voiceChannel.guild.id, oldQueue ? [...oldQueue, tracks[0].track] : [tracks[0].track]);
if (oldQueue) {
client.createMessage(message.channel.id, `${message.author.mention}, your tune has been added to the queue!`);
@ -113,7 +113,7 @@ exports.nextSong = async (message, connection, track, info, music, voiceChannel)
this.manager.leave(voiceChannel.guild.id);
this.players.delete(voiceChannel.guild.id);
queues.delete(voiceChannel.guild.id);
await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
if (music) await client.createMessage(message.channel.id, "🔊 The current voice channel session has ended.");
} else {
const track = await fetch(`http://${connection.node.host}:${connection.node.port}/decodetrack?track=${encodeURIComponent(newQueue[0])}`, { headers: { Authorization: connection.node.password } }).then(res => res.json());
this.nextSong(message, connection, newQueue[0], track, music, voiceChannel);
@ -209,6 +209,7 @@ exports.queue = async (message) => {
const groups = trackList.map((item, index) => {
return index % pageSize === 0 ? trackList.slice(index, index + pageSize) : null;
}).filter(Boolean);
if (groups.length === 0) groups.push("del");
for (const [i, value] of groups.entries()) {
embeds.push({
"embed": {
@ -225,7 +226,7 @@ exports.queue = async (message) => {
"value": `${firstTrack.info.author} - **${firstTrack.info.title}** (${firstTrack.info.isStream ? "∞" : moment.duration(firstTrack.info.length).format("m:ss", { trim: false })})`
}, {
"name": "🗒️ Queue",
"value": value.join("\n")
"value": value !== "del" ? value.join("\n") : "There's nothing in the queue!"
}]
}
});