Skip to content

Instantly share code, notes, and snippets.

@Kittyasd Kittyasd/money bot Secret
Last active Oct 14, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.