|
| 1 | +import random |
| 2 | +from datetime import datetime |
| 3 | +from typing import Union, Optional |
| 4 | + |
| 5 | +import discord |
| 6 | +from discord.ext import pages |
| 7 | +from discord.ext.bridge import BridgeContext |
| 8 | +from discord.embeds import Embed |
| 9 | + |
| 10 | + |
| 11 | +class Pagination(pages.Paginator): |
| 12 | + logo_path = "https://i.imgur.com/QMykWjw.png" |
| 13 | + |
| 14 | + async def respond( |
| 15 | + self, |
| 16 | + interaction: Union[discord.Interaction, BridgeContext], |
| 17 | + ephemeral: bool = False, |
| 18 | + target: Optional[discord.abc.Messageable] = None, |
| 19 | + target_message: str = "Paginator sent!", |
| 20 | + ) -> Union[discord.Message, discord.WebhookMessage]: |
| 21 | + for page in self.pages: |
| 22 | + if isinstance(page, Embed): |
| 23 | + if not isinstance(page.colour, discord.Colour): |
| 24 | + color = int("0x" + ''.join([random.choice('0123456789ABCDEF') for j in range(6)]), 16) |
| 25 | + page.colour = color |
| 26 | + page.set_footer(text="Made by Gccody") |
| 27 | + page.timestamp = datetime.now() |
| 28 | + continue |
| 29 | + |
| 30 | + for embed in page.embeds: |
| 31 | + if not isinstance(embed.colour, discord.Colour): |
| 32 | + color = int("0x" + ''.join([random.choice('0123456789ABCDEF') for j in range(6)]), 16) |
| 33 | + embed.colour = color |
| 34 | + embed.set_footer(text="Made by Gccody") |
| 35 | + embed.timestamp = datetime.now() |
| 36 | + |
| 37 | + return await super().respond(interaction, ephemeral, target, target_message) |
0 commit comments