Intégration MongoDB + Fix export et amp
This commit is contained in:
19
src/events/client/guildUpdate.ts
Executable file
19
src/events/client/guildUpdate.ts
Executable file
@@ -0,0 +1,19 @@
|
||||
import { Events, Guild } from 'discord.js'
|
||||
import dbGuildInit from '../../utils/dbGuildInit'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
|
||||
export default {
|
||||
name: Events.GuildUpdate,
|
||||
async execute(oldGuild: Guild, newGuild: Guild) {
|
||||
console.log(`Guild ${oldGuild.name} updated`)
|
||||
|
||||
let guildProfile = await dbGuild.findOne({ guildId: newGuild.id })
|
||||
if (!guildProfile) {
|
||||
guildProfile = await dbGuildInit(newGuild)
|
||||
} else {
|
||||
guildProfile.guildName = newGuild.name
|
||||
guildProfile.guildIcon = newGuild.iconURL() ?? 'None'
|
||||
await guildProfile.save().catch(console.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user