[docs]asyncdeffetch(self)->bytes:""" Fetches the asset Returns ------- `bytes` The asset data """r=awaithttp.query("GET",self.url,res_method="read")ifr.statusnotinrange(200,300):raiseHTTPException(r)returnr.response
[docs]asyncdefsave(self,path:str)->int:""" Fetches the file from the attachment URL and saves it locally to the path Parameters ---------- path: `str` Path to save the file to, which includes the filename and extension. Example: `./path/to/file.png` Returns ------- `int` The amount of bytes written to the file """data=awaitself.fetch()withopen(path,"wb")asf:returnf.write(data)
@propertydefurl(self)->str:""" The URL of the asset Returns ------- `str` The URL of the asset """returnself._url@propertydefkey(self)->str:""" The key of the asset Returns ------- `str` The key of the asset """returnself._key
[docs]defis_animated(self)->bool:""" Whether the asset is animated or not Returns ------- `bool` Whether the asset is animated or not """returnself._animated