Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             /**
  2.          * Sets the currency name for a guild
  3.          * @param {String} gid
  4.          * @param {String} name
  5.          */
  6.         setCurrency : (gid, name) => {
  7.             return new Promise(async (resolve, reject) => {
  8.                
  9.                 //check if guild exist
  10.                 let entry = await client.database.collection('guilds').findOne({id:gid})
  11.                 if(entry == null) return reject('Guild does not exist in database.')
  12.  
  13.                 //update guild
  14.                 client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.currencyName":name}})
  15.  
  16.                 //handle results of write
  17.                 .then(resolve)
  18.                 .catch(reject)
  19.             })
  20.         },
  21.  
  22.         /**
  23.          * Sets the wallet name for a guild
  24.          * @param {String} gid
  25.          * @param {String} name
  26.          */
  27.         setWallet : (gid, name) => {
  28.             return new Promise(async (resolve, reject) => {
  29.                
  30.                 //check if guild exist
  31.                 let entry = await client.database.collection('guilds').findOne({id:gid})
  32.                 if(entry == null) return reject('Guild does not exist in database.')
  33.  
  34.                 //update guild
  35.                 client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.walletName":name}})
  36.  
  37.                 //handle results of write
  38.                 .then(resolve)
  39.                 .catch(reject)
  40.             })
  41.         },
  42.  
  43.         /**
  44.          * Sets the admin role for a guild
  45.          * @param {String} gid
  46.          * @param {String} name
  47.          */
  48.         setAdminRole : (gid, rid) => {
  49.             return new Promise(async (resolve, reject) => {
  50.                
  51.                 //check if guild exist
  52.                 let entry = await client.database.collection('guilds').findOne({id:gid})
  53.                 if(entry == null) return reject('Guild does not exist in database.')
  54.  
  55.                 //update guild
  56.                 client.database.collection('guilds').updateOne({id:gid}, {$set:{adminRole:rid}})
  57.  
  58.                 //handle results of write
  59.                 .then(resolve)
  60.                 .catch(reject)
  61.             })
  62.         },
  63.  
  64.         /**
  65.          * Sets the admin role for a guild
  66.          * @param {String} gid
  67.          * @param {String} name
  68.          */
  69.         setStarterBalance : (gid, bal) => {
  70.             return new Promise(async (resolve, reject) => {
  71.                
  72.                 //check if guild exist
  73.                 let entry = await client.database.collection('guilds').findOne({id:gid})
  74.                 if(entry == null) return reject('Guild does not exist in database.')
  75.  
  76.                 //update guild
  77.                 client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.starterBalance":bal}})
  78.  
  79.                 //handle results of write
  80.                 .then(resolve)
  81.                 .catch(reject)
  82.             })
  83.         },
  84.  
  85.  
  86.         /**
  87.          * Finalizes intial setup and checks to make sure everythings in order
  88.          * @param {String} gid
  89.          */
  90.         finalCheck : gid => {
  91.             return new Promise(async (resolve, reject) => {
  92.                
  93.                 //check if guild exist
  94.                 let entry = await client.database.collection('guilds').findOne({id:gid})
  95.                 if(entry == null) return reject('Guild does not exist in database.')
  96.  
  97.                 //run checks
  98.                 if(entry.eco.currencyName == null) return reject('Setup incomplete.')
  99.                 if(entry.eco.walletName == null) return reject('Setup incomplete.')
  100.                 if(entry.adminRole == null) return reject('Setup incomplete.')
  101.  
  102.                 //update guild
  103.                 client.database.collection('guilds').updateOne({id:gid}, {$set:{finishedSetup:true}})
  104.  
  105.                 //handle results of write
  106.                 .then(resolve)
  107.                 .catch(reject)
  108.             })
  109.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement