Intégration MongoDB + Fix export et amp
This commit is contained in:
24
src/events/player/disconnect.ts
Executable file
24
src/events/player/disconnect.ts
Executable file
@@ -0,0 +1,24 @@
|
||||
import { GuildQueue, Track } from 'discord-player'
|
||||
import { PlayerMetadata } from '../../utilsPlayer/metadata'
|
||||
import dbGuild from '../../schemas/guild'
|
||||
|
||||
export default {
|
||||
name: 'disconnect',
|
||||
async execute(queue: GuildQueue<PlayerMetadata>, track: Track) {
|
||||
// Emitted when the bot leaves the voice channel
|
||||
queue.metadata.channel.send("J'ai quitté le vocal !")
|
||||
|
||||
let guildProfile = await dbGuild.findOne({ guildId: queue.guild.id })
|
||||
if (!guildProfile) return console.log(`Database data for **${queue.guild.name}** does not exist !`)
|
||||
|
||||
let dbData = guildProfile.get('guildPlayer.replay')
|
||||
dbData['textChannelId'] = ''
|
||||
dbData['voiceChannelId'] = ''
|
||||
dbData['trackUrl'] = ''
|
||||
dbData['progress'] = ''
|
||||
|
||||
guildProfile.set('guildPlayer.replay', dbData)
|
||||
guildProfile.markModified('guildPlayer.replay')
|
||||
return await guildProfile.save().catch(console.error)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user