mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-22 18:03:17 +00:00
Chore update 3.9
This commit is contained in:
parent
086c51f367
commit
163b6ce836
16
package.json
16
package.json
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "musix",
|
||||
"version": "3.8.4",
|
||||
"version": "3.9.0",
|
||||
"description": "V3 for Musix the discord music bot",
|
||||
"main": "./index.js",
|
||||
"scripts": {
|
||||
"start": "node --max-old-space-size=4096 index.js"
|
||||
"start": "node --max-old-space-size=3072 index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,13 +24,13 @@
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cors": "^2.8.5",
|
||||
"dblapi.js": "^2.4.0",
|
||||
"discord-webhook-node": "^1.0.7",
|
||||
"discord-webhook-node": "^1.1.0",
|
||||
"discord.js": "^12.2.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"erlpack": "github:discordapp/erlpack",
|
||||
"express": "^4.17.1",
|
||||
"firebase": "^7.14.6",
|
||||
"firebase-admin": "^8.12.1",
|
||||
"firebase": "^7.16.0",
|
||||
"firebase-admin": "^8.13.0",
|
||||
"fs": "0.0.1-security",
|
||||
"genius-lyrics-api": "^2.0.3",
|
||||
"he": "^1.2.0",
|
||||
@ -44,8 +44,8 @@
|
||||
"soundcloud-api-client": "0.0.9",
|
||||
"spotify-web-api-node": "^4.0.0",
|
||||
"utf-8-validate": "^5.0.2",
|
||||
"ytdl-core": "^3.1.0",
|
||||
"ytdl-core": "^3.1.2",
|
||||
"ytsr": "^0.1.15",
|
||||
"zlib-sync": "^0.1.6"
|
||||
"zlib-sync": "^0.1.7"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ module.exports = {
|
||||
cooldown: 5,
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "audio modifiers",
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!args[1] && queue)
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'list all commands and how many times they\'ve been used',
|
||||
onlyDev: true,
|
||||
permission: 'dev',
|
||||
category: 'info',
|
||||
category: 'util',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const cmduses = [];
|
||||
client.commands.forEach((value, key) => {
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'loop the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'loop the currently playing song.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "Change nigthcore audio modifier on/off",
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "audio modifiers",
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!args[1] && queue)
|
||||
|
@ -5,10 +5,10 @@ module.exports = {
|
||||
description: "See the currently playing song position and length.",
|
||||
onlyDev: false,
|
||||
permission: "none",
|
||||
category: "music",
|
||||
category: "info",
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
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 completed = (
|
||||
queue.connection.dispatcher.streamTime + queue.time
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'Pause the currently playing music.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
const YouTube = require("simple-youtube-api");
|
||||
const SpotifyApi = require("spotify-web-api-node");
|
||||
const ytdl = require("ytdl-core");
|
||||
const ytsr = require("ytsr");
|
||||
|
||||
@ -10,15 +8,8 @@ module.exports = {
|
||||
description: "Play some music.",
|
||||
onlyDev: false,
|
||||
permission: "none",
|
||||
category: "music",
|
||||
category: "play",
|
||||
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 url = args[1] ? args[1].replace(/<(.+)>/g, "$1") : "";
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
@ -47,7 +38,7 @@ module.exports = {
|
||||
} else if (url.match(/^https?:\/\/(open.spotify.com|spotify.com)(.*)$/)) {
|
||||
if (url.includes("playlist")) {
|
||||
const playlistId = url.split("/playlist/")[1].split("?")[0];
|
||||
spotify.getPlaylist(playlistId).then(
|
||||
client.spotify.getPlaylist(playlistId).then(
|
||||
async function (data) {
|
||||
console.log(data.body)
|
||||
searchPlaylist(data, client, msg, voiceChannel);
|
||||
@ -59,7 +50,7 @@ module.exports = {
|
||||
);
|
||||
} else if (url.includes("album")) {
|
||||
const albumId = url.split("/album/")[1].split("?")[0];
|
||||
spotify.getAlbumTracks(albumId).then(
|
||||
client.spotify.getAlbumTracks(albumId).then(
|
||||
async function (data) {
|
||||
searchAlbum(data, client, msg, voiceChannel);
|
||||
},
|
||||
@ -82,17 +73,17 @@ module.exports = {
|
||||
url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)
|
||||
) {
|
||||
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");
|
||||
});
|
||||
const videos = await playlist.getVideos().catch((err) => {
|
||||
console.log("err2");
|
||||
});
|
||||
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");
|
||||
});
|
||||
spotify.searchTracks(`track:${video2.name}`).then(
|
||||
client.spotify.searchTracks(`track:${video2.name}`).then(
|
||||
function (data) {
|
||||
client.funcs.handleVideo(
|
||||
video2.url,
|
||||
@ -125,7 +116,7 @@ module.exports = {
|
||||
const videoResults = res.items.filter(
|
||||
(item) => item.type === "video"
|
||||
);
|
||||
spotify.searchTracks(`track:${searchString}`).then(
|
||||
client.spotify.searchTracks(`track:${searchString}`).then(
|
||||
function (data) {
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
@ -138,7 +129,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
function (err) {
|
||||
console.log("Something went wrong!", err);
|
||||
console.log(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'Play the previous song.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id)
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'See the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
category: 'info',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!queue) return msg.channel.send(client.messages.noServerQueue);
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "Remove a song from the queue",
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "music control",
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'Replay the currently playing song.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'play',
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'Resume the paused music.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
const ytsr = require('ytsr');
|
||||
const SpotifyApi = require("spotify-web-api-node");
|
||||
const he = require('he');
|
||||
|
||||
module.exports = {
|
||||
@ -9,14 +8,8 @@ module.exports = {
|
||||
description: 'Search the top 10 queryes and choose one.',
|
||||
onlyDev: false,
|
||||
permission: 'none',
|
||||
category: 'music',
|
||||
category: 'play',
|
||||
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 queue = client.queue.get(msg.guild.id);
|
||||
const voiceChannel = msg.member.voice.channel;
|
||||
@ -54,7 +47,7 @@ module.exports = {
|
||||
return msg.channel.send(client.messages.cancellingVideoSelection);
|
||||
}
|
||||
const videoIndex = parseInt(response.first().content) - 1;
|
||||
spotify.searchTracks(`track:${videos[videoIndex].title}`)
|
||||
client.spotify.searchTracks(`track:${videos[videoIndex].title}`)
|
||||
.then(function (data) {
|
||||
client.funcs.handleVideo(
|
||||
videoResults[0].link,
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "Seek to a specific point in the currently playing song.",
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "music control",
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: 'Shuffle the queue.',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "Skip the currently playing song.",
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "music control",
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
const permissions = msg.channel.permissionsFor(msg.author);
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "Skip to a point in the queue",
|
||||
onlyDev: false,
|
||||
permission: "MANAGE_MESSAGES",
|
||||
category: "music",
|
||||
category: "music control",
|
||||
async execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
description: "",
|
||||
onlyDev: true,
|
||||
permission: "dev",
|
||||
category: "music",
|
||||
category: "play",
|
||||
async execute(msg, args, client, Discord, prefix, command) {
|
||||
if (!args[1]) return msg.channel.send(client.messages.noQuery);
|
||||
const SoundCloud = require("soundcloud-api-client");
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
usage: '',
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_CHANNELS',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (client.funcs.check(client, msg, command)) {
|
||||
|
@ -6,7 +6,7 @@ module.exports = {
|
||||
cooldown: 5,
|
||||
onlyDev: false,
|
||||
permission: 'MANAGE_MESSAGES',
|
||||
category: 'music',
|
||||
category: 'music control',
|
||||
execute(msg, args, client, Discord, command) {
|
||||
const queue = client.queue.get(msg.guild.id);
|
||||
if (!args[1] && queue) return msg.channel.send(`${client.messages.currentVolume}**${queue.volume}**`);
|
||||
|
@ -48,7 +48,7 @@ function findSimilar(client, queue, prevSongs, guild) {
|
||||
limit: 10,
|
||||
lastfmAPIKey: client.config.lastfm_api_key,
|
||||
lastfmAPISecret: client.config.lastfm_secret,
|
||||
youtubeAPIKey: client.config.api_key,
|
||||
youtubeAPIKey: client.config.api_keys[(client.shard.ids / 2).toFixed()],
|
||||
},
|
||||
async function (err, songs) {
|
||||
if (err) {
|
||||
|
@ -7,6 +7,9 @@ const admin = require("firebase-admin");
|
||||
const serviceAccount = require("./config/serviceAccount.json");
|
||||
const fs = require("fs");
|
||||
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();
|
||||
myIntents.add(
|
||||
@ -31,9 +34,14 @@ module.exports = class extends Client {
|
||||
this.commands = new Collection();
|
||||
this.settingCmd = new Collection();
|
||||
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.dispatcher = {};
|
||||
this.config = require("./config/config.js");
|
||||
this.messages = require("./config/messages.js");
|
||||
this.db = admin.firestore();
|
||||
this.db.FieldValue = require("firebase-admin").firestore.FieldValue;
|
||||
|
@ -6,6 +6,7 @@ module.exports = {
|
||||
dblKey: process.env.DBLKEY,
|
||||
bodKey: process.env.BODKEY,
|
||||
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,
|
||||
soundCloud_api_key: process.env.SOUNDCLOUD_API_KEY,
|
||||
spotify_access_key: process.env.SPOTIFY_ACCESS_KEY,
|
||||
@ -99,4 +100,4 @@ module.exports.emojis = {
|
||||
stop: "<:stop:674685626108477519> ",
|
||||
stopWatch: ":stopwatch: ",
|
||||
volumeHigh: "<:volumehigh:674685637626167307> ",
|
||||
};
|
||||
};
|
@ -1,4 +1,5 @@
|
||||
module.exports = async function (client) {
|
||||
|
||||
const request = require("request");
|
||||
|
||||
const refresh_token = client.config.spotify_refresh_token;
|
||||
@ -17,9 +18,11 @@ module.exports = async function (client) {
|
||||
|
||||
request.post(authOptions, function (error, response, body) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
client.spotify.setAccessToken(body.access_token);
|
||||
client.config.spotify_access_key = body.access_token
|
||||
console.log("- Spotify access token set -");
|
||||
} else {
|
||||
console.log("An error occured!")
|
||||
console.log("An error occured!");
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user