Skip to content

Instantly share code, notes, and snippets.

@kakarot-dev
Created May 25, 2021 14:22
Show Gist options
  • Save kakarot-dev/253956e256d0d7d30ab7c99f915e48f7 to your computer and use it in GitHub Desktop.
Save kakarot-dev/253956e256d0d7d30ab7c99f915e48f7 to your computer and use it in GitHub Desktop.
schema
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,
});
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