Advertisement
JackyG

Untitled

Aug 7th, 2022
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   const contributorRole = message.member.roles.cache.some(role => role.name === "Contributor");
  2.   const boosterRole = message.member.roles.cache.some(role => role.name === "Nitro Boost");
  3.   const memberOfTheWeekRole = message.member.roles.cache.some(role => role.name === "Member of the Week");
  4.  
  5.   try {
  6.  
  7.     if (message.author.bot) return;
  8.  
  9.     if (!contributorRole | !boosterRole | !memberOfTheWeekRole) {
  10.       const LevelSystem = await levelSystem.create({
  11.         nameUser: message.author.tag,
  12.         idUser: message.author.id,
  13.         level: "0",
  14.         xp: "5",
  15.         boost: "0",
  16.       });
  17.     } else {
  18.       const LevelSystem = await levelSystem.create({
  19.         nameUser: message.author.tag,
  20.         idUser: message.author.id,
  21.         level: "0",
  22.         xp: "10",
  23.         boost: "0",
  24.       });
  25.     }
  26.   } catch (error) {
  27.     if (error.name === "SequelizeUniqueConstraintError") {
  28.       const userData = await levelSystem.findOne({ where: { idUser: message.author.id } });
  29.  
  30.       if (userData.xp % 1000 === 0) userData.increment("level", { by: 1 });
  31.  
  32.       if (!contributorRole | !boosterRole | !memberOfTheWeekRole) {
  33.         userData.increment("xp", { by: 5 });
  34.       } else {
  35.         userData.increment("xp", { by: 10 });
  36.       }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement