-
-
Save Kittyasd/3bb6d625906b053388f50eff4f3dace9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const botconfig = require("./botconfig.json"); | |
const Discord = require("discord.js"); | |
const bot = new Discord.Client(); | |
const mongoose = require("mongoose"); | |
const url = "mongodb://localhost:27017/money"; | |
mongoose.connect(url, { useNewUrlParser: true }); | |
const BountySchema = mongoose.Schema({ | |
userID: String, | |
money: Number | |
}) | |
var Money = mongoose.model("Money", BountySchema); | |
bot.on("message", async message => { | |
let prefix = botconfig.prefix; | |
let messageArray = message.content.split(" "); | |
let cmd = messageArray[0]; | |
let args = messageArray.slice(1); | |
if(cmd === `${prefix}givebounty`){ | |
let quantit = Number(args.join(" ").slice(22)); | |
let quantity = quantit*1; | |
Money.findOne({ | |
userID: message.author.id | |
}, (money) => { | |
if(!money){ | |
const newMoney = new Money({ | |
userID: message.author.id, | |
money: quantity | |
}) | |
newMoney.save(); | |
} | |
else{ | |
money.money = money.money + quantity; | |
money.save(); | |
} | |
}) | |
} | |
}) | |
bot.login(botconfig.token); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment