From af44f182f6543e00b02571515e75775c033a8324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 8 Mar 2020 11:47:11 +0200 Subject: [PATCH 1/4] Removing error messages are going to debug channel --- events/ready.js | 2 -- package.json | 17 ++++++++++++----- struct/funcs/exe.js | 5 ----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/events/ready.js b/events/ready.js index e6d7a29..f81b65d 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,8 +1,6 @@ module.exports = { name: 'ready', async execute(client, Discord) { - const debugChannel = await client.channels.fetch(client.config.debug_channel); - client.debug_channel = debugChannel if (client.config.devMode) { console.log('dev mode'); } diff --git a/package.json b/package.json index f375dac..3f14594 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,25 @@ { "name": "radiox", "version": "1.0.0", - "description": "", + "description": "Finnish Radio Discord Music Bot", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "node ." + }, + "repository": { + "type": "git", + "url": "git+https://github.com/warengroup/eximiabots-radiox.git" + }, + "author": "EximiaBots", + "license": "MIT", + "bugs": { + "url": "https://github.com/warengroup/eximiabots-radiox/issues" }, - "author": "", - "license": "ISC", "dependencies": { + "@discordjs/opus": "^0.1.0", "discord.js": "^12.0.1", "dotenv": "^8.2.0", "fs": "0.0.1-security", - "node-opus": "^0.3.3", "path": "^0.12.7" } } diff --git a/struct/funcs/exe.js b/struct/funcs/exe.js index 51a688a..562b741 100644 --- a/struct/funcs/exe.js +++ b/struct/funcs/exe.js @@ -6,11 +6,6 @@ module.exports = function (msg, args, client, Discord, prefix, command) { command.execute(msg, args, client, Discord, prefix, command); } catch (error) { msg.reply(`<:redx:674263474704220182> there was an error trying to execute that command! Please contact support with \`${prefix}bug\`!`); - const embed = new Discord.MessageEmbed() - .setTitle(`Musix ${error.toString()}`) - .setDescription(error.stack.replace(/at /g, '**at **')) - .setColor('#b50002'); - client.debug_channel.send(embed); console.error(error); } }; From 60cf8df203675d3109c1d5e040045594d590a036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 8 Mar 2020 16:22:00 +0200 Subject: [PATCH 2/4] Some changes --- README.md | 1 + commands/bug.js | 17 ++++++++++++++--- commands/help.js | 5 ++--- commands/invite.js | 1 - commands/nowplaying.js | 3 +-- commands/play.js | 1 - commands/stop.js | 1 - commands/volume.js | 1 - config.js | 23 +++++++++++++++++++++++ events/msg.js | 5 +---- events/ready.js | 9 ++++----- package.json | 2 +- struct/client.js | 2 +- struct/config/config.js | 22 ---------------------- struct/funcs/msToTime.js | 17 +++++++++++++++++ struct/funcs/play.js | 1 - 16 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 config.js delete mode 100644 struct/config/config.js create mode 100644 struct/funcs/msToTime.js diff --git a/README.md b/README.md index b6c48f1..008d12f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # RadioX by EximiaBots +We will bring you finnish radio to your discord server. Join our Discord Server https://discord.gg/rRA65Mn diff --git a/commands/bug.js b/commands/bug.js index e42204d..62a2969 100644 --- a/commands/bug.js +++ b/commands/bug.js @@ -3,14 +3,25 @@ module.exports = { alias: 'none', usage: '', description: 'Report a bug', - onlyDev: false, permission: 'none', category: 'info', async execute(msg, args, client, Discord, prefix) { + + let developers = ""; + let user = ""; + for(i = 0; i < client.config.devId.length; i++){ + user = await client.users.fetch(client.config.devId[i]); + if(i == client.config.devId.length-1){ + developers += user.tag; + } else { + developers += user.tag + " & "; + } + } + const embed = new Discord.MessageEmbed() .setTitle(`Found a bug with ${client.user.username}?\nDM the core developer:`) - .setDescription(`Matte#0002\nOr join the support server: ${client.config.supportGuild}`) + .setDescription(`${developers}\nOr join the support server: ${client.config.supportGuild}`) .setColor(client.config.embedColor); msg.channel.send(embed); }, -}; +}; \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 93a2d86..786221a 100644 --- a/commands/help.js +++ b/commands/help.js @@ -3,12 +3,11 @@ module.exports = { alias: 'h', usage: '', description: 'See the help for RadioX.', - onlyDev: false, permission: 'none', category: 'info', execute(msg, args, client, Discord, prefix, command) { if (args[1]) { - if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true && msg.guild.id !== '489083836240494593')) return msg.channel.send('That command does not exist'); + if (!client.commands.has(args[1]) || (client.commands.has(args[1]) && client.commands.get(args[1]).omitFromHelp === true)) return msg.channel.send('That command does not exist'); const command = client.commands.get(args[1]); const embed = new Discord.MessageEmbed() .setTitle(`${client.global.db.guilds[msg.guild.id].prefix}${command.name} ${command.usage}`) @@ -23,7 +22,7 @@ module.exports = { } let commands = ''; for (let i = 0; i < categories.length; i++) { - commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp && !x.onlyDev).map(x => `\`${x.name}\``).join(', ')}\n`; + commands += `**» ${categories[i].toUpperCase()}**\n${client.commands.filter(x => x.category === categories[i] && !x.omitFromHelp).map(x => `\`${x.name}\``).join(', ')}\n`; } const embed = new Discord.MessageEmbed() .setTitle(`${client.user.username} help:`) diff --git a/commands/invite.js b/commands/invite.js index 52e9c7f..5288b64 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -3,7 +3,6 @@ module.exports = { alias: 'i', usage: '', description: 'Invite RadioX.', - onlyDev: false, permission: 'none', category: 'info', execute(msg, args, client, Discord, prefix) { diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 3732737..44112b2 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -3,7 +3,6 @@ module.exports = { alias: 'np', usage: '', description: 'See the currently playing song position and length.', - onlyDev: false, permission: 'none', category: 'music', async execute(msg, args, client, Discord, prefix) { @@ -15,7 +14,7 @@ module.exports = { const embed = new Discord.MessageEmbed() .setTitle("__Now playing__") .setDescription(`**Now playing:** ${radio.url}\n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``) - .setThumbnail(thumbnail._rejectionHandler0) + /*.setThumbnail(thumbnail._rejectionHandler0)*/ .setColor(client.config.embedColor) return msg.channel.send(embed); } diff --git a/commands/play.js b/commands/play.js index 057f39d..66bdaf0 100644 --- a/commands/play.js +++ b/commands/play.js @@ -3,7 +3,6 @@ module.exports = { alias: 'p', usage: '', description: 'Play some music.', - onlyDev: false, permission: 'none', category: 'music', async execute(msg, args, client, Discord, prefix) { diff --git a/commands/stop.js b/commands/stop.js index c664683..563e1db 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -3,7 +3,6 @@ module.exports = { description: 'Stop command.', alias: 'none', usage: '', - onlyDev: false, permission: 'MANAGE_CHANNELS', category: 'music', execute(msg, args, client, Discord, prefix, command) { diff --git a/commands/volume.js b/commands/volume.js index 32255eb..a94f073 100644 --- a/commands/volume.js +++ b/commands/volume.js @@ -3,7 +3,6 @@ module.exports = { description: 'Volume command.', alias: 'none', usage: '', - onlyDev: false, permission: 'MANAGE_MESSAGES', category: 'music', execute(msg, args, client, Discord, prefix, command) { diff --git a/config.js b/config.js new file mode 100644 index 0000000..e6561bd --- /dev/null +++ b/config.js @@ -0,0 +1,23 @@ +require('dotenv/config'); + +module.exports = { + + //credentials + token: "Njg0MTA5NTM1MzEyNjA5NDA5.XmOUxg.u2XChDQMZtokzueQRqGWc-CAvWE", + + //support + supportGuild: "https://discord.gg/rRA65Mn", + devId: [ + "493174343484833802", + "360363051792203779" + ], + + //misc + embedColor: "#88aa00", + invite: "https://discordapp.com/api/oauth2/authorize?client_id=684109535312609409&permissions=3427328&scope=bot", + + //Settings + prefix: "rx>", + volume: 5 + +} \ No newline at end of file diff --git a/events/msg.js b/events/msg.js index 1240650..906f7f4 100644 --- a/events/msg.js +++ b/events/msg.js @@ -2,8 +2,7 @@ module.exports = { name: 'message', async execute(client, msg, Discord) { if (msg.author.bot || !msg.guild) return; - let prefix = client.config.prefix - if (client.config.devMode) prefix = client.config.devPrefix; + let prefix = client.config.prefix; const args = msg.content.slice(prefix.length).split(' '); if (msg.mentions.users.first()) { if (msg.mentions.users.first().id === client.user.id) { @@ -20,8 +19,6 @@ module.exports = { const commandName = args[0].toLowerCase(); 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 msg.channel.send('<:redx:674263474704220182> You are not allowed to do that!'); - if (client.config.devMode && msg.member.id !== client.config.devId) return msg.channel.send('<:redx:674263474704220182> Dev mode has been turned on! Commands are only available to developer(s)!'); client.funcs.exe(msg, args, client, Discord, prefix, command); } } diff --git a/events/ready.js b/events/ready.js index f81b65d..707ca8b 100644 --- a/events/ready.js +++ b/events/ready.js @@ -1,9 +1,8 @@ module.exports = { name: 'ready', async execute(client, Discord) { - if (client.config.devMode) { - console.log('dev mode'); - } - console.log('- Activated -'); + console.log('RadioX'); + console.log('We will bring you finnish radio to your discord server'); + console.log('(c)2020 EximiaBots by Warén Media / Christer Warén & MatteZ02'); } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 3f14594..d480c6e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "radiox", "version": "1.0.0", - "description": "Finnish Radio Discord Music Bot", + "description": "We will bring you finnish radio to your discord server", "main": "index.js", "scripts": { "start": "node ." diff --git a/struct/client.js b/struct/client.js index cd8eb45..475702f 100644 --- a/struct/client.js +++ b/struct/client.js @@ -15,7 +15,7 @@ module.exports = class extends Client { this.radio = new Map(); this.funcs = {}; this.dispatcher = {}; - this.config = require('./config/config.js'); + this.config = require('../config.js'); fs.readdirSync(path.join(__dirname, 'funcs')).forEach(filename => { this.funcs[filename.slice(0, -3)] = require(`./funcs/${filename}`); diff --git a/struct/config/config.js b/struct/config/config.js deleted file mode 100644 index e90fb11..0000000 --- a/struct/config/config.js +++ /dev/null @@ -1,22 +0,0 @@ -require('dotenv/config'); - -module.exports = { - //credentials - token: process.env.TOKEN, - devToken: process.env.DEVTOKEN, - //support guild - supportGuild: "https://discord.gg/rRA65Mn", - //channels - debug_channel: "634718645188034560", - primary_test_channel: "617633098296721409", - secondary_test_channel: "570531724002328577", - devId: "360363051792203779", - //misc - embedColor: "", - invite: "https://discordapp.com/api/oauth2/authorize?client_id=684109535312609409&permissions=3427328&scope=bot", - //Settings - devMode: false, - prefix: "rx>", - devPrefix: "-", - volume: 5, -} diff --git a/struct/funcs/msToTime.js b/struct/funcs/msToTime.js new file mode 100644 index 0000000..14f3fdd --- /dev/null +++ b/struct/funcs/msToTime.js @@ -0,0 +1,17 @@ +module.exports = function msToTime(duration, format) { + var seconds = Math.floor((duration / 1000) % 60), + minutes = Math.floor((duration / (1000 * 60)) % 60), + hours = Math.floor((duration / (1000 * 60 * 60)) % 24); + days = Math.floor((duration / (1000 * 60 * 60 * 24)) % 24); + + days = (days < 10) ? "0" + days : days; + hours = (hours < 10) ? "0" + hours : hours; + minutes = (minutes < 10) ? "0" + minutes : minutes; + seconds = (seconds < 10) ? "0" + seconds : seconds; + + if (format === "hh:mm:ss") { + return `${hours}:${minutes}:${seconds}`; + } else if (format === "dd:hh:mm:ss") { + return `${days}:${hours}:${minutes}:${seconds}`; + } +} \ No newline at end of file diff --git a/struct/funcs/play.js b/struct/funcs/play.js index 4195649..518f2aa 100644 --- a/struct/funcs/play.js +++ b/struct/funcs/play.js @@ -13,7 +13,6 @@ module.exports = async function (guild, client, url) { }); dispatcher.on('error', error => { console.error(error); - client.channels.fetch(client.config.debug_channel).send('Error with the dispatcher: ' + error); radio.voiceChannel.leave(); client.radio.delete(guild.id); return radio.textChannel.send('<:redx:674263474704220182> An error has occured while playing radio!'); From f8691b18928261fb361a5d464af3cc95afd68a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 8 Mar 2020 16:54:57 +0200 Subject: [PATCH 3/4] Some changes --- commands/stop.js | 10 ++++------ struct/funcs/play.js | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/commands/stop.js b/commands/stop.js index 563e1db..da2c970 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -3,13 +3,11 @@ module.exports = { description: 'Stop command.', alias: 'none', usage: '', - permission: 'MANAGE_CHANNELS', + permission: 'none', category: 'music', execute(msg, args, client, Discord, prefix, command) { const radio = client.radio.get(msg.guild.id); - if (client.funcs.check(client, msg, command)) { - radio.connection.dispatcher.end(); - msg.channel.send('<:stop:674685626108477519> Stopped the music!') - } + radio.connection.dispatcher.end(); + msg.channel.send('<:stop:674685626108477519> Stopped the music!'); } -}; +}; \ No newline at end of file diff --git a/struct/funcs/play.js b/struct/funcs/play.js index 518f2aa..e7ba917 100644 --- a/struct/funcs/play.js +++ b/struct/funcs/play.js @@ -5,7 +5,7 @@ module.exports = async function (guild, client, url) { .play(url, { bitrate: 1024, passes: 10, volume: 1, highWaterMark: 1 << 25 }) .on("finish", () => { radio.voiceChannel.leave(); - radio.delete(); + client.radio.delete(guild.id); return; }); dispatcher.on('start', () => { From f4cc50762138e97712e2af71c4ed11abc261500c Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Sun, 8 Mar 2020 17:03:39 +0200 Subject: [PATCH 4/4] updastye --- commands/nowplaying.js | 3 +-- commands/play.js | 3 ++- commands/stop.js | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/commands/nowplaying.js b/commands/nowplaying.js index 44112b2..9339a85 100644 --- a/commands/nowplaying.js +++ b/commands/nowplaying.js @@ -10,11 +10,10 @@ module.exports = { if (!radio) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.'); if (!radio.playing) return msg.channel.send('<:redx:674263474704220182> There is nothing playing.'); radio.time = radio.connection.dispatcher.streamTime; - let completed = (radio.time.toFixed(0)); + const completed = (radio.time.toFixed(0)); const embed = new Discord.MessageEmbed() .setTitle("__Now playing__") .setDescription(`**Now playing:** ${radio.url}\n\`${client.funcs.msToTime(completed, "hh:mm:ss")}\``) - /*.setThumbnail(thumbnail._rejectionHandler0)*/ .setColor(client.config.embedColor) return msg.channel.send(embed); } diff --git a/commands/play.js b/commands/play.js index 66bdaf0..4b91928 100644 --- a/commands/play.js +++ b/commands/play.js @@ -24,7 +24,8 @@ module.exports = { } if (radio) { - radio.connection.dispatcher.end(); + radio.connection.dispatcher.destroy(); + client.funcs.play(msg.guild, client, url); } const construct = { diff --git a/commands/stop.js b/commands/stop.js index da2c970..f2d3dd6 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -7,7 +7,9 @@ module.exports = { category: 'music', execute(msg, args, client, Discord, prefix, command) { const radio = client.radio.get(msg.guild.id); - radio.connection.dispatcher.end(); + radio.connection.dispatcher.destroy(); + radio.voiceChannel.leave(); + client.radio.delete(guild.id); msg.channel.send('<:stop:674685626108477519> Stopped the music!'); } }; \ No newline at end of file