Compare commits
	
		
			3 Commits
		
	
	
		
			1559faeeb7
			...
			a2000f8a19
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | a2000f8a19 | |
|  | cbbd1db0cf | |
|  | 6dabdf07d6 | 
|  | @ -1,7 +1,6 @@ | |||
| class Message { | ||||
|     /** | ||||
|      * @typedef {Object} MessageFields | ||||
|      * @property {import('crypto').UUID} uuid | ||||
|      * @property {import('discord.js').Snowflake} serverId | ||||
|      * @property {string|null} serverName | ||||
|      * @property {import('discord.js').Snowflake} authorId | ||||
|  | @ -10,7 +9,6 @@ class Message { | |||
|      */ | ||||
| 
 | ||||
|     constructor(){ | ||||
|         this.uuid = require('crypto').randomUUID(); | ||||
|         this.serverId = 1; | ||||
|         this.serverName = "[No Server]"; | ||||
|         this.authorId = 1; | ||||
|  | @ -36,7 +34,6 @@ class Message { | |||
| 
 | ||||
|     toArray(){ | ||||
|         return { | ||||
|             uuid : this.uuid, | ||||
|             serverId : this.serverId, | ||||
|             serverName : this.serverName, | ||||
|             authorId : this.authorId, | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ const { EmbedBuilder } = require("@discordjs/builders"); | |||
|  * @param {Message} message | ||||
|  * @param {Client} discord  | ||||
|  */ | ||||
| const send = (message, database, channelId , discord) => { | ||||
| const send = (message, database, channelId , uuid , discord) => { | ||||
|     discord.channels.cache?.get(channelId).send({ | ||||
|         embeds: [ | ||||
|             new EmbedBuilder() | ||||
|  | @ -21,7 +21,16 @@ const send = (message, database, channelId , discord) => { | |||
|                     iconURL: discord.user.displayAvatarURL() | ||||
|                 }) | ||||
|         ] | ||||
|     }) | ||||
|     }).catch((error) => { | ||||
|         console.log(`Unable to Send Message to Channel [${channelId}]`); | ||||
|     }).then((_message) => { | ||||
|         database.insert("xan.messageDelivery" ,{ | ||||
|             channelId: channelId, | ||||
|             messageId : _message.id, | ||||
|             client: "discord", | ||||
|             link: uuid | ||||
|         }, (uuid) => {}); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| module.exports = send; | ||||
|  | @ -10,11 +10,11 @@ const initMessageManager = async ( | |||
|     database, | ||||
|     discord | ||||
| ) => { | ||||
|     function postMessage(message){ | ||||
|     function postMessage(message, uuid){ | ||||
|         database.list("xan.guilds" , {} , (list) => { | ||||
|            for(var element of list){ | ||||
| 
 | ||||
|             if(element.client == "discord") discordSend(message , data , element.channelId , discord); | ||||
|             if(element.client == "discord") discordSend(message , database , element.channelId ,uuid , discord); | ||||
|            }  | ||||
|         }); | ||||
|     } | ||||
|  | @ -26,6 +26,9 @@ const initMessageManager = async ( | |||
|             serverId : message.guild.id | ||||
|         } , async (data) => { | ||||
|             if(data !== null){ | ||||
| 
 | ||||
|                 message.delete().catch((error) => {}); | ||||
| 
 | ||||
|                 var _message = new Message(); | ||||
|                 _message.authorId = message.author.id; | ||||
|                 _message.authorName = message.author.username; | ||||
|  | @ -33,9 +36,9 @@ const initMessageManager = async ( | |||
|                 _message.serverName = message.guild.name, | ||||
|                 _message.message = message.content; | ||||
| 
 | ||||
|                 delete _message.uuid; | ||||
| 
 | ||||
|                 postMessage(_message.toArray()); | ||||
|                 database.insert("xan.messages" , _message.toArray() , (uuid) => { | ||||
|                     postMessage(_message.toArray(), uuid); | ||||
|                 }); | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue