From 5645fb9f797f17ca01e9e31b68a7baf90b71cc5a Mon Sep 17 00:00:00 2001 From: Lamp Date: Fri, 13 Jul 2018 17:04:39 -0700 Subject: [PATCH] move ids to config --- .gitignore | 1 + src/colorroles.js | 1 - src/commands.js | 4 ++-- src/config.js | 26 ++++++++++++++++++++------ src/main.js | 4 ++-- src/misc.js | 4 ++-- src/mppbridger/commands/bridge.js | 4 ++-- src/mppbridger/commands/unbridge.js | 2 +- src/mppbridger/namecollector.js | 4 ++-- src/screenshotter.js | 4 ++-- 10 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 897c76b..098d12e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /local/ node_modules/ .DS_Store +test.sh diff --git a/src/colorroles.js b/src/colorroles.js index aba55b1..2574da8 100755 --- a/src/colorroles.js +++ b/src/colorroles.js @@ -7,7 +7,6 @@ global.colorRoles = { // TODO clean up this, adsfhaiusdhgaisuhg name:"[]", permissions:[], color:"RANDOM", - //position: member.guild.roles.get('346754988023873546').position }}); return role; }, diff --git a/src/commands.js b/src/commands.js index ddb7a9e..129c4fa 100755 --- a/src/commands.js +++ b/src/commands.js @@ -42,7 +42,7 @@ global.commands = { //var name = msg.txt(1).replace(/[^a-zA-Z0-9]/g, '-').substr(0,100).toLowerCase(); var name = msg.txt(1); msg.guild.channels.create(name, { - parent: '399735134061985792', + parent: config.channels.user_channels, overwrites: [ { id: msg, @@ -79,7 +79,7 @@ global.commands = { var channel = msg.channel; } if (!channel.permissionsFor(msg.member).has('MANAGE_CHANNELS')) return msg.react('🚫'); - await channel.setParent('425054198699261953'); + await channel.setParent(config.channels.deleted_channels); await channel.lockPermissions(); msg.react('🆗'); } diff --git a/src/config.js b/src/config.js index 007ab6f..31481f7 100644 --- a/src/config.js +++ b/src/config.js @@ -1,18 +1,32 @@ module.exports = { "testmode": new Boolean(process.env.TEST), + + "DISCORD_TOKEN": process.env.DISCORD_TOKEN, + "DATABASE_URL": this.testmode ? "postgres://localhost/k4t" : process.env.DATABASE_URL, + "MONGODB_URI": this.testmode ? "mongodb://localhost/k4t" : process.env.MONGODB_URI, - "token": process.env.DISCORD_TOKEN, - "webhooks": { - "console": process.env.WEBHOOK_CONSOLE.split("/"), "welcome": process.env.WEBHOOK_WELCOME.split("/"), }, "opID": "281134216115257344", - "guildID": this.testmode ? "" : "321819041348190249", - "channels": { - "main": this.testmode ? "" : "321819041348190249" + "guildID": this.testmode ? "467473467634089985" : "321819041348190249", + + "channels": { // includes voice channels & category channels + "main": this.testmode ? "467473467634089987" : "321819041348190249", + "voice": this.testmode ? "467473467634089989" : "425060452129701889", + "name_collection": this.testmode ? "" : '379738469511069698', + "mpp_bridges": this.testmode ? "" : '360557444952227851', + "user_channels": this.testmode ? "" : '399735134061985792', + "deleted_channels": this.testmode ? "" : '425054198699261953', + "deleted_bridges": this.testmode ? "" : '451838300068511745', + "mpp_screenshot": this.testmode ? "" : '383773548810076163', + "owop_screenshot": this.testmode ? "" : '399079481161023492' + }, + + "roles": { + "viewing_deleted_channels": this.testmode ? "467473718353068042" : "425060792455397376", }, diff --git a/src/main.js b/src/main.js index 09001ea..7f50755 100755 --- a/src/main.js +++ b/src/main.js @@ -14,9 +14,9 @@ process.on('uncaughtException', error => { }); -(require('mongodb').MongoClient).connect(process.env.MONGODB_URI).then(client=>{ +(require('mongodb').MongoClient).connect(config.MONGODB_URI).then(client=>{ global.mdbClient = client; - dClient.login(config.token); + dClient.login(config.DISCORD_TOKEN); }); dClient.once('ready', () => { diff --git a/src/misc.js b/src/misc.js index f8c784e..747c1d2 100755 --- a/src/misc.js +++ b/src/misc.js @@ -14,8 +14,8 @@ // view deleted channels (async function(){ - var vcid = '425060452129701889'; - var rid = '425060792455397376'; + var vcid = config.channels.voice; + var rid = config.roles.viewing_deleted_channels; dClient.on('voiceStateUpdate', async (oldMember, newMember) => { if (oldMember.voiceChannelID != vcid && newMember.voiceChannelID == vcid) { // member joined the channel diff --git a/src/mppbridger/commands/bridge.js b/src/mppbridger/commands/bridge.js index 345bef9..d3678ec 100644 --- a/src/mppbridger/commands/bridge.js +++ b/src/mppbridger/commands/bridge.js @@ -15,7 +15,7 @@ module.exports = { } else /* rebridge */ { let channel = dClient.guilds.get(config.guildID).channels.get(existingBridge.discord_channel_id); await dbClient.query("UPDATE bridges SET disabled = false WHERE mpp_room = $1", [room]); - await channel.setParent('360557444952227851'); + await channel.setParent(); await channel.lockPermissions(); createMPPbridge(room, existingBridge.mpp_room, existingBridge.site, existingBridge.webhook_id, existingBridge.webhook_token); await msg.reply(`${site} room ${room} has been re-bridged.`); @@ -25,7 +25,7 @@ module.exports = { } /* new bridge */ var discordChannelName = room.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase(); - var categoryID = '360557444952227851'; + var categoryID = config.channels.mpp_bridges; var channel = await dClient.guilds.get(config.guildID).channels.create(discordChannelName, {parent: categoryID}); channel.setTopic(`http://www.multiplayerpiano.com/${encodeURIComponent(room)}`); var webhook = await channel.createWebhook('Webhook'); diff --git a/src/mppbridger/commands/unbridge.js b/src/mppbridger/commands/unbridge.js index 1d58203..a0fc5b0 100644 --- a/src/mppbridger/commands/unbridge.js +++ b/src/mppbridger/commands/unbridge.js @@ -20,7 +20,7 @@ module.exports = { await dbClient.query("UPDATE bridges SET disabled = 'true' WHERE mpp_room = $1", [bridge.mpp_room]); clients.MPP[bridge.mpp_room].stop(); var channel = dClient.channels.get(bridge.discord_channel_id) - await channel.setParent('451838300068511745'); + await channel.setParent(config.channels.deleted_bridges); await channel.lockPermissions(); msg.reply(`${bridge.mpp_room} has been unbridged.`); } diff --git a/src/mppbridger/namecollector.js b/src/mppbridger/namecollector.js index b8c213e..df8c13f 100644 --- a/src/mppbridger/namecollector.js +++ b/src/mppbridger/namecollector.js @@ -6,7 +6,7 @@ module.exports = { var newMsg = function(continued){ var str = `__**${participant._id}**__${continued ? ' (continued)' : ''}\n${participant.name}`; - return dClient.channels.get('379738469511069698').send(str); + return dClient.channels.get(config.channels.name_collection).send(str); } var document = await this.collection.findOne({_id: participant._id}); @@ -17,7 +17,7 @@ module.exports = { document.names.push(participant.name); this.collection.updateOne({_id: participant._id}, {$set:{names: document.names}}); - let message = await dClient.channels.get('379738469511069698').messages.fetch(document.discord_msg_id); + let message = await dClient.channels.get(config.channels.name_collection).messages.fetch(document.discord_msg_id); try { await message.edit(message.content + ', ' + participant.name); } catch(e) { diff --git a/src/screenshotter.js b/src/screenshotter.js index 0598e34..9682289 100755 --- a/src/screenshotter.js +++ b/src/screenshotter.js @@ -11,14 +11,14 @@ global.screenshotter = { var screenshot = await page.screenshot({type: 'png'}); var filename = `Screenshot of www.multiplayerpiano.com/lobby @ ${new Date().toISOString()}.png`; var attachment = new Discord.MessageAttachment(screenshot, filename); - await dClient.channels.get('383773548810076163').send(attachment); + await dClient.channels.get(config.channels.mpp_screenshot).send(attachment); await page.goto('http://ourworldofpixels.com'); await page.evaluate(function(){OWOP.camera.zoom = 1;}); await new Promise(resolve => setTimeout(resolve, 5000)); var screenshot = await page.screenshot({type: 'png'}); var filename = `Screenshot of ourworldofpixels.com/main @ ${new Date().toISOString()}.png`; var attachment = new Discord.MessageAttachment(screenshot, filename); - await dClient.channels.get('399079481161023492').send(attachment); + await dClient.channels.get(config.channels.owop_screenshot).send(attachment); await browser.close(); console.log('Finished screen captures'); },