diff --git a/src/cogs/ZzalUpload.py b/src/cogs/ZzalUpload.py index 331eee6..f368355 100644 --- a/src/cogs/ZzalUpload.py +++ b/src/cogs/ZzalUpload.py @@ -26,7 +26,7 @@ async def _upload(self, interaction: Interaction, message: Message, upload_type: [ uploaded, error, - ] = await self.uploadService.upload(upload_type, message.content, message.attachments) + ] = await self.uploadService.upload(upload_type, message) if uploaded > 0: if uploaded == 1: diff --git a/src/services/uploadService.py b/src/services/uploadService.py index 020e64b..dc8eb31 100644 --- a/src/services/uploadService.py +++ b/src/services/uploadService.py @@ -5,7 +5,7 @@ from enum import Enum from typing import List -from discord import Attachment +from discord import Attachment, Message from PIL import Image from synology_api import filestation @@ -23,7 +23,7 @@ def __init__(self): self.google_util = sheet.SheetPlugin() self.nasStation = filestation.FileStationPlugin().getFileStation() - async def upload(self, type: UploadType, message: str, files: List[Attachment]) -> tuple[int, str]: + async def upload(self, type: UploadType, message: Message) -> tuple[int, str]: worksheet = self.google_util.get_worksheet_by_index( key="1hfW3FTo9cjuMW9Kxvfnrbc6p_HyEnyYeA38mKM7nrOE", index=type.value ) @@ -34,7 +34,7 @@ async def upload(self, type: UploadType, message: str, files: List[Attachment]) uploaded = 0 errors = [] - for file in files: + for file in message.attachments: filename = file.filename if not ( @@ -46,7 +46,7 @@ async def upload(self, type: UploadType, message: str, files: List[Attachment]) ): _error_msg = f"`{filename}` 파일은 지원하지 않는 형식입니다." - if len(files) == 1: + if len(message.attachments) == 1: raise Exception(_error_msg) else: errors.append(_error_msg) @@ -76,7 +76,7 @@ async def upload(self, type: UploadType, message: str, files: List[Attachment]) if not zzal_name in resv_zzal_names: _error_msg = f"`{zzal_name}` 시트에 등록되지 않은 짤 이름입니다. 등록 후 다시 시도해 주세요." - if len(files) == 1: + if len(message.attachments) == 1: raise Exception(_error_msg) else: errors.append(_error_msg) @@ -125,7 +125,7 @@ async def upload(self, type: UploadType, message: str, files: List[Attachment]) else: _error_msg = f"업로드 중 문제가 발생했습니다.\n\n{uploadRes}" - if len(files) == 1: + if len(message.attachments) == 1: raise Exception(_error_msg) else: errors.append(_error_msg)