From c6f2e865f6dcd7891b051bd67024452c39d11564 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 19 Jun 2023 22:23:47 +0800 Subject: [PATCH] fix --- src/ws.message.ts | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/ws.message.ts b/src/ws.message.ts index 2b8f3e4..d8b83cf 100644 --- a/src/ws.message.ts +++ b/src/ws.message.ts @@ -137,30 +137,32 @@ export class WsMessage { this.messageUpdate(message); } private messageUpdate(message: any) { - // this.log("messageUpdate", JSON.stringify(message)); + const { content, embeds, interaction = {}, nonce, id } = message; - const { content, embeds, interaction, nonce, id } = message; - //settings - if (interaction.name === "settings" && !nonce) { - this.emit("settings", message); - return; - } - //describe - if (interaction.name === "describe" && !nonce) { - this.emitDescribe(id, embeds[0].description); - } - //info - if (interaction.name === "info" && !nonce) { - this.emit("info", embeds[0].description); - return; + if (!nonce) { + const { name } = interaction; + + switch (name) { + case "settings": + this.emit("settings", message); + return; + case "describe": + this.emitDescribe(id, embeds?.[0]?.description); + break; + case "info": + this.emit("info", embeds?.[0]?.description); + return; + } } - if (content === "") { - return; + if (content) { + this.processingImage(message); } - this.processingImage(message); } private processingImage(message: any) { - const { content, id, attachments, flags } = message; + const { content = "", id, attachments, flags } = message; + if (!content) { + return; + } const event = this.getEventById(id); if (!event) { return;