mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Show list of custom commands
This commit is contained in:
parent
a310d1696c
commit
7847cc1d29
11 changed files with 57 additions and 7 deletions
0
data/menus/__init__.py
Normal file
0
data/menus/__init__.py
Normal file
21
data/menus/custom_commands.py
Normal file
21
data/menus/custom_commands.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import discord
|
||||
from discord.ext import menus
|
||||
|
||||
|
||||
class CommandsList(menus.ListPageSource):
|
||||
def __init__(self, data, colour=discord.Colour.blue()):
|
||||
super().__init__(data, per_page=15)
|
||||
self.colour = colour
|
||||
|
||||
async def format_page(self, menu: menus.MenuPages, entries):
|
||||
embed = discord.Embed(colour=self.colour)
|
||||
embed.set_author(name="Custom Commands")
|
||||
embed.description = "\n".join(entries)
|
||||
embed.set_footer(text="{}/{}".format(menu.current_page + 1, self.get_max_pages()))
|
||||
|
||||
return embed
|
||||
|
||||
|
||||
class Pages(menus.MenuPages):
|
||||
def __init__(self, source, clear_reactions_after, timeout=30.0):
|
||||
super().__init__(source, timeout=timeout, delete_message_after=True, clear_reactions_after=clear_reactions_after)
|
||||
31
data/menus/paginatedLeaderboard.py
Normal file
31
data/menus/paginatedLeaderboard.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import discord
|
||||
from discord.ext import menus
|
||||
|
||||
|
||||
# https://github.com/Rapptz/discord-ext-menus
|
||||
class Source(menus.ListPageSource):
|
||||
def __init__(self, data, name, colour=discord.Colour.blue()):
|
||||
super().__init__(data, per_page=10)
|
||||
self.name = name
|
||||
self.colour = colour
|
||||
|
||||
async def format_page(self, menu: menus.MenuPages, entries):
|
||||
offset = menu.current_page * self.per_page
|
||||
|
||||
description = ""
|
||||
for i, v in enumerate(entries, start=offset):
|
||||
# Check if the person's name has to be highlighted
|
||||
if v.startswith("**") and v.endswith("**"):
|
||||
description += "**"
|
||||
v = v[2:]
|
||||
description += "{}: {}\n".format(i + 1, v)
|
||||
embed = discord.Embed(colour=self.colour)
|
||||
embed.set_author(name=self.name)
|
||||
embed.description = description
|
||||
embed.set_footer(text="{}/{}".format(menu.current_page + 1, self.get_max_pages()))
|
||||
return embed
|
||||
|
||||
|
||||
class Pages(menus.MenuPages):
|
||||
def __init__(self, source, clear_reactions_after, timeout=30.0):
|
||||
super().__init__(source, timeout=timeout, delete_message_after=True, clear_reactions_after=clear_reactions_after)
|
||||
28
data/menus/storePages.py
Normal file
28
data/menus/storePages.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import discord
|
||||
from discord.ext import menus
|
||||
|
||||
|
||||
# https://github.com/Rapptz/discord-ext-menus
|
||||
class Source(menus.ListPageSource):
|
||||
def __init__(self, data):
|
||||
super().__init__(data, per_page=10)
|
||||
self.name = "Didier Store"
|
||||
self.colour = discord.Colour.blue()
|
||||
|
||||
async def format_page(self, menu: menus.MenuPages, entries):
|
||||
offset = menu.current_page * self.per_page
|
||||
|
||||
embed = discord.Embed(colour=self.colour)
|
||||
embed.set_author(name=self.name)
|
||||
embed.description = "Heb je een idee voor een item? DM DJ STIJN met je idee!"
|
||||
embed.set_footer(text="{}/{}".format(menu.current_page + 1, self.get_max_pages()))
|
||||
|
||||
for i, v in enumerate(entries, start=offset):
|
||||
embed.add_field(name="#{} - {}".format(v[0], v[1]), value="{:,} Didier Dinks".format(v[2]))
|
||||
|
||||
return embed
|
||||
|
||||
|
||||
class Pages(menus.MenuPages):
|
||||
def __init__(self, source, clear_reactions_after, timeout=30.0):
|
||||
super().__init__(source, timeout=timeout, delete_message_after=True, clear_reactions_after=clear_reactions_after)
|
||||
Loading…
Add table
Add a link
Reference in a new issue