1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 03:33:17 +00:00

Chore update 3.9

This commit is contained in:
MatteZ02 2020-07-12 19:08:53 +03:00
parent 086c51f367
commit 163b6ce836
27 changed files with 54 additions and 71 deletions

View File

@ -1,10 +1,10 @@
{ {
"name": "musix", "name": "musix",
"version": "3.8.4", "version": "3.9.0",
"description": "V3 for Musix the discord music bot", "description": "V3 for Musix the discord music bot",
"main": "./index.js", "main": "./index.js",
"scripts": { "scripts": {
"start": "node --max-old-space-size=4096 index.js" "start": "node --max-old-space-size=3072 index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -24,13 +24,13 @@
"cookie-parser": "^1.4.5", "cookie-parser": "^1.4.5",
"cors": "^2.8.5", "cors": "^2.8.5",
"dblapi.js": "^2.4.0", "dblapi.js": "^2.4.0",
"discord-webhook-node": "^1.0.7", "discord-webhook-node": "^1.1.0",
"discord.js": "^12.2.0", "discord.js": "^12.2.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"erlpack": "github:discordapp/erlpack", "erlpack": "github:discordapp/erlpack",
"express": "^4.17.1", "express": "^4.17.1",
"firebase": "^7.14.6", "firebase": "^7.16.0",
"firebase-admin": "^8.12.1", "firebase-admin": "^8.13.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"genius-lyrics-api": "^2.0.3", "genius-lyrics-api": "^2.0.3",
"he": "^1.2.0", "he": "^1.2.0",
@ -44,8 +44,8 @@
"soundcloud-api-client": "0.0.9", "soundcloud-api-client": "0.0.9",
"spotify-web-api-node": "^4.0.0", "spotify-web-api-node": "^4.0.0",
"utf-8-validate": "^5.0.2", "utf-8-validate": "^5.0.2",
"ytdl-core": "^3.1.0", "ytdl-core": "^3.1.2",
"ytsr": "^0.1.15", "ytsr": "^0.1.15",
"zlib-sync": "^0.1.6" "zlib-sync": "^0.1.7"
} }
} }

View File

@ -6,7 +6,7 @@ module.exports = {
cooldown: 5, cooldown: 5,
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "audio modifiers",
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue) if (!args[1] && queue)

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'list all commands and how many times they\'ve been used', description: 'list all commands and how many times they\'ve been used',
onlyDev: true, onlyDev: true,
permission: 'dev', permission: 'dev',
category: 'info', category: 'util',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const cmduses = []; const cmduses = [];
client.commands.forEach((value, key) => { client.commands.forEach((value, key) => {

View File

@ -1,13 +0,0 @@
module.exports = {
name: 'end',
alias: ["none"],
usage: '',
description: 'just end it',
onlyDev: true,
permission: 'dev',
category: 'util',
async execute(msg, args, client, Discord, command) {
client.queue.delete(msg.guild.id);
msg.channel.send(client.messages.queueDeleted);
}
};

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'loop the queue.', description: 'loop the queue.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'loop the currently playing song.', description: 'loop the currently playing song.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: "Change nigthcore audio modifier on/off", description: "Change nigthcore audio modifier on/off",
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "audio modifiers",
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue) if (!args[1] && queue)

View File

@ -5,10 +5,10 @@ module.exports = {
description: "See the currently playing song position and length.", description: "See the currently playing song position and length.",
onlyDev: false, onlyDev: false,
permission: "none", permission: "none",
category: "music", category: "info",
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (!queue) return msg.channel.send(client.messages.noServerQueue); if (!queue || !queue.songs[0] || !queue.connection || !queue.connection.dispatcher) return msg.channel.send(client.messages.noServerQueue);
let songTime = (queue.songs[0].info.lengthSeconds * 1000).toFixed(0); let songTime = (queue.songs[0].info.lengthSeconds * 1000).toFixed(0);
let completed = ( let completed = (
queue.connection.dispatcher.streamTime + queue.time queue.connection.dispatcher.streamTime + queue.time

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Pause the currently playing music.', description: 'Pause the currently playing music.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -1,5 +1,3 @@
const YouTube = require("simple-youtube-api");
const SpotifyApi = require("spotify-web-api-node");
const ytdl = require("ytdl-core"); const ytdl = require("ytdl-core");
const ytsr = require("ytsr"); const ytsr = require("ytsr");
@ -10,15 +8,8 @@ module.exports = {
description: "Play some music.", description: "Play some music.",
onlyDev: false, onlyDev: false,
permission: "none", permission: "none",
category: "music", category: "play",
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const spotify = new SpotifyApi({
id: client.config.spotify_client_id,
secret: client.config.spotify_client_secret,
});
spotify.setAccessToken(client.config.spotify_access_key);
const youtube = new YouTube(client.config.api_key);
const searchString = args.slice(1).join(" "); const searchString = args.slice(1).join(" ");
const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : ""; const url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
@ -47,7 +38,7 @@ module.exports = {
} else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) { } else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) {
if (url.includes("playlist")) { if (url.includes("playlist")) {
const playlistId = url.split("/playlist/")[1].split("?")[0]; const playlistId = url.split("/playlist/")[1].split("?")[0];
spotify.getPlaylist(playlistId).then( client.spotify.getPlaylist(playlistId).then(
async function (data) { async function (data) {
console.log(data.body) console.log(data.body)
searchPlaylist(data, client, msg, voiceChannel); searchPlaylist(data, client, msg, voiceChannel);
@ -59,7 +50,7 @@ module.exports = {
); );
} else if (url.includes("album")) { } else if (url.includes("album")) {
const albumId = url.split("/album/")[1].split("?")[0]; const albumId = url.split("/album/")[1].split("?")[0];
spotify.getAlbumTracks(albumId).then( client.spotify.getAlbumTracks(albumId).then(
async function (data) { async function (data) {
searchAlbum(data, client, msg, voiceChannel); searchAlbum(data, client, msg, voiceChannel);
}, },
@ -82,17 +73,17 @@ module.exports = {
url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/) url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)
) { ) {
const lmsg = await msg.channel.send(client.messages.loadingSongs); const lmsg = await msg.channel.send(client.messages.loadingSongs);
const playlist = await youtube.getPlaylist(url).catch((err) => { const playlist = await client.youtube.getPlaylist(url).catch((err) => {
console.log("err1"); console.log("err1");
}); });
const videos = await playlist.getVideos().catch((err) => { const videos = await playlist.getVideos().catch((err) => {
console.log("err2"); console.log("err2");
}); });
for (const video of Object.values(videos)) { for (const video of Object.values(videos)) {
const video2 = await youtube.getVideoByID(video.id).catch((err) => { const video2 = await client.youtube.getVideoByID(video.id).catch((err) => {
console.log("err3"); console.log("err3");
}); });
spotify.searchTracks(`track:${video2.name}`).then( client.spotify.searchTracks(`track:${video2.name}`).then(
function (data) { function (data) {
client.funcs.handleVideo( client.funcs.handleVideo(
video2.url, video2.url,
@ -125,7 +116,7 @@ module.exports = {
const videoResults = res.items.filter( const videoResults = res.items.filter(
(item) => item.type === "video" (item) => item.type === "video"
); );
spotify.searchTracks(`track:${searchString}`).then( client.spotify.searchTracks(`track:${searchString}`).then(
function (data) { function (data) {
client.funcs.handleVideo( client.funcs.handleVideo(
videoResults[0].link, videoResults[0].link,
@ -138,7 +129,7 @@ module.exports = {
); );
}, },
function (err) { function (err) {
console.log("Something went wrong!", err); console.log(err);
} }
); );
} }

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Play the previous song.', description: 'Play the previous song.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id) const queue = client.queue.get(msg.guild.id)
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'See the queue.', description: 'See the queue.',
onlyDev: false, onlyDev: false,
permission: 'none', permission: 'none',
category: 'music', category: 'info',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (!queue) return msg.channel.send(client.messages.noServerQueue); if (!queue) return msg.channel.send(client.messages.noServerQueue);

View File

@ -5,7 +5,7 @@ module.exports = {
description: "Remove a song from the queue", description: "Remove a song from the queue",
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "music control",
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Replay the currently playing song.', description: 'Replay the currently playing song.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'play',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Resume the paused music.', description: 'Resume the paused music.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -1,5 +1,4 @@
const ytsr = require('ytsr'); const ytsr = require('ytsr');
const SpotifyApi = require("spotify-web-api-node");
const he = require('he'); const he = require('he');
module.exports = { module.exports = {
@ -9,14 +8,8 @@ module.exports = {
description: 'Search the top 10 queryes and choose one.', description: 'Search the top 10 queryes and choose one.',
onlyDev: false, onlyDev: false,
permission: 'none', permission: 'none',
category: 'music', category: 'play',
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const spotify = new SpotifyApi({
id: client.config.spotify_client_id,
secret: client.config.spotify_client_secret,
});
spotify.setAccessToken(client.config.spotify_access_key);
const searchString = args.slice(1).join(" "); const searchString = args.slice(1).join(" ");
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
const voiceChannel = msg.member.voice.channel; const voiceChannel = msg.member.voice.channel;
@ -54,7 +47,7 @@ module.exports = {
return msg.channel.send(client.messages.cancellingVideoSelection); return msg.channel.send(client.messages.cancellingVideoSelection);
} }
const videoIndex = parseInt(response.first().content) - 1; const videoIndex = parseInt(response.first().content) - 1;
spotify.searchTracks(`track:${videos[videoIndex].title}`) client.spotify.searchTracks(`track:${videos[videoIndex].title}`)
.then(function (data) { .then(function (data) {
client.funcs.handleVideo( client.funcs.handleVideo(
videoResults[0].link, videoResults[0].link,

View File

@ -5,7 +5,7 @@ module.exports = {
description: "Seek to a specific point in the currently playing song.", description: "Seek to a specific point in the currently playing song.",
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "music control",
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: 'Shuffle the queue.', description: 'Shuffle the queue.',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: "Skip the currently playing song.", description: "Skip the currently playing song.",
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "music control",
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
const permissions = msg.channel.permissionsFor(msg.author); const permissions = msg.channel.permissionsFor(msg.author);

View File

@ -5,7 +5,7 @@ module.exports = {
description: "Skip to a point in the queue", description: "Skip to a point in the queue",
onlyDev: false, onlyDev: false,
permission: "MANAGE_MESSAGES", permission: "MANAGE_MESSAGES",
category: "music", category: "music control",
async execute(msg, args, client, Discord, command) { async execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -5,7 +5,7 @@ module.exports = {
description: "", description: "",
onlyDev: true, onlyDev: true,
permission: "dev", permission: "dev",
category: "music", category: "play",
async execute(msg, args, client, Discord, prefix, command) { async execute(msg, args, client, Discord, prefix, command) {
if (!args[1]) return msg.channel.send(client.messages.noQuery); if (!args[1]) return msg.channel.send(client.messages.noQuery);
const SoundCloud = require("soundcloud-api-client"); const SoundCloud = require("soundcloud-api-client");

View File

@ -5,7 +5,7 @@ module.exports = {
usage: '', usage: '',
onlyDev: false, onlyDev: false,
permission: 'MANAGE_CHANNELS', permission: 'MANAGE_CHANNELS',
category: 'music', category: 'music control',
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (client.funcs.check(client, msg, command)) { if (client.funcs.check(client, msg, command)) {

View File

@ -6,7 +6,7 @@ module.exports = {
cooldown: 5, cooldown: 5,
onlyDev: false, onlyDev: false,
permission: 'MANAGE_MESSAGES', permission: 'MANAGE_MESSAGES',
category: 'music', category: 'music control',
execute(msg, args, client, Discord, command) { execute(msg, args, client, Discord, command) {
const queue = client.queue.get(msg.guild.id); const queue = client.queue.get(msg.guild.id);
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`); if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`);

View File

@ -48,7 +48,7 @@ function findSimilar(client, queue, prevSongs, guild) {
limit: 10, limit: 10,
lastfmAPIKey: client.config.lastfm_api_key, lastfmAPIKey: client.config.lastfm_api_key,
lastfmAPISecret: client.config.lastfm_secret, lastfmAPISecret: client.config.lastfm_secret,
youtubeAPIKey: client.config.api_key, youtubeAPIKey: client.config.api_keys[(client.shard.ids / 2).toFixed()],
}, },
async function (err, songs) { async function (err, songs) {
if (err) { if (err) {

View File

@ -7,6 +7,9 @@ const admin = require("firebase-admin");
const serviceAccount = require("./config/serviceAccount.json"); const serviceAccount = require("./config/serviceAccount.json");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const SpotifyApi = require("spotify-web-api-node");
const YouTube = require("simple-youtube-api");
const config = require("./config/config");
const myIntents = new Intents(); const myIntents = new Intents();
myIntents.add( myIntents.add(
@ -31,9 +34,14 @@ module.exports = class extends Client {
this.commands = new Collection(); this.commands = new Collection();
this.settingCmd = new Collection(); this.settingCmd = new Collection();
this.queue = new Map(); this.queue = new Map();
this.spotify = new SpotifyApi({
id: config.spotify_client_id,
secret: config.spotify_client_secret,
});
this.youtube = new YouTube(config.api_keys[(this.shard.ids / 2).toFixed()]);
this.config = config;
this.funcs = {}; this.funcs = {};
this.dispatcher = {}; this.dispatcher = {};
this.config = require("./config/config.js");
this.messages = require("./config/messages.js"); this.messages = require("./config/messages.js");
this.db = admin.firestore(); this.db = admin.firestore();
this.db.FieldValue = require("firebase-admin").firestore.FieldValue; this.db.FieldValue = require("firebase-admin").firestore.FieldValue;

View File

@ -6,6 +6,7 @@ module.exports = {
dblKey: process.env.DBLKEY, dblKey: process.env.DBLKEY,
bodKey: process.env.BODKEY, bodKey: process.env.BODKEY,
api_key: process.env.GOOGLE_API_KEY, api_key: process.env.GOOGLE_API_KEY,
api_keys: [process.env.GOOGLE_API_KEY1, process.env.GOOGLE_API_KEY2, process.env.GOOGLE_API_KEY3, process.env.GOOGLE_API_KEY4, process.env.GOOGLE_API_KEY5, process.env.GENIUS_API_KEY6],
genius_api_key: process.env.GENIUS_API_KEY, genius_api_key: process.env.GENIUS_API_KEY,
soundCloud_api_key: process.env.SOUNDCLOUD_API_KEY, soundCloud_api_key: process.env.SOUNDCLOUD_API_KEY,
spotify_access_key: process.env.SPOTIFY_ACCESS_KEY, spotify_access_key: process.env.SPOTIFY_ACCESS_KEY,

View File

@ -1,4 +1,5 @@
module.exports = async function (client) { module.exports = async function (client) {
const request = require("request"); const request = require("request");
const refresh_token = client.config.spotify_refresh_token; const refresh_token = client.config.spotify_refresh_token;
@ -17,9 +18,11 @@ module.exports = async function (client) {
request.post(authOptions, function (error, response, body) { request.post(authOptions, function (error, response, body) {
if (!error && response.statusCode === 200) { if (!error && response.statusCode === 200) {
client.spotify.setAccessToken(body.access_token);
client.config.spotify_access_key = body.access_token client.config.spotify_access_key = body.access_token
console.log("- Spotify access token set -");
} else { } else {
console.log("An error occured!") console.log("An error occured!");
} }
}); });
}; };