reactions support
This commit is contained in:
		
							parent
							
								
									74d92bbf6b
								
							
						
					
					
						commit
						815ae686f3
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								src/index.js
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								src/index.js
									
										
									
									
									
								
							| 
						 | 
					@ -147,6 +147,7 @@ rpc.once("ready", function () {
 | 
				
			||||||
rpc.on("error", function () {});
 | 
					rpc.on("error", function () {});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
client.on("messageCreate", async function (msg) {
 | 
					client.on("messageCreate", async function (msg) {
 | 
				
			||||||
 | 
					  if (!msg.author) return;
 | 
				
			||||||
  if (msg.author.id === client.user.id) return;
 | 
					  if (msg.author.id === client.user.id) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (
 | 
					  if (
 | 
				
			||||||
| 
						 | 
					@ -184,6 +185,7 @@ client.on("messageCreate", async function (msg) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
client.on("messageUpdate", async function (msg, old) {
 | 
					client.on("messageUpdate", async function (msg, old) {
 | 
				
			||||||
 | 
					  if (!msg.author) return;
 | 
				
			||||||
  if (msg.author.id === client.user.id) return;
 | 
					  if (msg.author.id === client.user.id) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (
 | 
					  if (
 | 
				
			||||||
| 
						 | 
					@ -222,6 +224,31 @@ client.on("messageUpdate", async function (msg, old) {
 | 
				
			||||||
    comcord.state.lastDM = msg.channel;
 | 
					    comcord.state.lastDM = msg.channel;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					client.on("messageReactionAdd", async function (msg, emoji, reactor) {
 | 
				
			||||||
 | 
					  if (msg.channel.id != comcord.state.currentChannel) return;
 | 
				
			||||||
 | 
					  const reply =
 | 
				
			||||||
 | 
					    msg.channel.messages.get(msg.id) ??
 | 
				
			||||||
 | 
					    (await msg.channel
 | 
				
			||||||
 | 
					      .getMessages({
 | 
				
			||||||
 | 
					        limit: 1,
 | 
				
			||||||
 | 
					        around: msg.id,
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      .then((msgs) => msgs[0]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const data = {
 | 
				
			||||||
 | 
					    channel: msg.channel,
 | 
				
			||||||
 | 
					    referencedMessage: reply,
 | 
				
			||||||
 | 
					    author: reactor?.user ?? client.users.get(reactor.id),
 | 
				
			||||||
 | 
					    timestamp: Date.now(),
 | 
				
			||||||
 | 
					    content: `*reacted with ${emoji.id ? `:${emoji.name}:` : emoji.name}*`,
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (comcord.state.inPrompt) {
 | 
				
			||||||
 | 
					    comcord.state.messageQueue.push(data);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    processMessage(data);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
process.stdin.on("data", async function (key) {
 | 
					process.stdin.on("data", async function (key) {
 | 
				
			||||||
  if (comcord.state.inPrompt) {
 | 
					  if (comcord.state.inPrompt) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue