Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //n3k4a is two xd
- const fs = require ('fs');
- const PChannels = require('./PChannels.json')
- function savePChannels () {
- fs.writeFileSync ('./PChannels.json', JSON.stringify (PChannels), (err) => {
- if (err) throw err;
- });
- };
- client.on ('message', Message => {
- if ((!Message.guild) || (Message.author.bot)) return null;
- if (Message.content.startsWith (prefix + 'myroom')) {
- var Category = Message.guild.channels.cache.find (Channel => (Channel.name.toLowerCase() == 'private channels') && (Channel.type == 'category'));
- if (!Category) return Message.channel.send('**Please create a category with name: `Private Channels`**');
- if ((PChannels[Message.author.id+Message.guild.id]) && (Message.guild.channels.cache.get (PChannels[Message.author.id+Message.guild.id].channel.id))) return Message.channel.send('**You have already created a channel.**');
- else {
- Message.guild.roles.create ({
- data: {
- name: `pr-${Message.author.username}`
- }
- }).then (async (Role) => {
- Message.guild.channels.create (`${Message.author.username}`, {
- type: 'text',
- parent: Category,
- reason: 'Private Channel By: '+Message.author.username,
- permissionOverwrites: [
- {
- id: Message.author.id,
- allow: ['MANAGE_CHANNELS', 'VIEW_CHANNEL', 'SEND_MESSAGES', 'SEND_TTS_MESSAGES', 'MANAGE_MESSAGES']
- },
- {
- id: Message.guild.id,
- deny: ['VIEW_CHANNEL']
- }
- ]
- }).then (async (Channel) => {
- Message.member.roles.add (Role);
- PChannels [Message.author.id+Message.guild.id] = {
- "channel": {
- "id": Channel.id
- },
- "Category": {
- "id": Category.id
- },
- "User": {
- "id": Message.author.id
- },
- "Role": {
- "id": Role.id
- }
- };
- savePChannels ();
- Message.reply ('**Successfully created your channel.**');
- });
- });
- }
- } else if (Message.content.startsWith (prefix + 'psettings')) {
- if (!PChannels[Message.author.id+Message.guild.id]) return Message.channel.send('**You have to setup your channel first.**');
- var Channel = Message.guild.channels.cache.get (PChannels[Message.author.id+Message.guild.id].channel.id);
- var args = Message.content.split (' ');
- if (!Channel) {
- delete PChannels[Message.author.id+Message.guild.id];
- savePChannels();
- Message.channel.send('**Your channel is deleted, please setup a new channel.**');
- } else {
- if (!args [1]) return Message.channel.send (`**Example: ${args [0]} \`add/remove/deleteChannel\`**`)
- if (!['add', 'remove', 'deletechannel'].includes (args [1].toLowerCase())) return Message.channel.send ('** :poop: كل**');
- if (args [1].toLowerCase () == "add") {
- var user = Message.mentions.members.first() || Message.guild.members.cache.get (args [2]);
- if (!user) return Message.channel.send('**I can\'t find this member.**');
- Channel.createOverwrite (user.id, {
- SEND_MESSAGES: true,
- READ_MESSAGE_HISTORY: true,
- VIEW_CHANNEL: true
- }, `Added to the channel by: ${Message.author.tag}`);
- Message.channel.send('**Successfully.**');
- } else if (args[1].toLowerCase () == "remove") {
- var user = Message.mentions.members.first() || Message.guild.members.cache.get (args [2]);
- if (!user) return Message.channel.send('**I can\'t find this member.**');
- Channel.updateOverwrite (user.id, {
- VIEW_CHANNEL: false,
- READ_MESSAGE_HISTORY: false,
- SEND_MESSAGES: false
- }, `Removed from the channel by: ${Message.author.tag}`);
- Message.channel.send('**Successfully.**');
- } else if (args [1].toLowerCase () == "deletechannel") {
- Channel.delete ();
- var role = Message.guild.roles.cache.get (PChannels[Message.author.id+Message.guild.id].Role.id);
- if(role) role.delete();
- delete PChannels[Message.author.id+Message.guild.id];
- savePChannels();
- Message.channel.send('**Done**');
- }
- }
- }
- });
- //By 3Mo_Steve ,_,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement