Advertisement
ademisking

Untitled

Mar 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. var Discord = require('discord.js');
  2. var bot = new Discord.Client();
  3. var fs = require('fs');
  4.  
  5. var userData = JSON.parse(fs.readFileSync('Storage/userData.json', 'utf8'));
  6. var commandsList = fs.readFileSync('Storage/commands.txt', 'utf8');
  7. bot.commands = new Discord.Collection();
  8.  
  9. fs.readdir('./commands/', (err, files) => {
  10. if(err) console.error(err);
  11.  
  12. var jsfiles = files.filter(f => f.split('.').pop() === 'js');
  13. if (jsfiles.length <= 0) { return console.log('No commands found...')}
  14. else {console.log(jsfiles.length + 'commands found.') }
  15.  
  16. jsfiles.forEach((f, i) => {
  17. var cmds = require('./commands/${f}');
  18. console.logs('Command ${f} loading...');
  19. bot.commands.set(cmds.config.command, cmds);
  20. })
  21.  
  22. })
  23.  
  24. function userInfo(user, guild) {
  25. var finalString = '';
  26.  
  27. finalString += '**' + user.username + '**, with the **ID** of **' + user.id + '**';
  28.  
  29. var userCreated = user.createdAt.toString().split(' ');
  30. finalString += ', was created on ' + userCreated[1] + ', ' + userCreated[2] +' ' + userCreated[3] + '.**'
  31.  
  32. finalString += 'Since then, they have **sent ' + userData[user.id + guild.id].messagesSent + 'messages** to this discord.'
  33.  
  34. return finalString;
  35. }
  36.  
  37. bot.on('message', message => {
  38.  
  39. var sender = message.author;
  40. var msg = message.content.toUpperCase();
  41. var prefix = '.'
  42. var cont = message.content.slice(prefix.length).split("");
  43. var args = cont.slice(1);
  44.  
  45. if (!message.content.startsWith(prefix)) return;
  46.  
  47. var cmd = bot.commands.get(cont[0])
  48. if (cmd) cmd.run(bot, message, args);
  49.  
  50. if(!userData[sender.id + message.guild.id]) userData[sender.id + message.guild.id] ={
  51. messagesSent: 0
  52. }
  53.  
  54. userData[sender.id + message.guild.id].messagesSent++;
  55.  
  56. if(sender.id === '559121240267161664') {
  57. return;
  58. }
  59.  
  60.  
  61.  
  62.  
  63. if (message.channel.id === '559451362765832192') {
  64. if(isNaN(message.content)) {
  65. message.delete()
  66. message.author.send('Please only post the number, and not any other text in this channel, thank you!')
  67. }
  68. }
  69.  
  70. if(msg.includes('NIG')) {
  71. message.delete();
  72. message.author.send('the word **nig** is banned, please dont use it again..')
  73. }
  74.  
  75. if(msg.includes('PING')) {
  76. message.channel.send('https://gyazo.com/73e7658b200e0694ceb59926754e397f')
  77. }
  78.  
  79. if(msg.startsWith(prefix + 'USERINFO')) {
  80. if (msg === prefix + 'USERINFO') {
  81. message.channel.send(userInfo(sender, message.guild));
  82. }
  83. }
  84.  
  85. fs.writeFile('Storage/userData.json', JSON.stringify(userData), (err) =>{
  86. if(err) console.error(err);
  87. });
  88.  
  89. });
  90.  
  91. bot.on('ready', () => {
  92. console.log('Bot Launched...')
  93.  
  94.  
  95.  
  96. bot.user.setStatus('Online')
  97.  
  98. bot.user.setGame('work in progress')
  99.  
  100. });
  101.  
  102. bot.on('guildMemberAdd',member => {
  103.  
  104. console.log('User' + member.user.username + 'has joined the server!')
  105.  
  106. var role = member.guild.roles.find('name', '👊 Base 👊');
  107.  
  108. member.addRole(role)
  109.  
  110. });
  111.  
  112.  
  113.  
  114. bot.login('token')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement