From a6e3e8b0defd9cb8e391b2fd2a9f966a51c50489 Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Mon, 20 Apr 2020 19:56:23 +0300 Subject: [PATCH] to js --- .gitignore | 3 +- config/config.ts | 2 +- config/serviceAccount.json | 12 ++ index.js | 39 +++-- src/bot.js | 2 + src/bot.ts | 2 - src/commands/{bass.ts => bass.js} | 0 src/commands/{cmduses.ts => cmduses.js} | 0 src/commands/{end.ts => end.js} | 0 src/commands/{eval.ts => eval.js} | 0 src/commands/{help.ts => help.js} | 0 src/commands/{invite.ts => invite.js} | 0 src/commands/{join.ts => join.js} | 0 src/commands/{loop.ts => loop.js} | 0 src/commands/{loopsong.ts => loopsong.js} | 0 src/commands/{lyrics.ts => lyrics.js} | 0 src/commands/{nigthcore.ts => nigthcore.js} | 0 src/commands/{nowplaying.ts => nowplaying.js} | 0 src/commands/{pause.ts => pause.js} | 0 src/commands/{play.ts => play.js} | 14 +- src/commands/{queue.ts => queue.js} | 4 +- src/commands/{remove.ts => remove.js} | 0 src/commands/{restart.ts => restart.js} | 0 src/commands/{resume.ts => resume.js} | 0 src/commands/{savedb.ts => savedb.js} | 0 src/commands/{search.ts => search.js} | 0 src/commands/{seek.ts => seek.js} | 0 src/commands/{settings.ts => settings.js} | 0 .../{announcesongs.ts => announcesongs.js} | 0 src/commands/settings/{bass.ts => bass.js} | 0 .../settings/{blacklist.ts => blacklist.js} | 0 .../{permissions.ts => permissions.js} | 0 .../settings/{prefix.ts => prefix.js} | 0 .../settings/{premium.ts => premium.js} | 0 src/commands/settings/{reset.ts => reset.js} | 0 src/commands/settings/{setDj.ts => setDj.js} | 0 .../settings/{setKey.ts => setKey.js} | 0 .../settings/{volume.ts => volume.js} | 0 src/commands/{shuffle.ts => shuffle.js} | 0 src/commands/{skip.ts => skip.js} | 0 src/commands/{skipto.ts => skipto.js} | 0 src/commands/{soundcloud.ts => soundcloud.js} | 0 src/commands/{status.ts => status.js} | 0 src/commands/{stop.ts => stop.js} | 0 src/commands/{volume.ts => volume.js} | 0 .../{guildCreate.ts => guildCreate.js} | 0 src/events/clientEvents/{msg.ts => msg.js} | 8 +- .../clientEvents/{ready.ts => ready.js} | 0 ...oiceStateUpdate.ts => voiceStateUpdate.js} | 0 .../dispatcherEvents/{error.ts => error.js} | 0 .../dispatcherEvents/{finish.ts => finish.js} | 0 src/events/{events.ts => events.js} | 8 +- src/struct/{client.ts => client.js} | 21 +-- src/struct/config/{emojis.ts => emojis.js} | 0 .../config/{messages.ts => messages.js} | 151 ++++++------------ .../config/{queueConfig.ts => queueConfig.js} | 0 .../{streamConfig.ts => streamConfig.js} | 0 src/struct/funcs/{check.ts => check.js} | 0 src/struct/funcs/{checkDB.ts => checkDB.js} | 0 src/struct/funcs/{dbget.ts => dbget.js} | 0 src/struct/funcs/{end.ts => end.js} | 0 src/struct/funcs/{exe.ts => exe.js} | 0 src/struct/funcs/{ffmpeg.ts => ffmpeg.js} | 0 .../funcs/{handleVideo.ts => handleVideo.js} | 0 src/struct/funcs/{msToTime.ts => msToTime.js} | 0 src/struct/funcs/{play.ts => play.js} | 12 +- src/struct/funcs/{saveDB.ts => saveDB.js} | 0 src/struct/funcs/{shuffle.ts => shuffle.js} | 0 src/struct/funcs/{sleep.ts => sleep.js} | 0 src/struct/funcs/{urlMatch.ts => urlMatch.js} | 0 web/app.js | 44 +++-- 71 files changed, 158 insertions(+), 164 deletions(-) create mode 100644 config/serviceAccount.json create mode 100644 src/bot.js delete mode 100644 src/bot.ts rename src/commands/{bass.ts => bass.js} (100%) rename src/commands/{cmduses.ts => cmduses.js} (100%) rename src/commands/{end.ts => end.js} (100%) rename src/commands/{eval.ts => eval.js} (100%) rename src/commands/{help.ts => help.js} (100%) rename src/commands/{invite.ts => invite.js} (100%) rename src/commands/{join.ts => join.js} (100%) rename src/commands/{loop.ts => loop.js} (100%) rename src/commands/{loopsong.ts => loopsong.js} (100%) rename src/commands/{lyrics.ts => lyrics.js} (100%) rename src/commands/{nigthcore.ts => nigthcore.js} (100%) rename src/commands/{nowplaying.ts => nowplaying.js} (100%) rename src/commands/{pause.ts => pause.js} (100%) rename src/commands/{play.ts => play.js} (94%) rename src/commands/{queue.ts => queue.js} (97%) rename src/commands/{remove.ts => remove.js} (100%) rename src/commands/{restart.ts => restart.js} (100%) rename src/commands/{resume.ts => resume.js} (100%) rename src/commands/{savedb.ts => savedb.js} (100%) rename src/commands/{search.ts => search.js} (100%) rename src/commands/{seek.ts => seek.js} (100%) rename src/commands/{settings.ts => settings.js} (100%) rename src/commands/settings/{announcesongs.ts => announcesongs.js} (100%) rename src/commands/settings/{bass.ts => bass.js} (100%) rename src/commands/settings/{blacklist.ts => blacklist.js} (100%) rename src/commands/settings/{permissions.ts => permissions.js} (100%) rename src/commands/settings/{prefix.ts => prefix.js} (100%) rename src/commands/settings/{premium.ts => premium.js} (100%) rename src/commands/settings/{reset.ts => reset.js} (100%) rename src/commands/settings/{setDj.ts => setDj.js} (100%) rename src/commands/settings/{setKey.ts => setKey.js} (100%) rename src/commands/settings/{volume.ts => volume.js} (100%) rename src/commands/{shuffle.ts => shuffle.js} (100%) rename src/commands/{skip.ts => skip.js} (100%) rename src/commands/{skipto.ts => skipto.js} (100%) rename src/commands/{soundcloud.ts => soundcloud.js} (100%) rename src/commands/{status.ts => status.js} (100%) rename src/commands/{stop.ts => stop.js} (100%) rename src/commands/{volume.ts => volume.js} (100%) rename src/events/clientEvents/{guildCreate.ts => guildCreate.js} (100%) rename src/events/clientEvents/{msg.ts => msg.js} (91%) rename src/events/clientEvents/{ready.ts => ready.js} (100%) rename src/events/clientEvents/{voiceStateUpdate.ts => voiceStateUpdate.js} (100%) rename src/events/dispatcherEvents/{error.ts => error.js} (100%) rename src/events/dispatcherEvents/{finish.ts => finish.js} (100%) rename src/events/{events.ts => events.js} (66%) rename src/struct/{client.ts => client.js} (85%) rename src/struct/config/{emojis.ts => emojis.js} (100%) rename src/struct/config/{messages.ts => messages.js} (66%) rename src/struct/config/{queueConfig.ts => queueConfig.js} (100%) rename src/struct/config/{streamConfig.ts => streamConfig.js} (100%) rename src/struct/funcs/{check.ts => check.js} (100%) rename src/struct/funcs/{checkDB.ts => checkDB.js} (100%) rename src/struct/funcs/{dbget.ts => dbget.js} (100%) rename src/struct/funcs/{end.ts => end.js} (100%) rename src/struct/funcs/{exe.ts => exe.js} (100%) rename src/struct/funcs/{ffmpeg.ts => ffmpeg.js} (100%) rename src/struct/funcs/{handleVideo.ts => handleVideo.js} (100%) rename src/struct/funcs/{msToTime.ts => msToTime.js} (100%) rename src/struct/funcs/{play.ts => play.js} (91%) rename src/struct/funcs/{saveDB.ts => saveDB.js} (100%) rename src/struct/funcs/{shuffle.ts => shuffle.js} (100%) rename src/struct/funcs/{sleep.ts => sleep.js} (100%) rename src/struct/funcs/{urlMatch.ts => urlMatch.js} (100%) diff --git a/.gitignore b/.gitignore index 7d24e34b..e7e74c08 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ dev/ .env .vscode/ -struct/config/serviceAccount.json \ No newline at end of file +struct/config/serviceAccount.json +./config/serviceAccount.json \ No newline at end of file diff --git a/config/config.ts b/config/config.ts index 6720ee9b..18d2af7d 100644 --- a/config/config.ts +++ b/config/config.ts @@ -20,7 +20,7 @@ module.exports = { invite: "https://discordapp.com/oauth2/authorize?client_id=607266889537945605&permissions=3427328&scope=bot", supportServer: "https://discord.gg/rvHuJtB", - devMode: false, + devMode: true, api: false, saveDB: true, respawn: true, diff --git a/config/serviceAccount.json b/config/serviceAccount.json new file mode 100644 index 00000000..39f4279d --- /dev/null +++ b/config/serviceAccount.json @@ -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" +} diff --git a/index.js b/index.js index 8df5fe77..1ce43182 100644 --- a/index.js +++ b/index.js @@ -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) { - console.log('- dev mode- '); - config.token = config.devToken; - config.shards = 1; + console.log("- dev mode- "); + config.token = config.devToken; + config.shards = 1; } const { - ShardingManager -} = require('discord.js'); -const manager = new ShardingManager('./src/bot.ts', { - token: config.token, - respawn: config.respawn, - totalShards: config.shards + ShardingManager +} = require("discord.js"); +const manager = new ShardingManager("./src/bot.js", { + token: config.token, + respawn: config.respawn, + totalShards: config.shards, }); -console.log('- Launching shards -'); +console.log("- Launching shards -"); manager.spawn(config.shards, config.shardDelay, config.shardTimeout); -manager.on('shardCreate', shard => console.log(`- Launched shard ${shard.id} -`)); \ No newline at end of file +manager.on("shardCreate", (shard) => + console.log(`- Launched shard ${shard.id} -`) +); \ No newline at end of file diff --git a/src/bot.js b/src/bot.js new file mode 100644 index 00000000..f0066a36 --- /dev/null +++ b/src/bot.js @@ -0,0 +1,2 @@ +const MusicClient = require('./struct/client.js'); +const client = new MusicClient({}); \ No newline at end of file diff --git a/src/bot.ts b/src/bot.ts deleted file mode 100644 index 21fca982..00000000 --- a/src/bot.ts +++ /dev/null @@ -1,2 +0,0 @@ -const MusicClient = require('./struct/client.ts'); -const client = new MusicClient({}); \ No newline at end of file diff --git a/src/commands/bass.ts b/src/commands/bass.js similarity index 100% rename from src/commands/bass.ts rename to src/commands/bass.js diff --git a/src/commands/cmduses.ts b/src/commands/cmduses.js similarity index 100% rename from src/commands/cmduses.ts rename to src/commands/cmduses.js diff --git a/src/commands/end.ts b/src/commands/end.js similarity index 100% rename from src/commands/end.ts rename to src/commands/end.js diff --git a/src/commands/eval.ts b/src/commands/eval.js similarity index 100% rename from src/commands/eval.ts rename to src/commands/eval.js diff --git a/src/commands/help.ts b/src/commands/help.js similarity index 100% rename from src/commands/help.ts rename to src/commands/help.js diff --git a/src/commands/invite.ts b/src/commands/invite.js similarity index 100% rename from src/commands/invite.ts rename to src/commands/invite.js diff --git a/src/commands/join.ts b/src/commands/join.js similarity index 100% rename from src/commands/join.ts rename to src/commands/join.js diff --git a/src/commands/loop.ts b/src/commands/loop.js similarity index 100% rename from src/commands/loop.ts rename to src/commands/loop.js diff --git a/src/commands/loopsong.ts b/src/commands/loopsong.js similarity index 100% rename from src/commands/loopsong.ts rename to src/commands/loopsong.js diff --git a/src/commands/lyrics.ts b/src/commands/lyrics.js similarity index 100% rename from src/commands/lyrics.ts rename to src/commands/lyrics.js diff --git a/src/commands/nigthcore.ts b/src/commands/nigthcore.js similarity index 100% rename from src/commands/nigthcore.ts rename to src/commands/nigthcore.js diff --git a/src/commands/nowplaying.ts b/src/commands/nowplaying.js similarity index 100% rename from src/commands/nowplaying.ts rename to src/commands/nowplaying.js diff --git a/src/commands/pause.ts b/src/commands/pause.js similarity index 100% rename from src/commands/pause.ts rename to src/commands/pause.js diff --git a/src/commands/play.ts b/src/commands/play.js similarity index 94% rename from src/commands/play.ts rename to src/commands/play.js index 1b74391f..029b8899 100644 --- a/src/commands/play.ts +++ b/src/commands/play.js @@ -1,6 +1,7 @@ const YouTube = require("simple-youtube-api"); const search = require("yt-search"); const SpotifyApi = require("spotify-web-api-node"); +const { globaldb } = require("../../index.js"); module.exports = { name: "play", @@ -16,9 +17,16 @@ module.exports = { secret: client.config.spotify_client_secret, }); - spotify.setAccessToken( - client.global.db.guilds[msg.guild.id].spotify_access_key - ); + const dbdata = await globaldb + .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 searchString = args.slice(1).join(" "); diff --git a/src/commands/queue.ts b/src/commands/queue.js similarity index 97% rename from src/commands/queue.ts rename to src/commands/queue.js index 744b62f3..1d6a1833 100644 --- a/src/commands/queue.ts +++ b/src/commands/queue.js @@ -1,7 +1,7 @@ module.exports = { name: 'queue', alias: 'q', - usage: '', + usage: '', description: 'See the queue.', onlyDev: false, permission: 'none', @@ -25,4 +25,4 @@ module.exports = { .setColor(client.config.embedColor) return msg.channel.send(embed); } -}; +}; \ No newline at end of file diff --git a/src/commands/remove.ts b/src/commands/remove.js similarity index 100% rename from src/commands/remove.ts rename to src/commands/remove.js diff --git a/src/commands/restart.ts b/src/commands/restart.js similarity index 100% rename from src/commands/restart.ts rename to src/commands/restart.js diff --git a/src/commands/resume.ts b/src/commands/resume.js similarity index 100% rename from src/commands/resume.ts rename to src/commands/resume.js diff --git a/src/commands/savedb.ts b/src/commands/savedb.js similarity index 100% rename from src/commands/savedb.ts rename to src/commands/savedb.js diff --git a/src/commands/search.ts b/src/commands/search.js similarity index 100% rename from src/commands/search.ts rename to src/commands/search.js diff --git a/src/commands/seek.ts b/src/commands/seek.js similarity index 100% rename from src/commands/seek.ts rename to src/commands/seek.js diff --git a/src/commands/settings.ts b/src/commands/settings.js similarity index 100% rename from src/commands/settings.ts rename to src/commands/settings.js diff --git a/src/commands/settings/announcesongs.ts b/src/commands/settings/announcesongs.js similarity index 100% rename from src/commands/settings/announcesongs.ts rename to src/commands/settings/announcesongs.js diff --git a/src/commands/settings/bass.ts b/src/commands/settings/bass.js similarity index 100% rename from src/commands/settings/bass.ts rename to src/commands/settings/bass.js diff --git a/src/commands/settings/blacklist.ts b/src/commands/settings/blacklist.js similarity index 100% rename from src/commands/settings/blacklist.ts rename to src/commands/settings/blacklist.js diff --git a/src/commands/settings/permissions.ts b/src/commands/settings/permissions.js similarity index 100% rename from src/commands/settings/permissions.ts rename to src/commands/settings/permissions.js diff --git a/src/commands/settings/prefix.ts b/src/commands/settings/prefix.js similarity index 100% rename from src/commands/settings/prefix.ts rename to src/commands/settings/prefix.js diff --git a/src/commands/settings/premium.ts b/src/commands/settings/premium.js similarity index 100% rename from src/commands/settings/premium.ts rename to src/commands/settings/premium.js diff --git a/src/commands/settings/reset.ts b/src/commands/settings/reset.js similarity index 100% rename from src/commands/settings/reset.ts rename to src/commands/settings/reset.js diff --git a/src/commands/settings/setDj.ts b/src/commands/settings/setDj.js similarity index 100% rename from src/commands/settings/setDj.ts rename to src/commands/settings/setDj.js diff --git a/src/commands/settings/setKey.ts b/src/commands/settings/setKey.js similarity index 100% rename from src/commands/settings/setKey.ts rename to src/commands/settings/setKey.js diff --git a/src/commands/settings/volume.ts b/src/commands/settings/volume.js similarity index 100% rename from src/commands/settings/volume.ts rename to src/commands/settings/volume.js diff --git a/src/commands/shuffle.ts b/src/commands/shuffle.js similarity index 100% rename from src/commands/shuffle.ts rename to src/commands/shuffle.js diff --git a/src/commands/skip.ts b/src/commands/skip.js similarity index 100% rename from src/commands/skip.ts rename to src/commands/skip.js diff --git a/src/commands/skipto.ts b/src/commands/skipto.js similarity index 100% rename from src/commands/skipto.ts rename to src/commands/skipto.js diff --git a/src/commands/soundcloud.ts b/src/commands/soundcloud.js similarity index 100% rename from src/commands/soundcloud.ts rename to src/commands/soundcloud.js diff --git a/src/commands/status.ts b/src/commands/status.js similarity index 100% rename from src/commands/status.ts rename to src/commands/status.js diff --git a/src/commands/stop.ts b/src/commands/stop.js similarity index 100% rename from src/commands/stop.ts rename to src/commands/stop.js diff --git a/src/commands/volume.ts b/src/commands/volume.js similarity index 100% rename from src/commands/volume.ts rename to src/commands/volume.js diff --git a/src/events/clientEvents/guildCreate.ts b/src/events/clientEvents/guildCreate.js similarity index 100% rename from src/events/clientEvents/guildCreate.ts rename to src/events/clientEvents/guildCreate.js diff --git a/src/events/clientEvents/msg.ts b/src/events/clientEvents/msg.js similarity index 91% rename from src/events/clientEvents/msg.ts rename to src/events/clientEvents/msg.js index b77ccef8..74032272 100644 --- a/src/events/clientEvents/msg.ts +++ b/src/events/clientEvents/msg.js @@ -1,3 +1,5 @@ +const { db } = require("../../../index-.js"); + module.exports = { name: "message", async execute(client, msg, Discord) { @@ -6,9 +8,9 @@ module.exports = { const args = msg.content.split(" "); if (!args[1] || !args[2]) return msg.channel.send(client.messages.setKeyUsage); - if (!client.guilds.cache.get(args[2])) - return msg.channel.send(client.messages.invalidGuild); - client.global.db.guilds[args[2]].spotify_access_key = args[1]; + client.config.db.collection("guilds").doc(args[2]).set({ + key: args[1], + }); return msg.channel.send(client.messages.keySet); } if (!msg.guild) return; diff --git a/src/events/clientEvents/ready.ts b/src/events/clientEvents/ready.js similarity index 100% rename from src/events/clientEvents/ready.ts rename to src/events/clientEvents/ready.js diff --git a/src/events/clientEvents/voiceStateUpdate.ts b/src/events/clientEvents/voiceStateUpdate.js similarity index 100% rename from src/events/clientEvents/voiceStateUpdate.ts rename to src/events/clientEvents/voiceStateUpdate.js diff --git a/src/events/dispatcherEvents/error.ts b/src/events/dispatcherEvents/error.js similarity index 100% rename from src/events/dispatcherEvents/error.ts rename to src/events/dispatcherEvents/error.js diff --git a/src/events/dispatcherEvents/finish.ts b/src/events/dispatcherEvents/finish.js similarity index 100% rename from src/events/dispatcherEvents/finish.ts rename to src/events/dispatcherEvents/finish.js diff --git a/src/events/events.ts b/src/events/events.js similarity index 66% rename from src/events/events.ts rename to src/events/events.js index 82a62f1c..5c0ae4cb 100644 --- a/src/events/events.ts +++ b/src/events/events.js @@ -2,16 +2,16 @@ module.exports = function (client) { const Discord = require('discord.js'); const events = './clientEvents/'; client.on('ready', () => { - require(`${events}ready.ts`).execute(client, Discord); + require(`${events}ready.js`).execute(client, Discord); }); client.on('message', (msg) => { - require(`${events}msg.ts`).execute(client, msg, Discord); + require(`${events}msg.js`).execute(client, msg, Discord); }); client.on('guildCreate', (guild) => { - require(`${events}guildCreate.ts`).execute(client, guild); + require(`${events}guildCreate.js`).execute(client, guild); }); 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.channels.fetch(client.config.debug_channel).send(`Error: ${error} on shard: ${client.shard}`); diff --git a/src/struct/client.ts b/src/struct/client.js similarity index 85% rename from src/struct/client.ts rename to src/struct/client.js index 3c052f1d..a7fb1238 100644 --- a/src/struct/client.ts +++ b/src/struct/client.js @@ -1,9 +1,12 @@ -const { Client, Collection } = require("discord.js"); +const { + Client, + Collection +} = require("discord.js"); const admin = require("firebase-admin"); const serviceAccount = require("./config/serviceAccount.json"); const fs = require("fs"); const path = require("path"); -const events = require("../events/events.ts"); +const events = require("../events/events.js"); module.exports = class extends Client { constructor() { @@ -21,12 +24,12 @@ module.exports = class extends Client { this.queue = new Map(); this.funcs = {}; this.dispatcher = {}; - this.config = require("../../config/config.ts"); - this.messages = require("./config/messages.ts"); + this.config = require("../../config/config.js"); + this.messages = require("./config/messages.js"); this.db = admin.firestore(); this.db.FieldValue = require("firebase-admin").firestore.FieldValue; - this.dispatcher.finish = require("../events/dispatcherEvents/finish.ts"); - this.dispatcher.error = require("../events/dispatcherEvents/error.ts"); + this.dispatcher.finish = require("../events/dispatcherEvents/finish.js"); + this.dispatcher.error = require("../events/dispatcherEvents/error.js"); this.global = { db: { guilds: {}, @@ -39,7 +42,7 @@ module.exports = class extends Client { const commandFiles = fs .readdirSync(path.join(path.dirname(__dirname), "commands")) - .filter((f) => f.endsWith(".ts")); + .filter((f) => f.endsWith(".js")); for (const file of commandFiles) { const command = require(`../commands/${file}`); command.uses = 0; @@ -48,7 +51,7 @@ module.exports = class extends Client { } const settingFiles = fs .readdirSync(path.join(path.dirname(__dirname), "commands/settings")) - .filter((f) => f.endsWith(".ts")); + .filter((f) => f.endsWith(".js")); for (const file of settingFiles) { const option = require(`../commands/settings/${file}`); this.settingCmd.set(option.name, option); @@ -63,4 +66,4 @@ module.exports = class extends Client { console.log("Failed to login: " + err) ); } -}; +}; \ No newline at end of file diff --git a/src/struct/config/emojis.ts b/src/struct/config/emojis.js similarity index 100% rename from src/struct/config/emojis.ts rename to src/struct/config/emojis.js diff --git a/src/struct/config/messages.ts b/src/struct/config/messages.js similarity index 66% rename from src/struct/config/messages.ts rename to src/struct/config/messages.js index c931cd8b..93394c91 100644 --- a/src/struct/config/messages.ts +++ b/src/struct/config/messages.js @@ -1,34 +1,25 @@ -const emojis = require("./emojis.ts"); +const emojis = require("./emojis.js"); module.exports = { alreadyPaused: emojis.redx + "The music is already paused!", alreadyVoted: emojis.redx + "You have already voted to skip!", announceSongs: emojis.megaPhone + "Current setting:", - announceSongsFalse: - emojis.green_check_mark + "announcesongs now set to `false`!", - announceSongsTrue: - emojis.green_check_mark + "announcesongs now set to `true`!", - bassApplied: - emojis.volumeHigh + "The bass level **%BASS%** has been applied!", + announceSongsFalse: emojis.green_check_mark + "announcesongs now set to `false`!", + announceSongsTrue: 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!", bassLevel: emojis.green_check_mark + "Bass level is now", blacklistTitle: "Currently blacklisted channels:", - blackListedVC: - emojis.redx + + blackListedVC: emojis.redx + "Your voiceChannel is blacklisted! Please choose another channel!", boolean: emojis.redx + "Please define a boolean! (true/false)", cancellingVideoSelection: emojis.redx + "Cancelling video selection", - cantSkipToCurrent: - emojis.redx + "You can't skip to the song currently playing!", - channelAdded: - emojis.green_check_mark + "Channel %CHANNEL% added to the blacklist!", - channelAlreadyBlackListed: - emojis.redx + "That channel is already blacklisted!", + cantSkipToCurrent: emojis.redx + "You can't skip to the song currently playing!", + channelAdded: 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!", - channelNotBlackListed: - emojis.redx + "That channel is not blacklisted or does not exist!", - channelRemoved: - emojis.green_check_mark + + channelNotBlackListed: emojis.redx + "That channel is not blacklisted or does not exist!", + channelRemoved: emojis.green_check_mark + "Channel %CHANNEL% has been removed from the blacklist!", cmdUsesFooter: "These statistics are from the current uptime.", cmdUsesTitle: "Musix Command Usage During Current Uptime", @@ -40,43 +31,33 @@ module.exports = { currentPrefix: "Current prefix:", currentVolume: emojis.loudSound + "The current volume is: ", dbSaved: emojis.green_check_mark + "DB Saved!", - defaultVolumeMax: - emojis.redx + + defaultVolumeMax: emojis.redx + "The default volume must be below `100` for quality and safety resons.", - defaultVolumeNumber: - emojis.redx + + defaultVolumeNumber: emojis.redx + "I'm sorry, But the default volume needs to be a valid __number__.", defaultVolumeSet: emojis.green_check_mark + "Default volume set to:", - devMode: - emojis.redx + + devMode: emojis.redx + "Dev mode has been turned on! Commands are only available to developer(s)!", - disableNigthCore: - emojis.redx + "Please disable nigthCore in order to use this command!", + disableNigthCore: emojis.redx + "Please disable nigthCore in order to use this command!", dispatcherError: "Error with the dispatcher: ", djFalse: emojis.green_check_mark + "`DJ` now set to `false`", - djRoleCreated: - emojis.green_check_mark + + djRoleCreated: emojis.green_check_mark + "I did not find a role `DJ` so i have created one for you!", - djRoleFound: - emojis.green_check_mark + + djRoleFound: emojis.green_check_mark + "I found a `DJ` role from this guild! This role is now the DJ role.", error: emojis.redx + "An error occured!", errorConnecting: "Error with connecting to voice channel: ", errorDetected: "Error detected: ", - errorDispatcher: - emojis.redx + + errorDispatcher: emojis.redx + "An error has occured while playing music! The queue has been deleted.", errorExe: emojis.redx + "there was an error trying to execute that command!", - errorExeOpt: - emojis.redx + "there was an error trying to execute that option!", + errorExeOpt: emojis.redx + "there was an error trying to execute that option!", evalTitle: "Evaluation Command", failedToLoad: emojis.redx + "Songs failed to load: ", helpCmdFooter: "Command Alias:", - helpFooter: - '"%PREFIX%help " to see more information about a command.', + helpFooter: '"%PREFIX%help " to see more information about a command.', helpTitle: "help", - idOrMentionChannel: - emojis.redx + "Please provide a channel id or mention a channel!", + idOrMentionChannel: emojis.redx + "Please provide a channel id or mention a channel!", invalidGuild: emojis.redx + "Invalid guild id!", inviteTitle: "Invite Musix to your Discord server!", joined: emojis.green_check_mark + "Joined", @@ -90,40 +71,31 @@ module.exports = { maxBass: emojis.redx + "The max bass is `100`!", maxVolume: emojis.redx + "The max volume is `100`!", mentionChannel: emojis.redx + "Please mention a channel!", - musicCommandsDisabled: - emojis.redx + + musicCommandsDisabled: emojis.redx + "This channels has been blacklisted! Music commands cannot be used here!", - nigthCoreApplied: - emojis.green_check_mark + + nigthCoreApplied: emojis.green_check_mark + "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!", noLooping: emojis.repeat + "No longer looping the queue!", noLoopingSong: emojis.repeatSong + "No longer looping the song!", noMorePremium: ":cry: Guild %GUILD% is no longer premium!", noPerms: emojis.redx + `You need the %PERMS% permission to use this command!`, - noPermsConnect: - emojis.redx + + noPermsConnect: emojis.redx + "I cannot connect to your voice channel, make sure I have the proper permissions!", - noPermsEmbed: - emojis.redx + + noPermsEmbed: emojis.redx + "I cannot send embeds (Embed links), make sure I have the proper permissions!", - noPermsManageRoles: - emojis.redx + + noPermsManageRoles: 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!", - noPermsManageSettings: - emojis.redx + + noPermsManageSettings: emojis.redx + "You need the `MANAGE_SERVER` permission to change the settings!", - noPermsSpeak: - emojis.redx + + noPermsSpeak: emojis.redx + "I cannot speak in your voice channel, make sure I have the proper permissions!", - noPermsUseExternalEmojis: - emojis.redx + + noPermsUseExternalEmojis: emojis.redx + "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!", noResults: emojis.redx + "I could not obtain any search results!", noResultsLyrics: emojis.redx + "I could not obtain any results!", - noResultsSpotify: - emojis.redx + + noResultsSpotify: emojis.redx + "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!", noSongs: emojis.redx + "That song does not exist!", @@ -132,8 +104,7 @@ module.exports = { notAllowed: emojis.redx + "You are not allowed to do that!", notEnoughVotes: emojis.redx + "Not enough votes!", notPaused: emojis.redx + "The music in not paused!", - noVoiceChannel: - emojis.redx + + noVoiceChannel: emojis.redx + "I'm sorry but you need to be in a voice channel to play music!", nowPlaying: "__Now playing__", nowPremium: ":tada: Guild %GUILD% is now premium!", @@ -141,14 +112,11 @@ module.exports = { paused: emojis.pause + "Paused the music!", permission: "🔒 Permission requirement:", permissionsFalse: emojis.redx + "That value is already `false`!", - permissionsSetFalse: - emojis.green_check_mark + "Permissions requirement now set to: `false`", - permissionsSetTrue: - emojis.green_check_mark + "Permissions requirement now set to: `true`", + permissionsSetFalse: emojis.green_check_mark + "Permissions requirement now set to: `false`", + permissionsSetTrue: emojis.green_check_mark + "Permissions requirement now set to: `true`", permissionsTrue: emojis.redx + "That value is already `true`!", pinging: emojis.loading + "Pinging...", - playlistAdded: - emojis.green_check_mark + + playlistAdded: emojis.green_check_mark + "Playlist: **%TITLE%** has been added to the queue!", positiveBass: emojis.redx + "The bass 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!", prefixSet: emojis.green_check_mark + "New prefix set to:", premiumState: "Premium status: ", - provideANumber: - "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!", + provideANumber: "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!", queueDeleted: "Queue deleted!", - queueDesc: - "**Now playing:** %SONG%\n:arrow_down: Next in queue :arrow_down:", + queueDesc: "**Now playing:** %SONG%\n:arrow_down: Next in queue :arrow_down:", queueFooter: "songs in the queue!", - queueLength: - emojis.redx + "There are only %SONGS% amount of songs in the queue!", + queueLength: emojis.redx + "There are only %SONGS% amount of songs in the queue!", queueTitle: "__Song queue__", - quotaReached: - emojis.redx + + quotaReached: emojis.redx + "Quota reached please try again after midnight Pacific Time (PT)!", reloaded: "All files reloaded!", removed: emojis.garbage + "removed `%SONG%` from the queue!", reset: emojis.green_check_mark + "Reset __all__ guild settings!", restart: "restarting all shards...", resumed: emojis.resume + "Resumed the music!", - seekingPointPositive: - emojis.redx + "The seeking point needs to be a positive number!", - seekMax: - emojis.redx + + seekingPointPositive: emojis.redx + "The seeking point needs to be a positive number!", + seekMax: emojis.redx + "The lenght of this song is %LENGTH% seconds! You can't seek further than that!", - setKeyUsage: - "Usage: `setkey `. Get your key from 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!", + setKeyUsage: "Usage: `setkey `. Get your key from 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", - settingsAnnounceSongsDesc: - "Whether to announce songs that start playing or not.", + settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.", settingsBass: "bass", settingsBassDesc: "Change the default bass level.", settingsBlacklist: "blacklist", - settingsBlacklistDesc: - "Blacklist channels that you wan't to block music commands to be executed on or block the bot from joining certain voiceChannels.", + settingsBlacklistDesc: "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  ", settingsPermissions: "permissions", - settingsPermissionsDesc: - "Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`", + settingsPermissionsDesc: "Change whether to require permissions to use eg `skip, stop, pause, loop, etc...`", settingsPrefix: "prefix", settingsPrefixDesc: "Change the guild specific prefix. (string)", settingsSetDj: "setdj", - 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!", + 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!", settingsSetKey: "setkey", settingsSetKeyDesc: "Get instructions on how to set a spotify key.", settingsTitle: "Guild settings for Musix", settingsVolume: "volume", - settingsVolumeDesc: - "Change the default volume that the bot will start playing at. (number)", + settingsVolumeDesc: "Change the default volume that the bot will start playing at. (number)", setVolume: emojis.volumeHigh + "I set the volume to: ", shuffled: emojis.shuffle + "Queue suffled!", skipped: emojis.skip + "Skipped the song!", - songAdded: - emojis.green_check_mark + "**%TITLE%** has been added to the queue!", - songBlockedWMG: - emojis.redx + + songAdded: emojis.green_check_mark + "**%TITLE%** has been added to the queue!", + songBlockedWMG: emojis.redx + "This song had been blocked by WMG (Warner Music Groud).\n<:skip:674685614221688832> Skipped to next song.", songSelection: "__Song Selection__", startPlaying: emojis.notes + "Start playing: ", @@ -221,9 +174,7 @@ module.exports = { statusField4: "Shard: ", statusTitle: "Status for Musix", stop: emojis.stop + "Stopped the music!", - validNumber: - emojis.redx + "I'm sorry, But you need to enter a valid __number__.", - wrongVoiceChannel: - emojis.redx + + validNumber: emojis.redx + "I'm sorry, But you need to enter a valid __number__.", + wrongVoiceChannel: emojis.redx + "I'm sorry but you need to be in the same voice channel as Musix to use this command!", -}; +}; \ No newline at end of file diff --git a/src/struct/config/queueConfig.ts b/src/struct/config/queueConfig.js similarity index 100% rename from src/struct/config/queueConfig.ts rename to src/struct/config/queueConfig.js diff --git a/src/struct/config/streamConfig.ts b/src/struct/config/streamConfig.js similarity index 100% rename from src/struct/config/streamConfig.ts rename to src/struct/config/streamConfig.js diff --git a/src/struct/funcs/check.ts b/src/struct/funcs/check.js similarity index 100% rename from src/struct/funcs/check.ts rename to src/struct/funcs/check.js diff --git a/src/struct/funcs/checkDB.ts b/src/struct/funcs/checkDB.js similarity index 100% rename from src/struct/funcs/checkDB.ts rename to src/struct/funcs/checkDB.js diff --git a/src/struct/funcs/dbget.ts b/src/struct/funcs/dbget.js similarity index 100% rename from src/struct/funcs/dbget.ts rename to src/struct/funcs/dbget.js diff --git a/src/struct/funcs/end.ts b/src/struct/funcs/end.js similarity index 100% rename from src/struct/funcs/end.ts rename to src/struct/funcs/end.js diff --git a/src/struct/funcs/exe.ts b/src/struct/funcs/exe.js similarity index 100% rename from src/struct/funcs/exe.ts rename to src/struct/funcs/exe.js diff --git a/src/struct/funcs/ffmpeg.ts b/src/struct/funcs/ffmpeg.js similarity index 100% rename from src/struct/funcs/ffmpeg.ts rename to src/struct/funcs/ffmpeg.js diff --git a/src/struct/funcs/handleVideo.ts b/src/struct/funcs/handleVideo.js similarity index 100% rename from src/struct/funcs/handleVideo.ts rename to src/struct/funcs/handleVideo.js diff --git a/src/struct/funcs/msToTime.ts b/src/struct/funcs/msToTime.js similarity index 100% rename from src/struct/funcs/msToTime.ts rename to src/struct/funcs/msToTime.js diff --git a/src/struct/funcs/play.ts b/src/struct/funcs/play.js similarity index 91% rename from src/struct/funcs/play.ts rename to src/struct/funcs/play.js index 3e98b629..2740b42e 100644 --- a/src/struct/funcs/play.ts +++ b/src/struct/funcs/play.js @@ -1,8 +1,10 @@ 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 ytdl = require("ytdl-core"); - const streamConfig = require("../config/streamConfig.ts"); + const streamConfig = require("../config/streamConfig.js"); const prism = require("prism-media"); const queue = client.queue.get(guild.id); if (!song) { @@ -41,7 +43,9 @@ module.exports = async function (guild, song, client, seek, play) { const args = isStream ? ffmpegArgs.slice() : ["-i", input, ...ffmpegArgs]; args.unshift("-ss", String(seek)); - const transcoder = new prism.FFmpeg({ args: args }); + const transcoder = new prism.FFmpeg({ + args: args + }); const stream = input.pipe(transcoder); @@ -71,4 +75,4 @@ module.exports = async function (guild, song, client, seek, play) { queue.textChannel.send(embed); } queue.playing = true; -}; +}; \ No newline at end of file diff --git a/src/struct/funcs/saveDB.ts b/src/struct/funcs/saveDB.js similarity index 100% rename from src/struct/funcs/saveDB.ts rename to src/struct/funcs/saveDB.js diff --git a/src/struct/funcs/shuffle.ts b/src/struct/funcs/shuffle.js similarity index 100% rename from src/struct/funcs/shuffle.ts rename to src/struct/funcs/shuffle.js diff --git a/src/struct/funcs/sleep.ts b/src/struct/funcs/sleep.js similarity index 100% rename from src/struct/funcs/sleep.ts rename to src/struct/funcs/sleep.js diff --git a/src/struct/funcs/urlMatch.ts b/src/struct/funcs/urlMatch.js similarity index 100% rename from src/struct/funcs/urlMatch.ts rename to src/struct/funcs/urlMatch.js diff --git a/web/app.js b/web/app.js index 127917a1..8f4af3bd 100644 --- a/web/app.js +++ b/web/app.js @@ -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 request = require("request"); // "Request" library const cors = require("cors"); @@ -42,13 +42,13 @@ app.get("/login", function (req, res) { res.redirect( "https://accounts.spotify.com/authorize?" + - querystring.stringify({ - response_type: "code", - client_id: client_id, - scope: scope, - redirect_uri: redirect_uri, - state: state, - }) + querystring.stringify({ + response_type: "code", + client_id: client_id, + scope: scope, + redirect_uri: redirect_uri, + state: state, + }) ); }); @@ -63,9 +63,9 @@ app.get("/callback", function (req, res) { if (state === null || state !== storedState) { res.redirect( "/#" + - querystring.stringify({ - error: "state_mismatch", - }) + querystring.stringify({ + error: "state_mismatch", + }) ); } else { res.clearCookie(stateKey); @@ -77,8 +77,7 @@ app.get("/callback", function (req, res) { grant_type: "authorization_code", }, headers: { - Authorization: - "Basic " + + Authorization: "Basic " + new Buffer(client_id + ":" + client_secret).toString("base64"), }, 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 res.redirect( "/#" + - querystring.stringify({ - access_token: access_token, - refresh_token: refresh_token, - }) + querystring.stringify({ + access_token: access_token, + refresh_token: refresh_token, + }) ); } else { res.redirect( "/#" + - querystring.stringify({ - error: "invalid_token", - }) + querystring.stringify({ + error: "invalid_token", + }) ); } }); @@ -128,8 +127,7 @@ app.get("/refresh_token", function (req, res) { var authOptions = { url: "https://accounts.spotify.com/api/token", headers: { - Authorization: - "Basic " + + Authorization: "Basic " + new Buffer(client_id + ":" + client_secret).toString("base64"), }, form: { @@ -150,4 +148,4 @@ app.get("/refresh_token", function (req, res) { }); console.log("Listening on " + config.port); -app.listen(config.port); +app.listen(config.port); \ No newline at end of file