From 1a98e5708b2bcf2d4cf2b126762392ce2160a77e Mon Sep 17 00:00:00 2001 From: na2na-p <yamamoto.akyshi@gmail.com> Date: Mon, 9 May 2022 17:43:26 +0900 Subject: [PATCH] =?UTF-8?q?=E6=8E=A1=E7=94=A8=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9FAPI=E3=81=8C=E4=BD=BF=E3=81=88=E3=81=AA=E3=81=8F?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E5=88=A5=E3=81=AE=E3=82=82=E3=81=AE=E3=81=AB=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/summonCat/index.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/modules/summonCat/index.ts b/src/modules/summonCat/index.ts index 9ffce4d..756e36d 100644 --- a/src/modules/summonCat/index.ts +++ b/src/modules/summonCat/index.ts @@ -21,12 +21,10 @@ export default class extends Module { if (msg.text && (msg.text.match(/(cat|Cat|ねこ|ネコ|にゃ[〜|ー]*ん)/g))) { const message = "にゃ~ん!"; - setTimeout(async () => { - const file = await this.getCatImage(); - this.log(file); - this.log('Replying...'); - msg.reply(message, { file }); - }, 500); + const file = await this.getCatImage(); + this.log(file); + this.log('Replying...'); + msg.reply(message, { file }); return { reaction: ':blobcatmeltnomblobcatmelt:' @@ -40,10 +38,10 @@ export default class extends Module { private async getCatImage(): Promise<any> { // https://aws.random.cat/meowにGETリクエストを送る // fileに画像URLが返ってくる - const res = await fetch('https://aws.random.cat/meow'); + const res = await fetch('https://api.thecatapi.com/v1/images/search'); const json = await res.json(); console.table(json); - const fileUri = json.file; + const fileUri = json[0].url; // 拡張子を取り除く const fileName = fileUri.split('/').pop().split('.')[0]; const rawFile = await fetch(fileUri);