diff --git a/src/commands/play.ts b/src/commands/play.ts index 1512a088..1b74391f 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -16,7 +16,9 @@ module.exports = { secret: client.config.spotify_client_secret, }); - spotify.setAccessToken(client.config.spotify_access_key); + spotify.setAccessToken( + client.global.db.guilds[msg.guild.id].spotify_access_key + ); const youtube = new YouTube(client.config.api_key); const searchString = args.slice(1).join(" "); @@ -123,7 +125,7 @@ module.exports = { }, function (err) { console.log(err); - msg.channel.send(client.messages.noResults); + msg.channel.send(client.messages.noResultsSpotify); } ); } else if ( diff --git a/src/commands/settings.ts b/src/commands/settings.ts index 5226a4b4..a32b2fd7 100644 --- a/src/commands/settings.ts +++ b/src/commands/settings.ts @@ -26,7 +26,7 @@ module.exports = { ) .addField( client.messages.settingsBlacklist, - client.messages.settingsBlacklist, + client.messages.settingsBlacklistDesc, true ) .addField( @@ -48,6 +48,11 @@ module.exports = { client.messages.settingsBassDesc, true ) + .addField( + client.messages.settingsSetKey, + client.messages.settingsSetKeyDesc, + true + ) .setFooter(footer) .setAuthor(client.user.username, client.user.displayAvatarURL) .setColor(client.config.embedColor); diff --git a/src/commands/settings/premium.ts b/src/commands/settings/premium.ts index b0a713ca..07743ac3 100644 --- a/src/commands/settings/premium.ts +++ b/src/commands/settings/premium.ts @@ -1,12 +1,12 @@ module.exports = { name: "premium", async execute(msg, args, client) { - if (msg.member.id !== client.config.devId) - return msg.channel.send(client.messages.onlyDev); if (!args[2]) return msg.channel.send( - `${client.messages.correctUsage} ${client.messages.premiumUsage}` + client.messages.premiumState + client.global.db.guilds[args[2]].premium ); + if (msg.member.id !== client.config.devId) + return msg.channel.send(client.messages.onlyDev); if (client.global.db.guilds[args[2]].premium === false) { client.global.db.guilds[args[2]].premium = true; let message; diff --git a/src/commands/settings/setKey.ts b/src/commands/settings/setKey.ts new file mode 100644 index 00000000..db904b73 --- /dev/null +++ b/src/commands/settings/setKey.ts @@ -0,0 +1,6 @@ +module.exports = { + name: "setkey", + async execute(msg, args, client) { + msg.channel.send(client.messages.setKeyUsage); + }, +}; diff --git a/src/events/clientEvents/msg.ts b/src/events/clientEvents/msg.ts index 63cd9069..b77ccef8 100644 --- a/src/events/clientEvents/msg.ts +++ b/src/events/clientEvents/msg.ts @@ -1,32 +1,51 @@ module.exports = { - name: 'message', - async execute(client, msg, Discord) { - if (msg.author.bot || !msg.guild) return; - if (!client.global.db.guilds[msg.guild.id]) return; - let prefix = client.global.db.guilds[msg.guild.id].prefix; - if (client.config.devMode) prefix = client.config.devPrefix; - const args = msg.content.slice(prefix.length).split(' '); - if (msg.mentions.users.first()) { - if (msg.mentions.users.first().id === client.user.id) { - if (!args[1]) return; - if (args[1] === 'prefix') { - if (!args[2]) return msg.channel.send(`${client.messages.prefixHere}\`${prefix}\`.`); - if (args[2] === "=" && args[3]) return prefix = args[3]; - } - if (args[1] === 'help') { - const command = client.commands.get("help"); - return client.funcs.exe(msg, args, client, Discord, prefix, command); - } - } - } - if (!msg.content.startsWith(prefix)) return; - if (!args[0]) return; - const commandName = args[0].toLowerCase(); - if (commandName === "none") return; - const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName); - if (!command && msg.content !== `${prefix}`) return; - if (command.onlyDev && msg.author.id !== client.config.devId) return; - if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send(client.messages.devMode); - client.funcs.exe(msg, args, client, Discord, command); + name: "message", + async execute(client, msg, Discord) { + if (msg.author.bot) return; + if (!msg.guild && msg.content.startsWith("setkey")) { + 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]; + return msg.channel.send(client.messages.keySet); } -} \ No newline at end of file + if (!msg.guild) return; + if (!client.global.db.guilds[msg.guild.id]) return; + let prefix = client.global.db.guilds[msg.guild.id].prefix; + const args = msg.content.slice(prefix.length).split(" "); + if (client.config.devMode) prefix = client.config.devPrefix; + if (msg.mentions.users.first()) { + if (msg.mentions.users.first().id === client.user.id) { + if (!args[1]) return; + if (args[1] === "prefix") { + if (!args[2]) + return msg.channel.send( + `${client.messages.prefixHere}\`${prefix}\`.` + ); + if (args[2] === "=" && args[3]) return (prefix = args[3]); + } + if (args[1] === "help") { + const command = client.commands.get("help"); + return client.funcs.exe(msg, args, client, Discord, prefix, command); + } + } + } + if (!msg.content.startsWith(prefix)) return; + if (!args[0]) return; + const commandName = args[0].toLowerCase(); + if (commandName === "none") return; + const command = + client.commands.get(commandName) || + client.commands.find( + (cmd) => cmd.aliases && cmd.aliases.includes(commandName) + ) || + client.commandAliases.get(commandName); + if (!command && msg.content !== `${prefix}`) return; + if (command.onlyDev && msg.author.id !== client.config.devId) return; + if (client.config.devMode && msg.member.id !== client.config.devId) + return msg.channel.send(client.messages.devMode); + client.funcs.exe(msg, args, client, Discord, command); + }, +}; diff --git a/src/struct/config/messages.ts b/src/struct/config/messages.ts index 8b5fdc13..c931cd8b 100644 --- a/src/struct/config/messages.ts +++ b/src/struct/config/messages.ts @@ -77,9 +77,11 @@ module.exports = { helpTitle: "help", 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", joinSupport: "Join the musix support server: ", + keySet: emojis.green_check_mark + "Key set!", loadingSongs: emojis.loading + "Loading song(s)", looping: emojis.repeat + "Looping the queue now!", loopingSong: emojis.repeatSong + "Looping **%TITLE%** now!", @@ -120,6 +122,9 @@ module.exports = { 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 + + "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!", notPremium: emojis.redx + "This is not a premium guild!", @@ -150,7 +155,7 @@ module.exports = { prefixHere: "My prefix here is: ", prefixMaxLength: "The prefix must be shorter or equal to 5 letters!", prefixSet: emojis.green_check_mark + "New prefix set to:", - premiumUsage: "`settings premium `", + premiumState: "Premium status: ", provideANumber: "Please provide a number ranging from 1-10 to select one of the search results.", provideASong: @@ -175,6 +180,8 @@ module.exports = { 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!", settingsAnnounceSongs: "announcesongs", settingsAnnounceSongsDesc: "Whether to announce songs that start playing or not.", @@ -192,6 +199,8 @@ module.exports = { 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!", + settingsSetKey: "setkey", + settingsSetKeyDesc: "Get instructions on how to set a spotify key.", settingsTitle: "Guild settings for Musix", settingsVolume: "volume", settingsVolumeDesc: