Added Interaction integration

This commit is contained in:
ION606
2023-03-20 12:45:20 -04:00
parent 9faf4a315e
commit 0e33185f16
10 changed files with 286 additions and 8 deletions
+7 -2
View File
@@ -1,6 +1,7 @@
const { exit } = require('process');
const gateWayEvents = require('../gateway/dispatch.js');
const { message } = require('../messages/message.js');
const Interaction = require('../interactions/interaction.js');
/**
@@ -8,7 +9,7 @@ const { message } = require('../messages/message.js');
* @param {Object} msg
* @returns {Promise<Boolean>}
*/
module.exports = async function handleEvents(msgObj, token) {
module.exports = async function handleEvents(msgObj, token, id) {
return new Promise((resolve, reject) => {
const op = msgObj["op"];
const t = msgObj["t"];
@@ -17,10 +18,14 @@ module.exports = async function handleEvents(msgObj, token) {
if (op == 0 && t == gateWayEvents.Ready) {
resolve({op: op, t: t, config: msgObj["d"]["user_settings"], profile: msgObj["d"]["user"] });
} else if (t == gateWayEvents.MessageCreate) {
}
else if (t == gateWayEvents.MessageCreate) {
const msg = new message(msgObj["d"], token);
resolve({op: op, t: t, message: msg});
}
else if (t == gateWayEvents.InteractionCreate) {
resolve({op: op, t: t, interaction: new Interaction(msgObj["d"], token, id)});
}
else {
// console.log(t);