mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
24 lines
681 B
TypeScript
24 lines
681 B
TypeScript
|
import TClient from 'src/client';
|
||
|
import mongoose from 'mongoose';
|
||
|
|
||
|
const Schema = mongoose.model('bonkCount', new mongoose.Schema({
|
||
|
_id: {type: String, required:true},
|
||
|
value: {type: Number, required:true}
|
||
|
}));
|
||
|
|
||
|
export default class bonkCount extends Schema {
|
||
|
client: TClient;
|
||
|
_content: typeof Schema;
|
||
|
constructor(client:TClient){
|
||
|
super();
|
||
|
this.client = client;
|
||
|
this._content = Schema;
|
||
|
}
|
||
|
async _incrementUser(userid: string){
|
||
|
const amount = await this._content.findById(userid)
|
||
|
if (amount) await this._content.findByIdAndUpdate(userid, {value: amount.value + 1})
|
||
|
else await this._content.create({_id: userid, value: 1})
|
||
|
return this;
|
||
|
}
|
||
|
}
|