Skip to content

Instantly share code, notes, and snippets.

@Kittyasd
Last active October 14, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kittyasd/b6a828ad1915ac82c494f37457567bf4 to your computer and use it in GitHub Desktop.
Save Kittyasd/b6a828ad1915ac82c494f37457567bf4 to your computer and use it in GitHub Desktop.
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.findOneAndUpdate({
userID: message.author.id},
(money) => {
money.money = money.money + quantity;
})
}
})
bot.login(botconfig.token);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment