Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: '_io.BytesIO' object has no attribute 'name' in paginator #1869

Merged
merged 10 commits into from
Jan 11, 2023
5 changes: 4 additions & 1 deletion discord/ext/pages/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from io import BufferedReader
from typing import Dict, List, Optional, Union

import discord
Expand Down Expand Up @@ -166,10 +167,12 @@ async def callback(self, interaction: Optional[discord.Interaction] = None):
"""

def update_files(self) -> Optional[List[discord.File]]:
"""Updates the files associated with the page by re-uploading them.
"""If possible, it updates the files associated with the page by re-uploading them.
Typically used when the page is changed.
"""
for file in self._files:
if not isinstance(file.fp, BufferedReader):
continue
with open(file.fp.name, "rb") as fp: # type: ignore
self._files[self._files.index(file)] = discord.File(
fp, # type: ignore
Expand Down