1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 02:00:20 +00:00
This commit is contained in:
MatteZ02 2020-04-20 19:56:23 +03:00
parent 2d55a3a8da
commit a6e3e8b0de
71 changed files with 158 additions and 164 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
dev/ dev/
.env .env
.vscode/ .vscode/
struct/config/serviceAccount.json struct/config/serviceAccount.json
./config/serviceAccount.json

View File

@ -20,7 +20,7 @@ module.exports = {
invite: invite:
"https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot", "https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot",
supportServer: "https://discord.gg/rvHuJtB", supportServer: "https://discord.gg/rvHuJtB",
devMode: false, devMode: true,
api: false, api: false,
saveDB: true, saveDB: true,
respawn: true, respawn: true,

View File

@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "global-1f5f9",
"private_key_id": "b5a6a0b88ae6140663840979255664efe81686b6",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDHtsqPN7JDzx/Z\n1V09wgEjytB+OpAZPWWRl42QGfAEhynYBXcQSOdXA6azZPfZvl+E2D5A48Ok/v47\nsruqLC5AWaA1uz53FbtyqH1AyMNG5bZIPyteR36yQzwJvqjVlufWG93v2htJt6bw\nl3tJva7/xYlTBBtoxuoZpHSKtKxNG5j2acPm31BZc3f+3KM6PCA6ZBnC/CiNOY37\nKEC1iLALK206ByU9WcVJo6yS49WufIfBOVFzYJVGdXy3ekGOnBfW1TlHSLiuw+qN\nMvLV8+yj9KxQfJ2oAnoYJwV9tboSTkDRu519izamGLBtiiPfSa4LSOcfPRcklO07\ncIYjq8WxAgMBAAECggEABPSr+5hP999KpMrm3Kq1AQieGlfFLh8oJ0/5rw75tf8N\nooLmNLT+apoYV6DEhrZy49bC2rTcLLq4H86cWgltH2Mp9tNd5jIXm+2C6CnjMJ3w\nI0RQBO+kvPMuqPY+dchgGd/IptREc5SXU6aKpGaM0mN6OCFktbmj4v2B99QqZ2Jh\n8BpF8V44naZpioCYF6Ve6WMhP+vLS3c1e9zCbBbJN2SLLLsiDnmQBxbW8O+SeLUL\ngOsiamIkMe7W2naY5+zPT9e1poX8a4JGxAuwffk3395093ReBXPU/9LOyWyVKSH3\n2e0rkGnrmXe2Zx8ghGdfl7rdzVNrgedyvzdJE9PX3QKBgQDwHoPFtUSkcNFmu+pq\nLGeUxfjj+FJfDDccok73sOro+oSIR7CrsPFER4xm9mAv7zhYoRQM9ST8iZF4gzS/\nadgQ80QE+fc0vf2cw7vmiWq8/qHI4OQ0QChWNXfN4FQ/8pLvlq+r8kiIuxgXKMJn\nFYjHywFp7sGJeePl3x3x2BFSHQKBgQDU7CwJWSEl2UfMP1f6cVz6KEL36ym7xIp/\nqSwKvnRAAxzKEFETzO46xq/N+F19AsGm4veacK+Z0/x9NeSPUuT38xvZyisTOwFe\n7yJZ/4aSxAHiOtjq1MTHQp8QievBPiHgk2TOn5vu1LfQRdaNXHvVRenSFfZTaSJY\nca/XnOHtpQKBgQDSrhN0Py2xEoPIngx5h+iCMonEjDbJyo/4gbjDvuj97gCnCi/L\nFP87p4NbO8T9ieloajyLefQv2AxZLtXzNM0tYiRGMYRjNGf3Sg3topiSpuAQvrG7\n3qcFrPgnHTMOwKmHqjEMrxJRVcc3Wr3ncI+IrWfaKHCLTPVW1cMSVUAtSQKBgBBl\nq7KAmavngr749daEmmttZFLhWlJqfVv9dDXTmvI/Cx2IiiXjN0lxeaJ8CP8SkkU+\n32CWYv+OsrgVyWc8NAPgRfnMtuqBNcbQ1a1mnz94NsjsTT4waoMJ32QPqwczuLop\nv66l3gVTfmBcsHwsbiDrhGk4ZcLgqtNy1d7d5ww9AoGBAJDjwVqkBJgmdBqnPdE+\n4BfTThQXUO6X976sQSX7op1uNv/ofE8fO3gvF/d8YzolpOrI0+igSUVEXASDkujx\nFmU3wR04qEr2LydGuaSvXvYIOw8htzx8wI9//OWA5p7f/+hNLo1bD0h7JTkfadEI\ntUL5tF7DbnMTXl6Wo8Ggsaj0\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-nckf2@global-1f5f9.iam.gserviceaccount.com",
"client_id": "116364112880753391831",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-nckf2%40global-1f5f9.iam.gserviceaccount.com"
}

View File

@ -1,20 +1,35 @@
const config = require("./config/config.ts"); const config = require("./config/config.js");
/*const admin = require("firebase-admin");
const serviceAccount = require("./config/serviceAccount.json");
const secondaryAppConfig = {
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://global-1f5f9.firebaseio.com",
};
const secondary = admin.initializeApp(secondaryAppConfig, "secondary");
const globaldb = secondary.database();
const global = {
db: {
guilds: {},
},
};*/
if (config.devMode) { if (config.devMode) {
console.log('- dev mode- '); console.log("- dev mode- ");
config.token = config.devToken; config.token = config.devToken;
config.shards = 1; config.shards = 1;
} }
const { const {
ShardingManager ShardingManager
} = require('discord.js'); } = require("discord.js");
const manager = new ShardingManager('./src/bot.ts', { const manager = new ShardingManager("./src/bot.js", {
token: config.token, token: config.token,
respawn: config.respawn, respawn: config.respawn,
totalShards: config.shards totalShards: config.shards,
}); });
console.log('- Launching shards -'); console.log("- Launching shards -");
manager.spawn(config.shards, config.shardDelay, config.shardTimeout); manager.spawn(config.shards, config.shardDelay, config.shardTimeout);
manager.on('shardCreate', shard => console.log(`- Launched shard ${shard.id} -`)); manager.on("shardCreate", (shard) =>
console.log(`- Launched shard ${shard.id} -`)
);

2
src/bot.js Normal file
View File

@ -0,0 +1,2 @@
const MusicClient = require('./struct/client.js');
const client = new MusicClient({});

View File

@ -1,2 +0,0 @@
const MusicClient = require('./struct/client.ts');
const client = new MusicClient({});

View File

@ -1,6 +1,7 @@
const YouTube = require("simple-youtube-api"); const YouTube = require("simple-youtube-api");
const search = require("yt-search"); const search = require("yt-search");
const SpotifyApi = require("spotify-web-api-node"); const SpotifyApi = require("spotify-web-api-node");
const { globaldb } = require("../../index.js");
module.exports = { module.exports = {
name: "play", name: "play",
@ -16,9 +17,16 @@ module.exports = {
secret: client.config.spotify_client_secret, secret: client.config.spotify_client_secret,
}); });
spotify.setAccessToken( const dbdata = await globaldb
client.global.db.guilds[msg.guild.id].spotify_access_key .collection("guilds")
); .doc(msg.guild.id)
.get()
.catch((err) => {
console.log("Error getting document", err);
return "error";
});
const accessKey = dbdata.data();
spotify.setAccessToken(accessKey);
const youtube = new YouTube(client.config.api_key); const youtube = new YouTube(client.config.api_key);
const searchString = args.slice(1).join(" "); const searchString = args.slice(1).join(" ");

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
name: 'queue', name: 'queue',
alias: 'q', alias: 'q',
usage: '<page(opt)>', usage: '',
description: 'See the queue.', description: 'See the queue.',
onlyDev: false, onlyDev: false,
permission: 'none', permission: 'none',
@ -25,4 +25,4 @@ module.exports = {
.setColor(client.config.embedColor) .setColor(client.config.embedColor)
return msg.channel.send(embed); return msg.channel.send(embed);
} }
}; };

View File

@ -1,3 +1,5 @@
const { db } = require("../../../index-.js");
module.exports = { module.exports = {
name: "message", name: "message",
async execute(client, msg, Discord) { async execute(client, msg, Discord) {
@ -6,9 +8,9 @@ module.exports = {
const args = msg.content.split(" "); const args = msg.content.split(" ");
if (!args[1] || !args[2]) if (!args[1] || !args[2])
return msg.channel.send(client.messages.setKeyUsage); return msg.channel.send(client.messages.setKeyUsage);
if (!client.guilds.cache.get(args[2])) client.config.db.collection("guilds").doc(args[2]).set({
return msg.channel.send(client.messages.invalidGuild); key: args[1],
client.global.db.guilds[args[2]].spotify_access_key = args[1]; });
return msg.channel.send(client.messages.keySet); return msg.channel.send(client.messages.keySet);
} }
if (!msg.guild) return; if (!msg.guild) return;

View File

@ -2,16 +2,16 @@ module.exports = function (client) {
const Discord = require('discord.js'); const Discord = require('discord.js');
const events = './clientEvents/'; const events = './clientEvents/';
client.on('ready', () => { client.on('ready', () => {
require(`${events}ready.ts`).execute(client, Discord); require(`${events}ready.js`).execute(client, Discord);
}); });
client.on('message', (msg) => { client.on('message', (msg) => {
require(`${events}msg.ts`).execute(client, msg, Discord); require(`${events}msg.js`).execute(client, msg, Discord);
}); });
client.on('guildCreate', (guild) => { client.on('guildCreate', (guild) => {
require(`${events}guildCreate.ts`).execute(client, guild); require(`${events}guildCreate.js`).execute(client, guild);
}); });
client.on('voiceStateUpdate', (oldState, newState) => { client.on('voiceStateUpdate', (oldState, newState) => {
require(`${events}voiceStateUpdate.ts`).execute(client, oldState, newState); require(`${events}voiceStateUpdate.js`).execute(client, oldState, newState);
}); });
client.on('error', (error) => { client.on('error', (error) => {
client.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${client.shard}`); client.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${client.shard}`);

View File

@ -1,9 +1,12 @@
const { Client, Collection } = require("discord.js"); const {
Client,
Collection
} = require("discord.js");
const admin = require("firebase-admin"); 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 events = require("../events/events.ts"); const events = require("../events/events.js");
module.exports = class extends Client { module.exports = class extends Client {
constructor() { constructor() {
@ -21,12 +24,12 @@ module.exports = class extends Client {
this.queue = new Map(); this.queue = new Map();
this.funcs = {}; this.funcs = {};
this.dispatcher = {}; this.dispatcher = {};
this.config = require("../../config/config.ts"); this.config = require("../../config/config.js");
this.messages = require("./config/messages.ts"); 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;
this.dispatcher.finish = require("../events/dispatcherEvents/finish.ts"); this.dispatcher.finish = require("../events/dispatcherEvents/finish.js");
this.dispatcher.error = require("../events/dispatcherEvents/error.ts"); this.dispatcher.error = require("../events/dispatcherEvents/error.js");
this.global = { this.global = {
db: { db: {
guilds: {}, guilds: {},
@ -39,7 +42,7 @@ module.exports = class extends Client {
const commandFiles = fs const commandFiles = fs
.readdirSync(path.join(path.dirname(__dirname), "commands")) .readdirSync(path.join(path.dirname(__dirname), "commands"))
.filter((f) => f.endsWith(".ts")); .filter((f) => f.endsWith(".js"));
for (const file of commandFiles) { for (const file of commandFiles) {
const command = require(`../commands/${file}`); const command = require(`../commands/${file}`);
command.uses = 0; command.uses = 0;
@ -48,7 +51,7 @@ module.exports = class extends Client {
} }
const settingFiles = fs const settingFiles = fs
.readdirSync(path.join(path.dirname(__dirname), "commands/settings")) .readdirSync(path.join(path.dirname(__dirname), "commands/settings"))
.filter((f) => f.endsWith(".ts")); .filter((f) => f.endsWith(".js"));
for (const file of settingFiles) { for (const file of settingFiles) {
const option = require(`../commands/settings/${file}`); const option = require(`../commands/settings/${file}`);
this.settingCmd.set(option.name, option); this.settingCmd.set(option.name, option);
@ -63,4 +66,4 @@ module.exports = class extends Client {
console.log("Failed to login: " + err) console.log("Failed to login: " + err)
); );
} }
}; };

View File

@ -1,34 +1,25 @@
const emojis = require("./emojis.ts"); const emojis = require("./emojis.js");
module.exports = { module.exports = {
alreadyPaused: emojis.redx + "The music is already paused!", alreadyPaused: emojis.redx + "The music is already paused!",
alreadyVoted: emojis.redx + "You have already voted to skip!", alreadyVoted: emojis.redx + "You have already voted to skip!",
announceSongs: emojis.megaPhone + "Current setting:", announceSongs: emojis.megaPhone + "Current setting:",
announceSongsFalse: announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!",
emojis.green_check_mark + "announcesongs now set to `false`!", announceSongsTrue: emojis.green_check_mark + "announcesongs now set to `true`!",
announceSongsTrue: bassApplied: emojis.volumeHigh + "The bass level **%BASS%** has been applied!",
emojis.green_check_mark + "announcesongs now set to `true`!",
bassApplied:
emojis.volumeHigh + "The bass level **%BASS%** has been applied!",
bassFalse: emojis.green_check_mark + "Bass is now false!", bassFalse: emojis.green_check_mark + "Bass is now false!",
bassLevel: emojis.green_check_mark + "Bass level is now", bassLevel: emojis.green_check_mark + "Bass level is now",
blacklistTitle: "Currently blacklisted channels:", blacklistTitle: "Currently blacklisted channels:",
blackListedVC: blackListedVC: emojis.redx +
emojis.redx +
"Your voiceChannel is blacklisted! Please choose another channel!", "Your voiceChannel is blacklisted! Please choose another channel!",
boolean: emojis.redx + "Please define a boolean! (true/false)", boolean: emojis.redx + "Please define a boolean! (true/false)",
cancellingVideoSelection: emojis.redx + "Cancelling video selection", cancellingVideoSelection: emojis.redx + "Cancelling video selection",
cantSkipToCurrent: cantSkipToCurrent: emojis.redx + "You can't skip to the song currently playing!",
emojis.redx + "You can't skip to the song currently playing!", channelAdded: emojis.green_check_mark + "Channel %CHANNEL% added to the blacklist!",
channelAdded: channelAlreadyBlackListed: emojis.redx + "That channel is already blacklisted!",
emojis.green_check_mark + "Channel %CHANNEL% added to the blacklist!",
channelAlreadyBlackListed:
emojis.redx + "That channel is already blacklisted!",
channelFull: emojis.redx + "Your voice channel is full!", channelFull: emojis.redx + "Your voice channel is full!",
channelNotBlackListed: channelNotBlackListed: emojis.redx + "That channel is not blacklisted or does not exist!",
emojis.redx + "That channel is not blacklisted or does not exist!", channelRemoved: emojis.green_check_mark +
channelRemoved:
emojis.green_check_mark +
"Channel %CHANNEL% has been removed from the blacklist!", "Channel %CHANNEL% has been removed from the blacklist!",
cmdUsesFooter: "These statistics are from the current uptime.", cmdUsesFooter: "These statistics are from the current uptime.",
cmdUsesTitle: "Musix Command Usage During Current Uptime", cmdUsesTitle: "Musix Command Usage During Current Uptime",
@ -40,43 +31,33 @@ module.exports = {
currentPrefix: "Current prefix:", currentPrefix: "Current prefix:",
currentVolume: emojis.loudSound + "The current volume is: ", currentVolume: emojis.loudSound + "The current volume is: ",
dbSaved: emojis.green_check_mark + "DB Saved!", dbSaved: emojis.green_check_mark + "DB Saved!",
defaultVolumeMax: defaultVolumeMax: emojis.redx +
emojis.redx +
"The default volume must be below `100` for quality and safety resons.", "The default volume must be below `100` for quality and safety resons.",
defaultVolumeNumber: defaultVolumeNumber: emojis.redx +
emojis.redx +
"I'm sorry, But the default volume needs to be a valid __number__.", "I'm sorry, But the default volume needs to be a valid __number__.",
defaultVolumeSet: emojis.green_check_mark + "Default volume set to:", defaultVolumeSet: emojis.green_check_mark + "Default volume set to:",
devMode: devMode: emojis.redx +
emojis.redx +
"Dev mode has been turned on! Commands are only available to developer(s)!", "Dev mode has been turned on! Commands are only available to developer(s)!",
disableNigthCore: disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!",
emojis.redx + "Please disable nigthCore in order to use this command!",
dispatcherError: "Error with the dispatcher: ", dispatcherError: "Error with the dispatcher: ",
djFalse: emojis.green_check_mark + "`DJ` now set to `false`", djFalse: emojis.green_check_mark + "`DJ` now set to `false`",
djRoleCreated: djRoleCreated: emojis.green_check_mark +
emojis.green_check_mark +
"I did not find a role `DJ` so i have created one for you!", "I did not find a role `DJ` so i have created one for you!",
djRoleFound: djRoleFound: emojis.green_check_mark +
emojis.green_check_mark +
"I found a `DJ` role from this guild! This role is now the DJ role.", "I found a `DJ` role from this guild! This role is now the DJ role.",
error: emojis.redx + "An error occured!", error: emojis.redx + "An error occured!",
errorConnecting: "Error with connecting to voice channel: ", errorConnecting: "Error with connecting to voice channel: ",
errorDetected: "Error detected: ", errorDetected: "Error detected: ",
errorDispatcher: errorDispatcher: emojis.redx +
emojis.redx +
"An error has occured while playing music! The queue has been deleted.", "An error has occured while playing music! The queue has been deleted.",
errorExe: emojis.redx + "there was an error trying to execute that command!", errorExe: emojis.redx + "there was an error trying to execute that command!",
errorExeOpt: errorExeOpt: emojis.redx + "there was an error trying to execute that option!",
emojis.redx + "there was an error trying to execute that option!",
evalTitle: "Evaluation Command", evalTitle: "Evaluation Command",
failedToLoad: emojis.redx + "Songs failed to load: ", failedToLoad: emojis.redx + "Songs failed to load: ",
helpCmdFooter: "Command Alias:", helpCmdFooter: "Command Alias:",
helpFooter: helpFooter: '"%PREFIX%help <command>" to see more information about a command.',
'"%PREFIX%help <command>" to see more information about a command.',
helpTitle: "help", helpTitle: "help",
idOrMentionChannel: idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!",
emojis.redx + "Please provide a channel id or mention a channel!",
invalidGuild: emojis.redx + "Invalid guild id!", invalidGuild: emojis.redx + "Invalid guild id!",
inviteTitle: "Invite Musix to your Discord server!", inviteTitle: "Invite Musix to your Discord server!",
joined: emojis.green_check_mark + "Joined", joined: emojis.green_check_mark + "Joined",
@ -90,40 +71,31 @@ module.exports = {
maxBass: emojis.redx + "The max bass is `100`!", maxBass: emojis.redx + "The max bass is `100`!",
maxVolume: emojis.redx + "The max volume is `100`!", maxVolume: emojis.redx + "The max volume is `100`!",
mentionChannel: emojis.redx + "Please mention a channel!", mentionChannel: emojis.redx + "Please mention a channel!",
musicCommandsDisabled: musicCommandsDisabled: emojis.redx +
emojis.redx +
"This channels has been blacklisted! Music commands cannot be used here!", "This channels has been blacklisted! Music commands cannot be used here!",
nigthCoreApplied: nigthCoreApplied: emojis.green_check_mark +
emojis.green_check_mark +
"NigthCore is now **%BOOLEAN%** this will be applied when the next song starts playing!", "NigthCore is now **%BOOLEAN%** this will be applied when the next song starts playing!",
noDj: emojis.redx + "You need the `DJ` role to use this command!", noDj: emojis.redx + "You need the `DJ` role to use this command!",
noLooping: emojis.repeat + "No longer looping the queue!", noLooping: emojis.repeat + "No longer looping the queue!",
noLoopingSong: emojis.repeatSong + "No longer looping the song!", noLoopingSong: emojis.repeatSong + "No longer looping the song!",
noMorePremium: ":cry: Guild %GUILD% is no longer premium!", noMorePremium: ":cry: Guild %GUILD% is no longer premium!",
noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`, noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`,
noPermsConnect: noPermsConnect: emojis.redx +
emojis.redx +
"I cannot connect to your voice channel, make sure I have the proper permissions!", "I cannot connect to your voice channel, make sure I have the proper permissions!",
noPermsEmbed: noPermsEmbed: emojis.redx +
emojis.redx +
"I cannot send embeds (Embed links), make sure I have the proper permissions!", "I cannot send embeds (Embed links), make sure I have the proper permissions!",
noPermsManageRoles: noPermsManageRoles: emojis.redx +
emojis.redx +
"I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!", "I cannot create roles (Manage roles), make sure I have the proper permissions! I will need this permission to create a `DJ` role since i did not find one!",
noPermsManageSettings: noPermsManageSettings: emojis.redx +
emojis.redx +
"You need the `MANAGE_SERVER` permission to change the settings!", "You need the `MANAGE_SERVER` permission to change the settings!",
noPermsSpeak: noPermsSpeak: emojis.redx +
emojis.redx +
"I cannot speak in your voice channel, make sure I have the proper permissions!", "I cannot speak in your voice channel, make sure I have the proper permissions!",
noPermsUseExternalEmojis: noPermsUseExternalEmojis: emojis.redx +
emojis.redx +
"I cannot use external emojis, make sure I have the proper permissions!", "I cannot use external emojis, make sure I have the proper permissions!",
noQuery: emojis.redx + "you need to use a link or search for a song!", noQuery: emojis.redx + "you need to use a link or search for a song!",
noResults: emojis.redx + "I could not obtain any search results!", noResults: emojis.redx + "I could not obtain any search results!",
noResultsLyrics: emojis.redx + "I could not obtain any results!", noResultsLyrics: emojis.redx + "I could not obtain any results!",
noResultsSpotify: noResultsSpotify: emojis.redx +
emojis.redx +
"I could not obtain any results! Make sure you have a key set! More info with the setkey setting.", "I could not obtain any results! Make sure you have a key set! More info with the setkey setting.",
noServerQueue: emojis.redx + "There is nothing playing!", noServerQueue: emojis.redx + "There is nothing playing!",
noSongs: emojis.redx + "That song does not exist!", noSongs: emojis.redx + "That song does not exist!",
@ -132,8 +104,7 @@ module.exports = {
notAllowed: emojis.redx + "You are not allowed to do that!", notAllowed: emojis.redx + "You are not allowed to do that!",
notEnoughVotes: emojis.redx + "Not enough votes!", notEnoughVotes: emojis.redx + "Not enough votes!",
notPaused: emojis.redx + "The music in not paused!", notPaused: emojis.redx + "The music in not paused!",
noVoiceChannel: noVoiceChannel: emojis.redx +
emojis.redx +
"I'm sorry but you need to be in a voice channel to play music!", "I'm sorry but you need to be in a voice channel to play music!",
nowPlaying: "__Now playing__", nowPlaying: "__Now playing__",
nowPremium: ":tada: Guild %GUILD% is now premium!", nowPremium: ":tada: Guild %GUILD% is now premium!",
@ -141,14 +112,11 @@ module.exports = {
paused: emojis.pause + "Paused the music!", paused: emojis.pause + "Paused the music!",
permission: "🔒 Permission requirement:", permission: "🔒 Permission requirement:",
permissionsFalse: emojis.redx + "That value is already `false`!", permissionsFalse: emojis.redx + "That value is already `false`!",
permissionsSetFalse: permissionsSetFalse: emojis.green_check_mark + "Permissions requirement now set to: `false`",
emojis.green_check_mark + "Permissions requirement now set to: `false`", permissionsSetTrue: emojis.green_check_mark + "Permissions requirement now set to: `true`",
permissionsSetTrue:
emojis.green_check_mark + "Permissions requirement now set to: `true`",
permissionsTrue: emojis.redx + "That value is already `true`!", permissionsTrue: emojis.redx + "That value is already `true`!",
pinging: emojis.loading + "Pinging...", pinging: emojis.loading + "Pinging...",
playlistAdded: playlistAdded: emojis.green_check_mark +
emojis.green_check_mark +
"Playlist: **%TITLE%** has been added to the queue!", "Playlist: **%TITLE%** has been added to the queue!",
positiveBass: emojis.redx + "The bass needs to be a positive number!", positiveBass: emojis.redx + "The bass needs to be a positive number!",
positiveVolume: emojis.redx + "The volume needs to be a positive number!", positiveVolume: emojis.redx + "The volume needs to be a positive number!",
@ -156,62 +124,47 @@ module.exports = {
prefixMaxLength: "The prefix must be shorter or equal to 5 letters!", prefixMaxLength: "The prefix must be shorter or equal to 5 letters!",
prefixSet: emojis.green_check_mark + "New prefix set to:", prefixSet: emojis.green_check_mark + "New prefix set to:",
premiumState: "Premium status: ", premiumState: "Premium status: ",
provideANumber: provideANumber: "Please provide a number ranging from 1-10 to select one of the search results.",
"Please provide a number ranging from 1-10 to select one of the search results.", provideASong: emojis.redx + "Please provide a song position in queue for me to remove!",
provideASong:
emojis.redx + "Please provide a song position in queue for me to remove!",
queueDeleted: "Queue deleted!", queueDeleted: "Queue deleted!",
queueDesc: queueDesc: "**Now playing:** %SONG%<a:aNotes:674602408105476106>\n:arrow_down: Next in queue :arrow_down:",
"**Now playing:** %SONG%<a:aNotes:674602408105476106>\n:arrow_down: Next in queue :arrow_down:",
queueFooter: "songs in the queue!", queueFooter: "songs in the queue!",
queueLength: queueLength: emojis.redx + "There are only %SONGS% amount of songs in the queue!",
emojis.redx + "There are only %SONGS% amount of songs in the queue!",
queueTitle: "__Song queue__", queueTitle: "__Song queue__",
quotaReached: quotaReached: emojis.redx +
emojis.redx +
"Quota reached please try again after midnight Pacific Time (PT)!", "Quota reached please try again after midnight Pacific Time (PT)!",
reloaded: "All files reloaded!", reloaded: "All files reloaded!",
removed: emojis.garbage + "removed `%SONG%` from the queue!", removed: emojis.garbage + "removed `%SONG%` from the queue!",
reset: emojis.green_check_mark + "Reset __all__ guild settings!", reset: emojis.green_check_mark + "Reset __all__ guild settings!",
restart: "restarting all shards...", restart: "restarting all shards...",
resumed: emojis.resume + "Resumed the music!", resumed: emojis.resume + "Resumed the music!",
seekingPointPositive: seekingPointPositive: emojis.redx + "The seeking point needs to be a positive number!",
emojis.redx + "The seeking point needs to be a positive number!", seekMax: emojis.redx +
seekMax:
emojis.redx +
"The lenght of this song is %LENGTH% seconds! You can't seek further than that!", "The lenght of this song is %LENGTH% seconds! You can't seek further than that!",
setKeyUsage: setKeyUsage: "Usage: `setkey <key> <guild id>`. Get your key from <https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#> by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!",
"Usage: `setkey <key> <guild id>`. Get your key from <https://developer.spotify.com/documentation/web-playback-sdk/quick-start/#> by pressing `Get your web playback sdk access token`.\nThe key will expire in 60 minutes!\nDO THIS COMMAND IN THE DMS! YOUR KEY IS PRIVATE DO NOT SHARE IT WITH ANYONE!",
settingsAnnounceSongs: "announcesongs", settingsAnnounceSongs: "announcesongs",
settingsAnnounceSongsDesc: settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.",
"Whether to announce songs that start playing or not.",
settingsBass: "bass", settingsBass: "bass",
settingsBassDesc: "Change the default bass level.", settingsBassDesc: "Change the default bass level.",
settingsBlacklist: "blacklist", settingsBlacklist: "blacklist",
settingsBlacklistDesc: settingsBlacklistDesc: "Blacklist channels that you wan't to block music commands to be executed on or block the bot from joining certain voiceChannels.",
"Blacklist channels that you wan't to block music commands to be executed on or block the bot from joining certain voiceChannels.",
settingsFooter: "how to use: %PREFIX%settings <Setting name> <value>", settingsFooter: "how to use: %PREFIX%settings <Setting name> <value>",
settingsPermissions: "permissions", settingsPermissions: "permissions",
settingsPermissionsDesc: settingsPermissionsDesc: "Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`",
"Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`",
settingsPrefix: "prefix", settingsPrefix: "prefix",
settingsPrefixDesc: "Change the guild specific prefix. (string)", settingsPrefixDesc: "Change the guild specific prefix. (string)",
settingsSetDj: "setdj", settingsSetDj: "setdj",
settingsSetDjDesc: settingsSetDjDesc: "Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!",
"Set a DJ role. This will allow chosen users to freely use all Musix commands. This will automatically set the `permissions` settings to true in order for the `DJ` role to have effect!",
settingsSetKey: "setkey", settingsSetKey: "setkey",
settingsSetKeyDesc: "Get instructions on how to set a spotify key.", settingsSetKeyDesc: "Get instructions on how to set a spotify key.",
settingsTitle: "Guild settings for Musix", settingsTitle: "Guild settings for Musix",
settingsVolume: "volume", settingsVolume: "volume",
settingsVolumeDesc: settingsVolumeDesc: "Change the default volume that the bot will start playing at. (number)",
"Change the default volume that the bot will start playing at. (number)",
setVolume: emojis.volumeHigh + "I set the volume to: ", setVolume: emojis.volumeHigh + "I set the volume to: ",
shuffled: emojis.shuffle + "Queue suffled!", shuffled: emojis.shuffle + "Queue suffled!",
skipped: emojis.skip + "Skipped the song!", skipped: emojis.skip + "Skipped the song!",
songAdded: songAdded: emojis.green_check_mark + "**%TITLE%** has been added to the queue!",
emojis.green_check_mark + "**%TITLE%** has been added to the queue!", songBlockedWMG: emojis.redx +
songBlockedWMG:
emojis.redx +
"This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.", "This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.",
songSelection: "__Song Selection__", songSelection: "__Song Selection__",
startPlaying: emojis.notes + "Start playing: ", startPlaying: emojis.notes + "Start playing: ",
@ -221,9 +174,7 @@ module.exports = {
statusField4: "Shard: ", statusField4: "Shard: ",
statusTitle: "Status for Musix", statusTitle: "Status for Musix",
stop: emojis.stop + "Stopped the music!", stop: emojis.stop + "Stopped the music!",
validNumber: validNumber: emojis.redx + "I'm sorry, But you need to enter a valid __number__.",
emojis.redx + "I'm sorry, But you need to enter a valid __number__.", wrongVoiceChannel: emojis.redx +
wrongVoiceChannel:
emojis.redx +
"I'm sorry but you need to be in the same voice channel as Musix to use this command!", "I'm sorry but you need to be in the same voice channel as Musix to use this command!",
}; };

View File

@ -1,8 +1,10 @@
module.exports = async function (guild, song, client, seek, play) { module.exports = async function (guild, song, client, seek, play) {
const { Readable: ReadableStream } = require("stream"); const {
Readable: ReadableStream
} = require("stream");
const Discord = require("discord.js"); const Discord = require("discord.js");
const ytdl = require("ytdl-core"); const ytdl = require("ytdl-core");
const streamConfig = require("../config/streamConfig.ts"); const streamConfig = require("../config/streamConfig.js");
const prism = require("prism-media"); const prism = require("prism-media");
const queue = client.queue.get(guild.id); const queue = client.queue.get(guild.id);
if (!song) { if (!song) {
@ -41,7 +43,9 @@ module.exports = async function (guild, song, client, seek, play) {
const args = isStream ? ffmpegArgs.slice() : ["-i", input, ...ffmpegArgs]; const args = isStream ? ffmpegArgs.slice() : ["-i", input, ...ffmpegArgs];
args.unshift("-ss", String(seek)); args.unshift("-ss", String(seek));
const transcoder = new prism.FFmpeg({ args: args }); const transcoder = new prism.FFmpeg({
args: args
});
const stream = input.pipe(transcoder); const stream = input.pipe(transcoder);
@ -71,4 +75,4 @@ module.exports = async function (guild, song, client, seek, play) {
queue.textChannel.send(embed); queue.textChannel.send(embed);
} }
queue.playing = true; queue.playing = true;
}; };

View File

@ -1,4 +1,4 @@
const config = require("../config/config.ts"); const config = require("../config/config.js");
const express = require("express"); // Express web server framework const express = require("express"); // Express web server framework
const request = require("request"); // "Request" library const request = require("request"); // "Request" library
const cors = require("cors"); const cors = require("cors");
@ -42,13 +42,13 @@ app.get("/login", function (req, res) {
res.redirect( res.redirect(
"https://accounts.spotify.com/authorize?" + "https://accounts.spotify.com/authorize?" +
querystring.stringify({ querystring.stringify({
response_type: "code", response_type: "code",
client_id: client_id, client_id: client_id,
scope: scope, scope: scope,
redirect_uri: redirect_uri, redirect_uri: redirect_uri,
state: state, state: state,
}) })
); );
}); });
@ -63,9 +63,9 @@ app.get("/callback", function (req, res) {
if (state === null || state !== storedState) { if (state === null || state !== storedState) {
res.redirect( res.redirect(
"/#" + "/#" +
querystring.stringify({ querystring.stringify({
error: "state_mismatch", error: "state_mismatch",
}) })
); );
} else { } else {
res.clearCookie(stateKey); res.clearCookie(stateKey);
@ -77,8 +77,7 @@ app.get("/callback", function (req, res) {
grant_type: "authorization_code", grant_type: "authorization_code",
}, },
headers: { headers: {
Authorization: Authorization: "Basic " +
"Basic " +
new Buffer(client_id + ":" + client_secret).toString("base64"), new Buffer(client_id + ":" + client_secret).toString("base64"),
}, },
json: true, json: true,
@ -105,17 +104,17 @@ app.get("/callback", function (req, res) {
// we can also pass the token to the browser to make requests from there // we can also pass the token to the browser to make requests from there
res.redirect( res.redirect(
"/#" + "/#" +
querystring.stringify({ querystring.stringify({
access_token: access_token, access_token: access_token,
refresh_token: refresh_token, refresh_token: refresh_token,
}) })
); );
} else { } else {
res.redirect( res.redirect(
"/#" + "/#" +
querystring.stringify({ querystring.stringify({
error: "invalid_token", error: "invalid_token",
}) })
); );
} }
}); });
@ -128,8 +127,7 @@ app.get("/refresh_token", function (req, res) {
var authOptions = { var authOptions = {
url: "https://accounts.spotify.com/api/token", url: "https://accounts.spotify.com/api/token",
headers: { headers: {
Authorization: Authorization: "Basic " +
"Basic " +
new Buffer(client_id + ":" + client_secret).toString("base64"), new Buffer(client_id + ":" + client_secret).toString("base64"),
}, },
form: { form: {
@ -150,4 +148,4 @@ app.get("/refresh_token", function (req, res) {
}); });
console.log("Listening on " + config.port); console.log("Listening on " + config.port);
app.listen(config.port); app.listen(config.port);