didier/data/menus/custom_commands.py

19 lines
660 B
Python
Raw Normal View History

from typing import Union
2021-06-19 23:08:42 +02:00
from discord import ApplicationContext
from discord.ext.commands import Context
2021-06-19 23:08:42 +02:00
from data.menus.paginated import Paginated
from functions.database.custom_commands import get_all
from functions.stringFormatters import capitalize
2021-06-19 23:08:42 +02:00
class CommandsList(Paginated):
def __init__(self, ctx: Union[ApplicationContext, Context]):
all_commands = get_all()
commands_sorted = list(sorted(map(lambda x: (capitalize(x["name"]),), all_commands)))
super().__init__(ctx=ctx, title="Custom Commands", data=commands_sorted, per_page=15)
2021-06-19 23:08:42 +02:00
def format_entry(self, index: int, value: tuple) -> str:
return value[0]