codePreviews: null check
This commit is contained in:
		
							parent
							
								
									98a3dfe26c
								
							
						
					
					
						commit
						e0d67ff501
					
				
					 1 changed files with 53 additions and 51 deletions
				
			
		| 
						 | 
					@ -28,6 +28,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
 | 
				
			||||||
  const gitlabLinks = msg.content.match(REGEX_GITLAB);
 | 
					  const gitlabLinks = msg.content.match(REGEX_GITLAB);
 | 
				
			||||||
  const giteaLinks = msg.content.match(REGEX_GITEA);
 | 
					  const giteaLinks = msg.content.match(REGEX_GITEA);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (githubLinks?.length) {
 | 
				
			||||||
    for (const link of githubLinks) {
 | 
					    for (const link of githubLinks) {
 | 
				
			||||||
      const rawLink = link.replace("/blob/", "/raw/");
 | 
					      const rawLink = link.replace("/blob/", "/raw/");
 | 
				
			||||||
      const file = await fetch(rawLink).then((res) => res.text());
 | 
					      const file = await fetch(rawLink).then((res) => res.text());
 | 
				
			||||||
| 
						 | 
					@ -86,6 +87,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
 | 
				
			||||||
        unindent(targetLines) +
 | 
					        unindent(targetLines) +
 | 
				
			||||||
        "\n```\n";
 | 
					        "\n```\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (out !== "")
 | 
					  if (out !== "")
 | 
				
			||||||
    msg.channel.createMessage({
 | 
					    msg.channel.createMessage({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue