Publish the correct version 🤦

Apparently editing the project on different computers caused versioning
derps and restored an old version. So that's why weird stuff has been
happening lately.
This commit is contained in:
ledlamp 2018-05-11 23:02:32 -07:00
parent e46058b8c1
commit 192112d562
9 changed files with 131 additions and 20 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
/local/
/src/config.json
/src/config.json
node_modules/

79
src/colorroles.js Normal file → Executable file
View File

@ -1,37 +1,90 @@
global.colorRoles = {
create: async function (member){
var role = await member.guild.createRole({data:{
global.colorRoles = { // TODO clean up this, adsfhaiusdhgaisuhg
create: async function (guild){ // create new color role
var role = await guild.roles.create({data:{
name:"[]",
permissions:[],
color:"RANDOM",
//position: member.guild.roles.get('346754988023873546').position
}});
member.addRole(role);
return role;
},
get: function (member){
get: function (member){ // get color role of member
return member.roles.find(role => {if (role.name.startsWith('[')) return role});
},
ensure: function (member) { // give color role to member if they don't have one; not sure what to call this
ensure: async function (member) { // restore or create role for member if they don't have one
if (this.get(member)) return;
this.create(member);
if (await this.restore(member)) return;
var role = await this.create(member.guild);
await member.roles.add(role);
},
pack: async function (member) { // store member color role in database and delete
var role = this.get(member);
if (!role) return;
var json = {
id: role.id,
name: role.name,
color: role.color,
hoist: role.hoist,
position: role.position,
permissions: role.permissions.bitfield,
mentionable: role.mentionable
}
var id = member.id;
var res = await dbClient.query(`SELECT * FROM member_data WHERE id = $1`, [id]);
if (res.rows[0]) {
await dbClient.query(`UPDATE member_data SET color_role = $2 WHERE id = $1`, [id, json]);
} else {
await dbClient.query(`INSERT INTO member_data (id, color_role) VALUES ($1, $2)`, [id, json]);
} // need better sql, oof
role.delete();
},
restore: async function (member) { // load color role from database and reapply to member
var json = (await dbClient.query(`SELECT (color_role) FROM member_data WHERE id = $1`, [member.id])).rows[0];
if (!json) return false;
else json = json.color_role;
var role = member.guild.roles.get(json.id);
if (!role) role = await member.guild.roles.create({data:{
name: json.name,
color: json.color,
hoist: json.hoist,
//position: json.position,
permissions: json.permissions,
mentionable: json.mentionable
}});
member.roles.add(role);
return true;
},
}
dClient.on('presenceUpdate', (oldMember, newMember) => {
if (newMember.guild.id != config.guildID) return;
if (oldMember.presence.status != newMember.presence.status && newMember.presence.status != "offline") {
colorRoles.ensure(newMember);
if (oldMember.presence.status != newMember.presence.status) {
if (newMember.presence.status == "offline") {
colorRoles.pack(newMember);
} else {
colorRoles.ensure(newMember);
}
}
});
//dClient.on('guildMemberAdd', member => colorRoles.ensure(member));
dClient.on('guildMemberRemove', member => {
if (member.guild.id != config.guildID) return;
var role = colorRoles.get(member);
if (role.members.array().length == 0) role.delete();
colorRoles.pack(member);
});
commands.color = {

3
src/commands.js Normal file → Executable file
View File

@ -41,7 +41,7 @@ global.commands = {
if (!msg.args[0]) return false;
//var name = msg.txt(1).replace(/[^a-zA-Z0-9]/g, '-').substr(0,100).toLowerCase();
var name = msg.txt(1);
msg.guild.createChannel(name, {
msg.guild.channels.create(name, {
parent: '399735134061985792',
overwrites: [
{
@ -66,6 +66,7 @@ global.commands = {
'delete': {
usage: "[channel]",
aliases: ['archive'],
hidden: true,
description: "Archives a channel that you have permission to delete.",
exec: async function (msg) {
if (msg.args[1]) {

0
src/lib/jsmidgen.js Normal file → Executable file
View File

0
src/lib/mpprecorder-module.js Normal file → Executable file
View File

4
src/misc.js Normal file → Executable file
View File

@ -19,10 +19,10 @@
dClient.on('voiceStateUpdate', (oldMember, newMember) => {
if (oldMember.voiceChannelID != vcid && newMember.voiceChannelID == vcid) {
// member joined the channel
newMember.addRole(newMember.guild.roles.get(rid));
newMember.roles.add(newMember.guild.roles.get(rid));
} else if (oldMember.voiceChannelID == vcid && newMember.voiceChannelID != vcid) {
// member left the channel
newMember.removeRole(newMember.guild.roles.get(rid));
newMember.roles.remove(newMember.guild.roles.get(rid));
}
});
})();

6
src/mppbridger.js Normal file → Executable file
View File

@ -65,7 +65,7 @@ global.createMPPbridge = function (room, DiscordChannelID, site = 'MPP', webhook
msgBuffer = [];
}, 2000); //TODO make changeable
const gClient = site == "MPP" ? new Client("ws://www.multiplayerpiano.com:443") : site == "WOPP" ? new Client("ws://ourworldofpixels.com:1234", true) : site == "MPT" ? new Client("ws://23.95.115.204:8080", true) : site == "VFDP" ? new Client("ws://www.visualfiredev.com:8080") : undefined;
const gClient = site == "MPP" ? new Client("ws://www.multiplayerpiano.com:443") : site == "WOPP" ? new Client("ws://ourworldofpixels.com:1234", true) : site == "MPT" ? new Client("ws://ts.terrium.net:8080", true) : site == "VFDP" ? new Client("ws://www.visualfiredev.com:8080") : undefined;
if (!gClient) return console.error(`Invalid site ${site}`);
gClient.setChannel(/*(site == "MPP" && room == "lobby") ? "lolwutsecretlobbybackdoor" : */room);
gClient.canConnect = true;
@ -376,7 +376,7 @@ commands.bridge = {
else if ((existingBridge && existingBridge.disabled) || config.disabledRooms.includes(room)) return msg.reply(`You cannot bridge this room.`);
var discordChannelName = room.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
var categoryID = '360557444952227851';
var channel = await dClient.guilds.get(config.guildID).createChannel(discordChannelName, {parent: categoryID});
var channel = await dClient.guilds.get(config.guildID).channels.create(discordChannelName, {parent: categoryID});
channel.setTopic(`Bridged to http://www.multiplayerpiano.com/${encodeURIComponent(room)}`);
var webhook = await channel.createWebhook('Webhook');
createMPPbridge(room, channel.id, site, webhook.id, webhook.token);
@ -465,7 +465,7 @@ commands.list = {
var names = [];
for (let person in ppl) {
person = ppl[person];
names.push(`\`${person._id.substr(0,4)}\` ${person.name}`);
names.push(`\`${person._id.substr(0,6)}\` ${person.name}`);
}
str += names.join(', ');
message.channel.send(str, {split:{char:''}});

55
src/package-lock.json generated Executable file
View File

@ -0,0 +1,55 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"discord.js": {
"version": "github:hydrabolt/discord.js#b186472785db6bbe7de37e1a75104d79dd0cc44f",
"requires": {
"pako": "1.0.6",
"prism-media": "0.2.1",
"snekfetch": "3.6.4",
"tweetnacl": "1.0.0",
"ws": "4.1.0"
}
},
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg=="
},
"prism-media": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.2.1.tgz",
"integrity": "sha512-Kfp1+6gzjY6X8mqKHa6D3brX+BtMUPFwzAkz4zgtVPgbkA2XxhITROdfQXVurU4fuJsylFRwqo7ciQlQCm9hAw=="
},
"safe-buffer": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
},
"snekfetch": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz",
"integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw=="
},
"tweetnacl": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz",
"integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins="
},
"ws": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
"integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
"requires": {
"async-limiter": "1.0.0",
"safe-buffer": "5.1.1"
}
}
}
}

1
src/screenshotter.js Normal file → Executable file
View File

@ -6,6 +6,7 @@ global.screenshotter = {
var page = await browser.newPage();
await page.setViewport({width: 1440, height: 900});
await page.goto('http://www.multiplayerpiano.com/lobby');
await page.evaluate(function(){ setTimeout(()=>{ document.getElementById('modal').click() }, 1000) });
await new Promise(resolve => setTimeout(resolve, 5000));
var screenshot = await page.screenshot({type: 'png'});
var filename = `Screenshot of www.multiplayerpiano.com/lobby @ ${new Date().toISOString()}.png`;