Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Sets the currency name for a guild
- * @param {String} gid
- * @param {String} name
- */
- setCurrency : (gid, name) => {
- return new Promise(async (resolve, reject) => {
- //check if guild exist
- let entry = await client.database.collection('guilds').findOne({id:gid})
- if(entry == null) return reject('Guild does not exist in database.')
- //update guild
- client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.currencyName":name}})
- //handle results of write
- .then(resolve)
- .catch(reject)
- })
- },
- /**
- * Sets the wallet name for a guild
- * @param {String} gid
- * @param {String} name
- */
- setWallet : (gid, name) => {
- return new Promise(async (resolve, reject) => {
- //check if guild exist
- let entry = await client.database.collection('guilds').findOne({id:gid})
- if(entry == null) return reject('Guild does not exist in database.')
- //update guild
- client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.walletName":name}})
- //handle results of write
- .then(resolve)
- .catch(reject)
- })
- },
- /**
- * Sets the admin role for a guild
- * @param {String} gid
- * @param {String} name
- */
- setAdminRole : (gid, rid) => {
- return new Promise(async (resolve, reject) => {
- //check if guild exist
- let entry = await client.database.collection('guilds').findOne({id:gid})
- if(entry == null) return reject('Guild does not exist in database.')
- //update guild
- client.database.collection('guilds').updateOne({id:gid}, {$set:{adminRole:rid}})
- //handle results of write
- .then(resolve)
- .catch(reject)
- })
- },
- /**
- * Sets the admin role for a guild
- * @param {String} gid
- * @param {String} name
- */
- setStarterBalance : (gid, bal) => {
- return new Promise(async (resolve, reject) => {
- //check if guild exist
- let entry = await client.database.collection('guilds').findOne({id:gid})
- if(entry == null) return reject('Guild does not exist in database.')
- //update guild
- client.database.collection('guilds').updateOne({id:gid}, {$set:{"eco.starterBalance":bal}})
- //handle results of write
- .then(resolve)
- .catch(reject)
- })
- },
- /**
- * Finalizes intial setup and checks to make sure everythings in order
- * @param {String} gid
- */
- finalCheck : gid => {
- return new Promise(async (resolve, reject) => {
- //check if guild exist
- let entry = await client.database.collection('guilds').findOne({id:gid})
- if(entry == null) return reject('Guild does not exist in database.')
- //run checks
- if(entry.eco.currencyName == null) return reject('Setup incomplete.')
- if(entry.eco.walletName == null) return reject('Setup incomplete.')
- if(entry.adminRole == null) return reject('Setup incomplete.')
- //update guild
- client.database.collection('guilds').updateOne({id:gid}, {$set:{finishedSetup:true}})
- //handle results of write
- .then(resolve)
- .catch(reject)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement