SHARE
TWEET

Untitled

a guest Aug 25th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require(`discord.js`);
  2.  
  3. const client = new Discord.Client();
  4.  
  5. var prefix = "*";
  6.  
  7. const ytdl = require('ytdl-core')
  8.  
  9. const queue = new Map();
  10.  
  11. var servers = {};
  12.  
  13. client.login("NTI2NjkyOTQ2MjQyNjk5Mjk3.DwI8aw.BelC434eUNwUI15Hze2woS-30cQ");
  14.  
  15. /*Music Bot*/
  16. function play(connection, message) {
  17.     var server= servers[message.guild.id];
  18.  
  19.     server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audiononly"}));
  20.  
  21.     server.queue.shift();
  22.  
  23.     server.dispatcher.on("end", function() {
  24.         if (server.queue[0]) play(connection, message);
  25.  
  26.         else connection.disconnect();
  27.  
  28.     });
  29. }
  30.  
  31.  
  32. /*AddRole + Message Join*/  
  33. client.on('guildMemberAdd', member =>{
  34.   let embed = new Discord.RichEmbed()
  35.       .setDescription(':tada: **' + member.user.username + '** Joined  ' + member.guild.name)
  36.       .setFooter('The member count is : ' + member.guild.memberCount)
  37.   member.guild.channels.get('<#443364008641429504>').send(embed)
  38.   member.addRole('<@&442289881427869708>')
  39.   member.addRole('<@&442309713804394496>')
  40.   member.addRole('<@&442309750802219028>')
  41.  
  42. });
  43.  
  44. /*Message Leave*/  
  45. client.on('guildMemberRemove', member =>{
  46.   let embed = new Discord.RichEmbed()
  47.       .setDescription(':cry: **' + member.user.username + '** leave ' + member.guild.name)
  48.       .setFooter('The member count is :  ' + member.guild.memberCount)
  49.   member.guild.channels.get('<#443364008641429504>').send(embed)
  50.  
  51. });
  52.  
  53. /*Jeux*/
  54. client.on("ready", () => {
  55.     console.log("The Horkid | Bot are ready to kill a mom")
  56.     client.user.setGame("Horkid Network | horkid.eu");
  57. });
  58.  
  59. /*Speak*/
  60. client.on(`message`, message => {
  61.  
  62.     if(message.content === "Hi"){
  63.         message.reply("Hi im the official Horkid Bot")
  64.         console.log("A player speak at the bot");
  65.     }
  66.  
  67. /*Help*/
  68.     if(message.content === prefix + "help"){
  69.         var help_embed = new Discord.RichEmbed()
  70.         .setColor("3366FF")
  71.         .setTitle("Horkid | Help")
  72.         .setDescription("The Horkid Command")
  73.         .addField("*help", "Use this to show the help Command")
  74.         .addField("*staff", "Use this to show the Staff Command")
  75.         .addField("*info", "Use this to show the Network Stats")
  76.         .setFooter("This is the Horkid Help Menu")
  77.         message.channel.sendMessage(help_embed);
  78.         console.log ("A player show the help page on the bot")
  79.     }
  80.  
  81. /*Staff-Help*/    
  82.     if(message.content === prefix + "staff"){
  83.         var help_embed = new Discord.RichEmbed()
  84.         .setColor("3366FF")
  85.         .setTitle("Horkid | Staff")
  86.         .setDescription("The Horkid Staff Command")
  87.         .addField("*ban", "Use this to ban a player")
  88.         .addField("*mute", "Use this to mute a player")
  89.         .addField("*unmute", "Use this to unmute a player")
  90.         .addField("*warn", "Use this to warn a player")
  91.         .addField("*seewarns", "Use this to see a player warns")
  92.         .addField("*deletewarns", "Use this to clear a player warns")
  93.         .setFooter("This is the Horkid Staff Help Menu")
  94.         message.channel.sendMessage(help_embed);
  95.         console.log ("A player show the help page on the bot")
  96.     }
  97.  
  98. /*Info*/
  99.     if(message.content === prefix + "info") {
  100.         var info_embed = new Discord.RichEmbed()
  101.         .setColor("3366FF")
  102.         .setTitle("Horkid | Bot Information and Network Information")
  103.         .addField(":robot: My name is:", `${client.user.tag}`, true)
  104.         .addField("My :id: is", `${client.user.id}`)
  105.         .addField("Number of players", message.guild.members.size)
  106.         .addField("Discord Link : ", "Official discord link https://discord.gg/CmQyYNh")
  107.         .addField("Network Information", "There is the Network Information")
  108.         .addField("Ip is :", "horkid.eu")
  109.         .addField("Teamspeak IP", "ts.horkid.club")
  110.         .addField("Network Status", "Whitelisted (Network in Developement)")
  111.         .setFooter("Horkid | Bot Information and Network Information")
  112.         message.channel.sendMessage(info_embed)
  113.         console.log("A user show the info on the Network and Bot")
  114.  
  115.     }
  116.  
  117. /*Kick*/    
  118.     if(message.content.startsWith(prefix + "kick")){
  119.         if(!message.guild.member(message.author).hasPermission("KICK_MEMBERS")) return message.channel.send("You don't have this Permission");
  120.  
  121.         if(message.mentions.users.size === 0) {
  122.             return message.channel.send("You have to choose the user")
  123.         }
  124.  
  125.         var kick = message.guild.member(message.mentions.users.first());
  126.         if(!kick) {
  127.             return message.channel.send("The user does not exist")
  128.         }
  129.  
  130.         if(!message.guild.member(client.user).hasPermission("KICK_MEMBERS")) {
  131.             return message.channel.send("I dont have Permission for kick");
  132.         }
  133.  
  134.         kick.kick().then(member => {
  135.             message.channel.send(`${member.user.username} has been kicked by ${message.author.username}`);
  136.         });
  137.     }
  138.  
  139. /*Ban*/    
  140.     if(message.content.startsWith(prefix + "ban")){
  141.         if(!message.guild.member(message.author).hasPermission("BAN_MEMBERS")) return message.channel.send("You don't have this Permission");
  142.  
  143.         if(message.mentions.users.size === 0) {
  144.             return message.channel.send("You have to choose the user")
  145.         }
  146.  
  147.         var kick = message.guild.member(message.mentions.users.first());
  148.         if(!kick) {
  149.             return message.channel.send("The user does not exist")
  150.         }
  151.  
  152.         if(!message.guild.member(client.user).hasPermission("BAN_MEMBERS")) {
  153.             return message.channel.send("I dont have Permission for ban");
  154.         }
  155.  
  156.         ban.ban().then(member => {
  157.             message.channel.send(`${member.user.username} has been banned by ${message.author.username}`);
  158.         });
  159.     }
  160.    
  161. /*Clear*/
  162.     if(message.content.startsWith(prefix + "clear")) {
  163.         if(!message.guild.member(message.author).hasPermission("MANAGE_MESSAGE")) return message.channel.send("You dont Permission");
  164.  
  165.         Let (args) = message.content.split(" ").slice(1);
  166.  
  167.         if(!args[0]) return message.channel.send("Specifies the number of messages to be deleted")
  168.         message.channel.bulkDelete(args[0]).then(() => {
  169.             message.channel.send(`${args[0]} has been deleted`);
  170.         })
  171.     }
  172.  
  173. /*Mute*/    
  174.     if(message.content.startsWith(prefix + "mute")) {
  175.         if(!message.guild.member(message.author).hasPermission("ADMINISTRATOR")) return message.channel.send("You dont have Permission");
  176.  
  177.         if(message.mentions.users.size === 0) {
  178.             return message.channel.send('Choose the user you want to mute');
  179.         }
  180.  
  181.         var mute = message.guild.member(message.mentions.users.first());
  182.         if(!mute) {
  183.             return message.channel.send("The user does not exist");
  184.         }
  185.  
  186.         if(!message.guild.member(client.user).hasPermission("ADMINISTRATOR")) return message.channel.send("I dont have Permission");
  187.         message.channel.overwritePermissions(mute, { SEND_MESSAGES: false}).then(member => {
  188.             message.channel.send(`${mute.user.username} has been muted`)
  189.         })
  190.     }
  191.  
  192. /*UnMute*/    
  193.     if(message.content.startsWith(prefix + "unmute")) {
  194.         if(!message.guild.member(message.author).hasPermission("ADMINISTRATOR")) return message.channel.send("You dont have Permission");
  195.  
  196.         if(message.mentions.users.size === 0) {
  197.             return message.channel.send('Choose the user you want to unmute');
  198.         }
  199.  
  200.         var unmute = message.guild.member(message.mentions.users.first());
  201.         if(!unmute) {
  202.             return message.channel.send("The user does not exist");
  203.         }
  204.  
  205.         if(!message.guild.member(client.user).hasPermission("ADMINISTRATOR")) return message.channel.send("I dont have Permission");
  206.         message.channel.overwritePermissions(mute, { SEND_MESSAGES: true}).then(member => {
  207.             message.channel.send(`${mute.user.username} has been unmuted`)
  208.         })
  209.     }
  210.  
  211.     var fs = require('fs');
  212.  
  213. /*Warn*/    
  214. let warns = JSON.parse(fs.readFileSync("./warns.json", "utf8"));
  215.  
  216. if (message.content.startsWith(prefix + "warn")){
  217.  
  218. if (message.channel.type === "dm") return;
  219.  
  220. var mentionned = message.mentions.users.first();
  221.  
  222. if(!message.guild.member(message.author).hasPermission("MANAGE_GUILD")) return message.reply("**:x: You dont have permission `Manage the server` in this server**").catch(console.error);
  223.  
  224. if(message.mentions.users.size === 0) {
  225.  
  226.   return message.channel.send("**:x: You have mention any user**");
  227.  
  228. }else{
  229.  
  230.     const args = message.content.split(' ').slice(1);
  231.  
  232.     const mentioned = message.mentions.users.first();
  233.  
  234.     if (message.member.hasPermission('MANAGE_GUILD')){
  235.  
  236.       if (message.mentions.users.size != 0) {
  237.  
  238.         if (args[0] === "<@!"+mentioned.id+">"||args[0] === "<@"+mentioned.id+">") {
  239.  
  240.           if (args.slice(1).length != 0) {
  241.  
  242.             const date = new Date().toUTCString();
  243.  
  244.             if (warns[message.guild.id] === undefined)
  245.  
  246.               warns[message.guild.id] = {};
  247.  
  248.             if (warns[message.guild.id][mentioned.id] === undefined)
  249.  
  250.               warns[message.guild.id][mentioned.id] = {};
  251.  
  252.             const warnumber = Object.keys(warns[message.guild.id][mentioned.id]).length;
  253.  
  254.             if (warns[message.guild.id][mentioned.id][warnumber] === undefined){
  255.  
  256.               warns[message.guild.id][mentioned.id]["1"] = {"raison": args.slice(1).join(' '), time: date, user: message.author.id};
  257.  
  258.             } else {
  259.  
  260.               warns[message.guild.id][mentioned.id][warnumber+1] = {"raison": args.slice(1).join(' '),
  261.  
  262.                 time: date,
  263.  
  264.                 user: message.author.id};
  265.  
  266.             }
  267.  
  268.             fs.writeFile("./warns.json", JSON.stringify(warns), (err) => {if (err) console.error(err);});
  269.  
  270. message.delete();
  271.  
  272.             message.channel.send(':warning: | **'+mentionned.tag+' has been warned**');
  273.  
  274. message.mentions.users.first().send(`:warning: **Warn |** since **${message.guild.name}** given by **${message.author.username}**\n\n**Reason:** ` + args.slice(1).join(' '))
  275.  
  276.           } else {
  277.  
  278.             message.channel.send("Error improper usage: "+prefix+"warn <user> <raison>");
  279.  
  280.           }
  281.  
  282.         } else {
  283.  
  284.           message.channel.send("Error improper usage: "+prefix+"warn <user> <raison>");
  285.  
  286.         }
  287.  
  288.       } else {
  289.  
  290.         message.channel.send("Error improper usage: "+prefix+"warn <user> <raison>");
  291.  
  292.       }
  293.  
  294.     } else {
  295.  
  296.       message.channel.send("**:x: You dont have permission `Manage the server` in this server**");
  297.  
  298.     }
  299.  
  300.   }
  301.  
  302. }
  303.  
  304.  
  305. /*SeeWarn*/  
  306.   if (message.content.startsWith(prefix+"seewarns")||message.content===prefix+"seewarns") {
  307.  
  308. if (message.channel.type === "dm") return;
  309.  
  310. if(!message.guild.member(message.author).hasPermission("MANAGE_GUILD")) return message.reply("**:x: You dont have permission `Manage the server` in this server**").catch(console.error);
  311.  
  312.     const mentioned = message.mentions.users.first();
  313.  
  314.     const args = message.content.split(' ').slice(1);
  315.  
  316.     if (message.member.hasPermission('MANAGE_GUILD')){
  317.  
  318.       if (message.mentions.users.size !== 0) {
  319.  
  320.         if (args[0] === "<@!"+mentioned.id+">"||args[0] === "<@"+mentioned.id+">") {
  321.  
  322.           try {
  323.  
  324.             if (warns[message.guild.id][mentioned.id] === undefined||Object.keys(warns[message.guild.id][mentioned.id]).length === 0) {
  325.  
  326.               message.channel.send("**"+mentioned.tag+"** have 0 Warn :eyes:");
  327.  
  328.               return;
  329.  
  330.             }
  331.  
  332.           } catch (err) {
  333.  
  334.             message.channel.send("**"+mentioned.tag+"** have 0 Warn :eyes:");
  335.  
  336.             return;
  337.  
  338.           }
  339.  
  340.           let arr = [];
  341.  
  342.           arr.push(`**${mentioned.tag}** have **`+Object.keys(warns[message.guild.id][mentioned.id]).length+"** warns :eyes:");
  343.  
  344.           for (var warn in warns[message.guild.id][mentioned.id]) {
  345.  
  346.             arr.push(`**${warn}** - **"`+warns[message.guild.id][mentioned.id][warn].raison+
  347.  
  348.             "**\" warn gived by **"+message.guild.members.find("id", warns[message.guild.id][mentioned.id][warn].user).user.tag+"** the **"+warns[message.guild.id][mentioned.id][warn].time+"**");
  349.  
  350.           }
  351.  
  352.           message.channel.send(arr.join('\n'));
  353.  
  354.         } else {
  355.  
  356.           message.channel.send("Error improper usage: "+prefix+"seewarns <user> <raison>");
  357.  
  358.           console.log(args);
  359.  
  360.         }
  361.  
  362.       } else {
  363.  
  364.         message.channel.send("Error improper usage: "+prefix+"seewarns <user> <raison>");
  365.  
  366.       }
  367.  
  368.     } else {
  369.  
  370.       message.channel.send("**:x: You dont have permission `Manage the server` in this server**");
  371.  
  372.     }
  373.  
  374.   }
  375.  
  376.  
  377.  
  378.  
  379. /*DeleteWarn*/  
  380.   if (message.content.startsWith(prefix+"deletewarns")||message.content===prefix+"deletewarns") {
  381.  
  382. if (message.channel.type === "dm") return;
  383.  
  384. if(!message.guild.member(message.author).hasPermission("MANAGE_GUILD")) return message.reply("**:x: You dont have permission `Manage the server` in this server**").catch(console.error);
  385.  
  386.    const mentioned = message.mentions.users.first();
  387.  
  388.     const args = message.content.split(' ').slice(1);
  389.  
  390.     const arg2 = Number(args[1]);
  391.  
  392.     if (message.member.hasPermission('MANAGE_GUILD')){
  393.  
  394.       if (message.mentions.users.size != 0) {
  395.  
  396.         if (args[0] === "<@!"+mentioned.id+">"||args[0] === "<@"+mentioned.id+">"){
  397.  
  398.           if (!isNaN(arg2)) {
  399.  
  400.             if (warns[message.guild.id][mentioned.id] === undefined) {
  401.  
  402.               message.channel.send(mentioned.tag+" have 0 Warn");
  403.  
  404.               return;
  405.  
  406.             } if (warns[message.guild.id][mentioned.id][arg2] === undefined) {
  407.  
  408.               message.channel.send("**:x: Tihs Warn doesnt exist**");
  409.  
  410.               return;
  411.  
  412.             }
  413.  
  414.             delete warns[message.guild.id][mentioned.id][arg2];
  415.  
  416.             var i = 1;
  417.  
  418.             Object.keys(warns[message.guild.id][mentioned.id]).forEach(function(key){
  419.  
  420.               var val=warns[message.guild.id][mentioned.id][key];
  421.  
  422.               delete warns[message.guild.id][mentioned.id][key];
  423.  
  424.               key = i;
  425.  
  426.               warns[message.guild.id][mentioned.id][key]=val;
  427.  
  428.               i++;
  429.  
  430.             });
  431.  
  432.             fs.writeFile("./warns.json", JSON.stringify(warns), (err) => {if (err) console.error(err);});
  433.  
  434.             if (Object.keys(warns[message.guild.id][mentioned.id]).length === 0) {
  435.  
  436.               delete warns[message.guild.id][mentioned.id];
  437.  
  438.             }
  439.  
  440.             message.channel.send(`The warn of **${mentioned.tag}**\': **${args[1]}** has been sucefully deleted`);
  441.  
  442.             return;
  443.  
  444.           } if (args[1] === "all") {
  445.  
  446.             delete warns[message.guild.id][mentioned.id];
  447.  
  448.             fs.writeFile("./warns.json", JSON.stringify(warns), (err) => {if (err) console.error(err);});
  449.  
  450.             message.channel.send(`The warn of **${mentioned.tag}** has been sucefully deleted`);
  451.  
  452.             return;
  453.  
  454.           } else {
  455.  
  456.             message.channel.send("Error improper usage: "+prefix+"clearwarns <user> <number>");
  457.  
  458.           }
  459.  
  460.         } else {
  461.  
  462.           message.channel.send("Error improper usage: "+prefix+"clearwarns <user> <number>");
  463.  
  464.         }
  465.  
  466.       } else {
  467.  
  468.        message.channel.send("Error improper usage: "+prefix+"clearwarns <user> <number>");
  469.  
  470.       }
  471.  
  472.     } else {
  473.  
  474.       message.channel.send("**:x: You dont have permission `Manage the server` in this server**");
  475.  
  476.     }
  477.  
  478.   }
  479.        
  480. });
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
 
Top