Created
May 25, 2021 14:22
-
-
Save kakarot-dev/253956e256d0d7d30ab7c99f915e48f7 to your computer and use it in GitHub Desktop.
schema
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
import { afk } from '../../mongoose/schemas/afk-message'; | |
await afk.findOneAndUpdate({ // Update AFK message | |
guildId, | |
userId | |
}, { | |
guildId, | |
userId, | |
$set: { | |
afk: afkMessage, | |
timestamp: new Date().getTime(), | |
username: message.member?.nickname === null ? message.author.username : message.member?.nickname // Keep Old Username | |
} | |
}, { | |
upsert: true, | |
}); |
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
import mongoose from 'mongoose'; | |
const afkSchema = new mongoose.Schema({ // Make schema | |
guildId: { | |
type: String, | |
required: true | |
}, | |
userId: { | |
type: String, | |
required: true | |
}, | |
afk: { | |
type: String, | |
required: true | |
}, | |
timestamp: { | |
type: Number, | |
required: true, | |
}, | |
username: { // So we can change username back | |
type: String, | |
required: true, | |
} | |
}); | |
const afk = mongoose.model<any>('afk', afkSchema); | |
export { afk }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment