Huge sound player overhaul using Lavalink, added boom, removed prunejuice, boat, and bus, re-encoded audio files with ffmpeg
This commit is contained in:
parent
56faea8d59
commit
0cc80da8b6
|
@ -11,6 +11,8 @@ TOKEN=
|
|||
MONGO=mongodb://localhost:27017/esmBot
|
||||
# Put snowflake ID of bot owner here
|
||||
OWNER=
|
||||
# Put Lavalink password here
|
||||
LAVAPASS=youshallnotpass
|
||||
|
||||
###########
|
||||
# Optional
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,9 +0,0 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/boat.opus", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["tape", "flextape", "phil", "philswift"];
|
||||
exports.category = 6;
|
||||
exports.help = "Plays the Flex Tape boat sound effect";
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/boi.opus", message);
|
||||
return soundPlayer.play("./assets/audio/boi.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["boy", "neutron", "hugh"];
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return soundPlayer.play("./assets/audio/boom.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["thud", "vine"];
|
||||
exports.category = 6;
|
||||
exports.help = "Plays the Vine boom sound effect";
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/bruh.opus", message);
|
||||
return soundPlayer.play("./assets/audio/bruh.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["bro"];
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/bus.opus", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["noyelling", "busyell"];
|
||||
exports.category = 6;
|
||||
exports.help = "Plays the \"no yelling on the bus\" sound effect";
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/explosion.opus", message);
|
||||
return soundPlayer.play("./assets/audio/explosion.ogg", message);
|
||||
};
|
||||
|
||||
exports.category = 6;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/ping.opus", message);
|
||||
return soundPlayer.play("./assets/audio/ping.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["notification", "notif"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/fart.opus", message);
|
||||
return soundPlayer.play("./assets/audio/fart.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["toot"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/fbi.opus", message);
|
||||
return soundPlayer.play("./assets/audio/fbi.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["openup"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/mail.opus", message);
|
||||
return soundPlayer.play("./assets/audio/mail.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["yougotmail", "youvegotmail", "aol"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/oof.opus", message);
|
||||
return soundPlayer.play("./assets/audio/oof.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["roblox", "commitdie"];
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/prunejuice.opus", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["juice", "grandma"];
|
||||
exports.category = 6;
|
||||
exports.help = "Plays the \"Drink yo prune juice\" sound effect";
|
|
@ -1,7 +1,7 @@
|
|||
const playSound = require("../utils/soundplayer.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
|
||||
exports.run = async (message) => {
|
||||
return playSound("./assets/audio/winxp.opus", message);
|
||||
return soundPlayer.play("./assets/audio/winxp.ogg", message);
|
||||
};
|
||||
|
||||
exports.aliases = ["windows", "xp"];
|
||||
|
|
|
@ -7,6 +7,7 @@ const collections = require("../utils/collections.js");
|
|||
const logger = require("../utils/logger.js");
|
||||
const messages = require("../messages.json");
|
||||
const misc = require("../utils/misc.js");
|
||||
const soundPlayer = require("../utils/soundplayer.js");
|
||||
const helpGenerator =
|
||||
process.env.OUTPUT !== "" ? require("../utils/help.js") : null;
|
||||
const twitter =
|
||||
|
@ -128,6 +129,8 @@ module.exports = async () => {
|
|||
});
|
||||
};
|
||||
|
||||
await soundPlayer.connect();
|
||||
|
||||
// tweet stuff
|
||||
if (twitter !== null && twitter.active === false) {
|
||||
const blocks = await twitter.client.blocks.ids();
|
||||
|
|
|
@ -24,6 +24,30 @@
|
|||
"js-tokens": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@lavacord/eris": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@lavacord/eris/-/eris-0.0.3.tgz",
|
||||
"integrity": "sha512-o7w4pbiAFaB3m85RY/D73qRM45DWcdc4r4fB7QNWXRsZJqGHxgGc+VIvocL0MeOOCjgpxLt1uf4Iflv7xhngtQ==",
|
||||
"requires": {
|
||||
"lavacord": "^1.1.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"lavacord": {
|
||||
"version": "1.1.9",
|
||||
"resolved": "https://registry.npmjs.org/lavacord/-/lavacord-1.1.9.tgz",
|
||||
"integrity": "sha512-haZghbblO1w3Hodc9q63ZWgV5zA/jB6xFKS17fImK5aIdn0PkKuZ6AsJBxMFpR275v8GNYOxg6cTQBYBQ+batQ==",
|
||||
"requires": {
|
||||
"node-fetch": "^2.6.0",
|
||||
"ws": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"ws": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
|
||||
"integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@tokenizer/token": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.1.1.tgz",
|
||||
|
@ -1438,6 +1462,22 @@
|
|||
"colornames": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"lavacord": {
|
||||
"version": "1.1.9",
|
||||
"resolved": "https://registry.npmjs.org/lavacord/-/lavacord-1.1.9.tgz",
|
||||
"integrity": "sha512-haZghbblO1w3Hodc9q63ZWgV5zA/jB6xFKS17fImK5aIdn0PkKuZ6AsJBxMFpR275v8GNYOxg6cTQBYBQ+batQ==",
|
||||
"requires": {
|
||||
"node-fetch": "^2.6.0",
|
||||
"ws": "^7.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": {
|
||||
"version": "7.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz",
|
||||
"integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"levn": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
"url": "git+https://github.com/TheEssem/esmBot.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lavacord/eris": "0.0.3",
|
||||
"cowsay": "^1.4.0",
|
||||
"cron": "^1.8.2",
|
||||
"dblapi.js": "^2.4.0",
|
||||
|
@ -27,6 +28,7 @@
|
|||
"file-type": "^13.1.2",
|
||||
"gm": "github:TheEssem/gm",
|
||||
"jsqr": "^1.3.1",
|
||||
"lavacord": "^1.1.9",
|
||||
"moment": "^2.26.0",
|
||||
"moment-duration-format": "^2.3.2",
|
||||
"mongoose": "^5.9.19",
|
||||
|
|
|
@ -25,6 +25,8 @@ After that, you should install the rest of the dependencies using npm:
|
|||
npm install
|
||||
```
|
||||
|
||||
And set up Lavalink: https://github.com/Frederikam/Lavalink#server-configuration
|
||||
|
||||
Finally, fill in the info inside `.env.example`, rename it to `.env`, and run `app.js`.
|
||||
|
||||
## Credits
|
||||
|
|
|
@ -1,27 +1,47 @@
|
|||
const client = require("./client.js");
|
||||
const logger = require("./logger.js");
|
||||
const fetch = require("node-fetch");
|
||||
const { Manager } = require("@lavacord/eris");
|
||||
|
||||
module.exports = async (sound, message) => {
|
||||
const nodes = [
|
||||
{ id: "1", host: "localhost", port: 2333, password: process.env.LAVAPASS }
|
||||
];
|
||||
|
||||
let manager;
|
||||
|
||||
exports.connect = async () => {
|
||||
manager = new Manager(client, nodes, {
|
||||
user: client.user.id
|
||||
});
|
||||
const { length } = await manager.connect();
|
||||
logger.log(`Successfully connected to ${length} Lavalink node(s).`);
|
||||
manager.on("error", (error, node) => {
|
||||
logger.error(`An error occurred on Lavalink node ${node}: ${error}`);
|
||||
});
|
||||
};
|
||||
|
||||
exports.play = async (sound, message) => {
|
||||
if (message.member.voiceState.channelID) {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I can't join this voice channel!`);
|
||||
const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I don't have permission to join this voice channel!`);
|
||||
const connection = await voiceChannel.join({
|
||||
opusOnly: true
|
||||
const node = manager.idealNodes[0];
|
||||
const { tracks } = await fetch(`http://${node.host}:${node.port}/loadtracks?identifier=${sound}`, { headers: { Authorization: node.password } }).then(res => res.json());
|
||||
const connection = await manager.join({
|
||||
guild: voiceChannel.guild.id,
|
||||
channel: voiceChannel.id,
|
||||
node: node.id
|
||||
});
|
||||
if (connection.playing) return client.createMessage(message.channel.id, `${message.author.mention}, I'm already playing a sound!`);
|
||||
const playingMessage = await client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
if (connection.playing) {
|
||||
connection.stopPlaying();
|
||||
}
|
||||
connection.play(sound);
|
||||
await connection.play(tracks[0].track);
|
||||
connection.on("error", (error) => {
|
||||
voiceChannel.leave();
|
||||
manager.leave(voiceChannel.guild.id);
|
||||
playingMessage.delete();
|
||||
logger.error(error);
|
||||
});
|
||||
connection.once("end", () => {
|
||||
voiceChannel.leave();
|
||||
connection.once("end", (data) => {
|
||||
if (data.reason === "REPLACED") return;
|
||||
manager.leave(voiceChannel.guild.id);
|
||||
playingMessage.delete();
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue