commandDispatcher: handle errors
This commit is contained in:
		
							parent
							
								
									cc4d882d7a
								
							
						
					
					
						commit
						0de8b61ddb
					
				
					 1 changed files with 20 additions and 8 deletions
				
			
		| 
						 | 
					@ -83,7 +83,8 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const response = await runCommand(msg, cmd, line, args);
 | 
					    const response = await runCommand(msg, cmd, line, args);
 | 
				
			||||||
    if (response != null) {
 | 
					    if (response != null) {
 | 
				
			||||||
      msg.channel.createMessage(
 | 
					      msg.channel
 | 
				
			||||||
 | 
					        .createMessage(
 | 
				
			||||||
          Object.assign(
 | 
					          Object.assign(
 | 
				
			||||||
            typeof response === "string" ? {content: response} : response,
 | 
					            typeof response === "string" ? {content: response} : response,
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -96,7 +97,18 @@ async function CommandDispatcher(msg) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
          response.file
 | 
					          response.file
 | 
				
			||||||
      );
 | 
					        )
 | 
				
			||||||
 | 
					        .catch((e) => {
 | 
				
			||||||
 | 
					          msg.channel.createMessage({
 | 
				
			||||||
 | 
					            content: `:warning: An error has occurred:\n\`\`\`${e}\`\`\``,
 | 
				
			||||||
 | 
					            allowedMentions: {
 | 
				
			||||||
 | 
					              repliedUser: false,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            messageReference: {
 | 
				
			||||||
 | 
					              messageID: msg.id,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    msg.hasRan = true;
 | 
					    msg.hasRan = true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue