commandDispatcher: convert embed to embeds, add addReactions
This commit is contained in:
		
							parent
							
								
									ff8d811ee3
								
							
						
					
					
						commit
						2577a7e847
					
				
					 1 changed files with 55 additions and 34 deletions
				
			
		| 
						 | 
					@ -82,6 +82,7 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const args = parseArguments(line);
 | 
					    const args = parseArguments(line);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
      const response = await runCommand(msg, cmd, line, args);
 | 
					      const response = await runCommand(msg, cmd, line, args);
 | 
				
			||||||
      if (response != null) {
 | 
					      if (response != null) {
 | 
				
			||||||
        let file;
 | 
					        let file;
 | 
				
			||||||
| 
						 | 
					@ -89,6 +90,9 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
          file = response.file;
 | 
					          file = response.file;
 | 
				
			||||||
          delete response.file;
 | 
					          delete response.file;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (response.embed) {
 | 
				
			||||||
 | 
					          response.embeds = [...(response.embeds ?? []), response.embed];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (response.embeds) {
 | 
					        if (response.embeds) {
 | 
				
			||||||
          for (const embed of response.embeds) {
 | 
					          for (const embed of response.embeds) {
 | 
				
			||||||
            embed.color =
 | 
					            embed.color =
 | 
				
			||||||
| 
						 | 
					@ -99,8 +103,8 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
        if (response.reaction) {
 | 
					        if (response.reaction) {
 | 
				
			||||||
          msg.addReaction(response.reaction);
 | 
					          msg.addReaction(response.reaction);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
        msg.channel
 | 
					          try {
 | 
				
			||||||
          .createMessage(
 | 
					            const outMessage = await msg.channel.createMessage(
 | 
				
			||||||
              Object.assign(
 | 
					              Object.assign(
 | 
				
			||||||
                typeof response === "string" ? {content: response} : response,
 | 
					                typeof response === "string" ? {content: response} : response,
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
| 
						 | 
					@ -113,10 +117,16 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              ),
 | 
					              ),
 | 
				
			||||||
              file
 | 
					              file
 | 
				
			||||||
          )
 | 
					            );
 | 
				
			||||||
          .catch((e) => {
 | 
					            if (response.addReactions) {
 | 
				
			||||||
 | 
					              for (const index in response.addReactions) {
 | 
				
			||||||
 | 
					                const reaction = response.addReactions[index];
 | 
				
			||||||
 | 
					                await outMessage.addReaction(reaction);
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          } catch (err) {
 | 
				
			||||||
            msg.channel.createMessage({
 | 
					            msg.channel.createMessage({
 | 
				
			||||||
              content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
 | 
					              content: `:warning: An error has occurred:\n\`\`\`${err}\`\`\``,
 | 
				
			||||||
              allowedMentions: {
 | 
					              allowedMentions: {
 | 
				
			||||||
                repliedUser: false,
 | 
					                repliedUser: false,
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
| 
						 | 
					@ -124,10 +134,21 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
                messageID: msg.id,
 | 
					                messageID: msg.id,
 | 
				
			||||||
              },
 | 
					              },
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
          });
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        msg.hasRan = true;
 | 
					        msg.hasRan = true;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    } catch (err) {
 | 
				
			||||||
 | 
					      msg.channel.createMessage({
 | 
				
			||||||
 | 
					        content: `:warning: An error has occurred:\n\`\`\`${err}\`\`\``,
 | 
				
			||||||
 | 
					        allowedMentions: {
 | 
				
			||||||
 | 
					          repliedUser: false,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        messageReference: {
 | 
				
			||||||
 | 
					          messageID: msg.id,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue