SHARE
TWEET

Untitled

a guest Aug 18th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const config = require('../config.json');
  3. const log = require(`leekslazylogger`);
  4. module.exports = {
  5.   name: 'add',
  6.   description: 'Add a member to a ticket channel',
  7.   usage: '<@member>',
  8.   aliases: ['adduser'],
  9.   example: 'add @exampleUser',
  10.   args: true,
  11.   cooldown: config.cooldown,
  12.   guildOnly: true,
  13.   execute(message, args) {
  14.     const client = message.client;
  15.     // command starts here
  16.     message.delete();
  17.     if(!message.author.roles.has(config.supportRole)) {
  18.       const no = new Discord.RichEmbed()
  19.           .setColor("#E74C3C")
  20.           .setDescription(`:x: **This command can only be used by a support member**`)
  21.       return message.channel.send(no);
  22.     } else {
  23.     if(!message.channel.name.startsWith('ticket-')) {
  24.       if(config.useEmbeds) {
  25.         const notTicket = new Discord.RichEmbed()
  26.             .setColor("#E74C3C")
  27.             .setDescription(`:x: **This command can only be used within a ticket channel**`)
  28.         return message.channel.send(notTicket);
  29.       } else {
  30.         return message.channel.send(`:x: **This command can only be used within a ticket channel**`)
  31.       }
  32.     }
  33.  
  34.     let user = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  35.     if(!user) {
  36.       if(config.useEmbeds) {
  37.         const err1 = new Discord.RichEmbed()
  38.             .setColor("#E74C3C")
  39.             .setDescription(`:x: **Unknown user.** Please mention a valid user.`)
  40.             return message.channel.send(err1);
  41.       } else {
  42.         return message.channel.send(`:x: **Unknown user.** Please mention a valid user.`);
  43.       }
  44.     }
  45.     try {
  46.     message.channel.overwritePermissions(user, {
  47.       SEND_MESSAGES: true,
  48.       READ_MESSAGES: true,
  49.       ATTACH_FILES: true
  50.     });
  51.     if(config.useEmbeds) {
  52.       const added = new Discord.RichEmbed()
  53.           .setColor(config.colour)
  54.           .setDescription(`${user} has been added.`)
  55.           message.channel.send(added);
  56.     } else {
  57.        message.channel.send(`${user} has been added.`);
  58.     }
  59.     // log
  60.     if(config.useEmbeds) {
  61.       const embed = new Discord.RichEmbed()
  62.         .setAuthor(`${client.user.username} / Ticket Log`, client.user.avatarURL)
  63.         .setTitle("User Added")
  64.         .setColor(config.colour)
  65.         .addField("Username", user, true)
  66.         .addField("Added by", message.author, true)
  67.         .addField("Channel", message.channel, true)
  68.         .setFooter(`AuthenityIO Tickets`)
  69.         .setTimestamp();
  70.       client.channels.get(config.logChannel).send({embed})
  71.     } else {
  72.       client.channels.get(config.logChannel).send(`User added to a ticket by **${message.author.tag} (${message.author.id})**`);
  73.     }
  74.     log.info(`${message.author.tag} added a user to a ticket (#${message.channel})`)
  75.   } catch(error) {
  76.     log.error(error);
  77.   }
  78. }
  79.  
  80.     // command ends here
  81.   },
  82. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top