diff --git a/moonlink.js b/moonlink.js index 7e3281b..901685b 100644 --- a/moonlink.js +++ b/moonlink.js @@ -3,6 +3,7 @@ const { Manager } = require("moonlink.js"); const { version } = require("./package.json"); const Locale = require("./class/Locale"); const LocaleSchema = require("./schemas/Locale"); +const PlayingHistorySchema = require("./schemas/PlayingHistory"); /** * @@ -96,6 +97,22 @@ function initializationMoonlink(client) { ] }); } + + try { + if (track.requestedBy && track.sourceName && track.title && track.url && client.user.id && player.guildId && player.voiceChannelId) { + await PlayingHistorySchema.create({ + userId: track.requestedBy, + source: track.sourceName, + title: track.title, + url: track.url, + bot: client.user.id, + guildId: player.guildId, + channelId: player.voiceChannelId + }); + } + } catch (err) { + console.error(err); + } } catch (err) { console.error(err); } diff --git a/schemas/PlayingHistory.js b/schemas/PlayingHistory.js new file mode 100644 index 0000000..4265c31 --- /dev/null +++ b/schemas/PlayingHistory.js @@ -0,0 +1,13 @@ +const { model, Schema } = require("mongoose"); + +module.exports = model("playing_history", new Schema({ + userId: String, + source: String, + title: String, + url: String, + bot: String, + guildId: String, + channelId: String +}, { + timestamps: true +})); \ No newline at end of file