Compare commits

..

No commits in common. "1188883f2028846a2d6d6535a108b8b654b528c4" and "513a9f76aacc044ca9a8efdfb8cf6964ea65573f" have entirely different histories.

2 changed files with 0 additions and 67 deletions

View File

@ -1,67 +0,0 @@
var client = require("./client");
var config = require("./config");
var app = require("./www");
var fs = require("fs");
var {EventEmitter} = require("events");
let p = u => `${config.data_dir}/magic-channels/${u}`
module.exports = class MagicChannel extends EventEmitter{
constructor(guild, user, channelName) {
super();
this.guild = client.guilds.resolve(guild);
this.user = client.users.resolve(user);
app.get(`/${this.user.id}`, (req, res) => {
res.sendFile(process.cwd() + "/track-image.png");
if (req.headers["user-agent"].includes("Discordbot")) return;
this.emit("trigger");
});
if (fs.existsSync(p(this.user.id))) {
let channel_id = fs.readFileSync(p(this.user.id));
this.channel = client.channels.resolve(channel_id);
}
if (!this.channel) {
this.guild.channels.create(channelName || this.user.username, {
permissionOverwrites: [
{
id: this.guild.roles.everyone,
deny: "VIEW_CHANNEL"
},
{
id: this.user,
allow: "VIEW_CHANNEL"
}
]
}).then(channel => {
this.channel = channel;
fs.writeFileSync(p(this.user.id), channel.id);
channel.send(`https://${config.web_hostname}/${this.user.id}`);
});
}
this.once("trigger", () => this.hide());
}
show() {
return this.channel.permissionOverwrites.edit(this.user, {
VIEW_CHANNEL: true
});
}
hide() {
return this.channel.permissionOverwrites.edit(this.user, {
VIEW_CHANNEL: false
});
}
reset() {
this.show()
this.once("trigger", () => this.hide());
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB