diff --git a/gumo/api/core.py b/gumo/api/core.py index 8c56cad..2e57bc3 100644 --- a/gumo/api/core.py +++ b/gumo/api/core.py @@ -2,7 +2,6 @@ Define a client to interact with the Ori and the Blind Forest Randomizer API """ -import io import logging from urllib import parse import random @@ -119,11 +118,10 @@ async def get_seed(self, seed_name: str = None, logic_mode: str = None, key_mode seed_data = await self._get_seed_data(seed_name=seed_name, logic_mode=logic_mode, key_mode=key_mode, goal_mode=goal_mode, spawn=spawn, variations=variations, item_pool=item_pool, relic_count=relic_count) - seed_buffer = io.BytesIO(bytes(seed_data['players'][0]['seed'], encoding="utf8")) return { 'seed_header': seed_data['players'][0]['seed'].split("\n")[0], 'spoiler_url': f"{SEEDGEN_API_URL}{seed_data['players'][0]['spoiler_url']}", 'map_url': f"{SEEDGEN_API_URL}{seed_data['map_url']}", 'history_url': f"{SEEDGEN_API_URL}{seed_data['history_url']}", - 'seed_buffers': [seed_buffer] + 'seed_file_content': seed_data['players'][0]['seed'] } diff --git a/gumo/modules/league.py b/gumo/modules/league.py index 5adf58b..580e9a8 100644 --- a/gumo/modules/league.py +++ b/gumo/modules/league.py @@ -10,6 +10,7 @@ import logging from datetime import datetime, time, timedelta import functools +import io import os import random import re @@ -350,8 +351,9 @@ async def league_seed(self, interaction: discord.Interaction): interaction (discord.Interaction): discord interaction object """ await interaction.response.defer(ephemeral=True) - seed_files = [discord.File(sd, filename='randomizer.dat') for sd in self._seed_data['seed_buffers']] - return await interaction.followup.send(content=f"`{self._seed_data['seed_header']}`", files=seed_files) + seed_buffer = io.BytesIO(bytes(self._seed_data['seed_file_content'], encoding="utf8")) + seed_file = discord.File(seed_buffer, filename='randomizer.dat') + return await interaction.followup.send(content=f"`{self._seed_data['seed_header']}`", files=[seed_file]) async def _league_seed(self): """ diff --git a/gumo/modules/seed.py b/gumo/modules/seed.py index 3f63e5c..fe09dd4 100644 --- a/gumo/modules/seed.py +++ b/gumo/modules/seed.py @@ -4,6 +4,7 @@ - "/daily": the default seed generation command, forcing the seed name to the current date YYYY-MM-DD. """ +import io import logging from datetime import datetime from typing import Optional @@ -76,8 +77,8 @@ async def seed(self, interaction: discord.Interaction, await interaction.response.defer() seed_settings = {s[0]: s[1] for s in interaction.namespace if not s[0].startswith('variation')} variations = (s[1] for s in interaction.namespace if s[0].startswith('variation')) - message, files = await self._get_seed_message(**seed_settings, variations=variations) - return await interaction.followup.send(content=message, files=files) + message, file = await self._get_seed_message(**seed_settings, variations=variations) + return await interaction.followup.send(content=message, files=[file]) @app_commands.command(name='daily') @app_commands.describe(logic_mode="Randomizer logic mode") @@ -153,12 +154,13 @@ async def _get_seed_message(self, seed_name: str = None, logic_mode: str = None, seed_data = await self.api_client.get_seed(seed_name=seed_name, logic_mode=logic_mode, key_mode=key_mode, goal_mode=goal_mode, spawn=spawn, variations=variations, item_pool=item_pool, relic_count=relic_count) - seed_files = [discord.File(sd, filename='randomizer.dat') for sd in seed_data['seed_buffers']] + seed_buffer = io.BytesIO(bytes(seed_data['seed_file_content'], encoding="utf8")) + seed_file = discord.File(seed_buffer, filename='randomizer.dat') message = f"`{seed_data['seed_header']}`\n" \ f"**Spoiler**: [link]({seed_data['spoiler_url']})\n" \ f"**Map**: [link]({seed_data['map_url']})\n" \ f"**History**: [link]({seed_data['history_url']})" - return message, seed_files + return message, seed_file @seed.error @daily.error