Advertisement
Templuzy

Untitled

Feb 8th, 2021
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. const Canvacord = require("canvacord");
  4. const db = require('quick.db');
  5.  
  6. const prefix = 'hmb '
  7.  
  8. const fs = require('fs');
  9. const { Canvas } = require('canvacord');
  10.  
  11. client.commands = new Discord.Collection();
  12.  
  13. const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
  14. for(const file of commandFiles){
  15.     const command = require(`./commands/${file}`);
  16.  
  17.     client.commands.set(command.name, command);
  18. }
  19.  
  20.  
  21. client.once('ready', () => {
  22.     console.log('BB is online!')
  23.     //Below Status  
  24.     //Below Auto-Changing Status
  25.     setInterval(() => {
  26.         const statuses = [
  27.             `hmb help`,
  28.             `BURGERS!!!!`,
  29.         ]
  30.  
  31.         const status = statuses[Math.floor(Math.random() * statuses.length)]
  32.         client.user.setActivity(status, { type: "STREAMING"}) // Can Be WATCHING, STREAMING, LISTENING
  33.     }, 5000) // Second You Want to Change Status, This Cahnges Every 2 Seconds
  34. });
  35.  
  36. client.on('message', async message => {
  37.     if (message.author.bot) return
  38.     xp(message)
  39.     if(message.content.startsWith(`${prefix}rank`)) {
  40.         var user = message.mentions.users.first() || message.author
  41.         var level = db.get(`guild_${message.guild.id}_level_${user.id}`) || 0
  42.         level = level.toString()
  43.         let xp = db.get(`guild_${message.guild.id}_xp_${user.id}`) || 0
  44.         var xpNeeded = level * 500 + 500
  45.         let every = db
  46.             .all()
  47.             .filter(i => i.ID.startsWith(`guild_${message.guild.id}_xptotal_`))
  48.             .sort((a, b) => b.data - a.data) //mark
  49.         var rank = every.map(x => x.ID).indexOf(`guild_${message.guild.id}_xptotal_${user.id}`) + 1
  50.         rank = rank.toString()
  51.         const img = new Canvacord.Rank({
  52.             username: user.username,
  53.             discrim: user.discriminator,
  54.             status: user.presence.status,
  55.             currentXP: xp.toString(),
  56.             neededXP: xpNeeded.toString(),
  57.             rank,
  58.             level,
  59.             avatarURL: user.displayAvatarURL({ format: "png", size: 1024}),
  60.             color: "white"
  61.         })
  62.         img.onload = () => ctx.drawImage(img, 0, 0);
  63.         img.src = "rank.png";
  64.         message.channel.send(new Discord.MessageAttachment(img , "rank.png"))
  65.     }
  66. })
  67.  
  68. function xp(message) {
  69.     if (message.content.startsWith(prefix)) return
  70.     const randomNumber = Math.floor(Math.random() * 10) + 15
  71.     db.add(`guild_${message.guild.id}_xp_${message.author.id}`, randomNumber)
  72.     db.add(`guild_${message.guild.id}_xptotal_${message.author.id}`, randomNumber)
  73.     var level = db.get(`guild_${message.guild.id}_level_${message.author.id}`) || 1
  74.     var xp = db.get(`guild_${message.guild.id}_xp_${message.author.id}`)
  75.     var xpNeeded = level * 500
  76.     if (xpNeeded < xp) {
  77.         var newLevel = db.add(`guild_${message.guild.id}_level_${message.author.id}`, 1)
  78.         db.subtract(`guild_${message.guild.id}_xp_${message.author.id}`, xpNeeded)
  79.         message.channel.send(`${message.author}, you leveled up to Hamburger tier ${newLevel}`)
  80.     }
  81. }
  82.  
  83. client.on('message', message =>{
  84.     if(!message.content.startsWith(prefix) || message.author.bot) return;
  85.  
  86.     const args = message.content.slice(prefix.length).split(/ +/);
  87.     const command = args.shift().toLowerCase();
  88.  
  89.     if(command === 'ping'){
  90.         client.commands.get('ping').execute(client, message, args);
  91.     } else if(command === 'ban'){
  92.         client.commands.get('ban').execute(message, args);
  93.     } else if(command === 'kick'){
  94.         client.commands.get('kick').execute(message, args);
  95.     } else if(command === 'help'){
  96.         client.commands.get('help').execute(message, args);
  97.     } else if(command === 'burger'){
  98.         client.commands.get('burger').execute(message, args);
  99.     } else if(command === 'hungry'){
  100.         client.commands.get('hungry').execute(message, args);
  101.     } else if(command === 'give'){
  102.         client.commands.get('give').execute(message, args);
  103.     } else if(command === 'warn'){
  104.         client.commands.get('warn').execute(client, message, args)
  105.     }
  106. });
  107.  
  108. client.login('ODApMjYwMTMzuzMxNzI5NDI4.Yi7MSw.n79OYz6EAOVuC3UBrgEPum30hng');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement