mirror of https://github.com/stijndcl/didier
				
				
				
			Show list of custom commands
							parent
							
								
									a310d1696c
								
							
						
					
					
						commit
						7847cc1d29
					
				| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
from data import paginatedLeaderboard
 | 
					from data.menus import paginatedLeaderboard
 | 
				
			||||||
from decorators import help
 | 
					from decorators import help
 | 
				
			||||||
import discord
 | 
					import discord
 | 
				
			||||||
from discord.ext import commands
 | 
					from discord.ext import commands
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
from data import paginatedLeaderboard
 | 
					from data.menus import paginatedLeaderboard
 | 
				
			||||||
from decorators import help
 | 
					from decorators import help
 | 
				
			||||||
import discord
 | 
					import discord
 | 
				
			||||||
from discord.ext import commands
 | 
					from discord.ext import commands
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,11 +5,10 @@ from discord.ext import commands
 | 
				
			||||||
from enums.help_categories import Category
 | 
					from enums.help_categories import Category
 | 
				
			||||||
from functions import checks, config, timeFormatters
 | 
					from functions import checks, config, timeFormatters
 | 
				
			||||||
from functions.database import memes, githubs, twitch, dadjoke
 | 
					from functions.database import memes, githubs, twitch, dadjoke
 | 
				
			||||||
 | 
					from functions.database.custom_commands import add_command, add_alias
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from functions.database.custom_commands import is_name_free, add_command, add_alias
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ModCommands(commands.Cog):
 | 
					class ModCommands(commands.Cog):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					from discord.ext import commands
 | 
				
			||||||
 | 
					from data.menus import custom_commands
 | 
				
			||||||
 | 
					from decorators import help
 | 
				
			||||||
 | 
					from enums.help_categories import Category
 | 
				
			||||||
 | 
					from functions.database.custom_commands import get_all
 | 
				
			||||||
 | 
					from functions.stringFormatters import capitalize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Other(commands.Cog):
 | 
				
			||||||
 | 
					    def __init__(self, client):
 | 
				
			||||||
 | 
					        self.client = client
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Don't allow any commands to work when locked
 | 
				
			||||||
 | 
					    def cog_check(self, ctx):
 | 
				
			||||||
 | 
					        return not self.client.locked
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @commands.command(name="Custom")
 | 
				
			||||||
 | 
					    @help.Category(category=Category.Didier)
 | 
				
			||||||
 | 
					    async def list_custom(self, ctx):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Get a list of all custom commands
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        all_commands = get_all()
 | 
				
			||||||
 | 
					        formatted = list(sorted(map(lambda x: capitalize(x["name"]), all_commands)))
 | 
				
			||||||
 | 
					        src = custom_commands.CommandsList(formatted)
 | 
				
			||||||
 | 
					        await custom_commands.Pages(source=src, clear_reactions_after=True).start(ctx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def setup(client):
 | 
				
			||||||
 | 
					    client.add_cog(Other(client))
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
from converters.numbers import Abbreviated
 | 
					from converters.numbers import Abbreviated
 | 
				
			||||||
from data import storePages
 | 
					from data.menus import storePages
 | 
				
			||||||
from decorators import help
 | 
					from decorators import help
 | 
				
			||||||
import discord
 | 
					import discord
 | 
				
			||||||
from discord.ext import commands
 | 
					from discord.ext import commands
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
from data import paginatedLeaderboard
 | 
					from data.menus import paginatedLeaderboard
 | 
				
			||||||
import datetime
 | 
					 | 
				
			||||||
from decorators import help
 | 
					from decorators import help
 | 
				
			||||||
import discord
 | 
					import discord
 | 
				
			||||||
from discord.ext import commands, menus
 | 
					from discord.ext import commands, menus
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
				
			||||||
| 
						 | 
					@ -33,6 +33,7 @@
 | 
				
			||||||
  "config": "Past constanten in het config bestand aan.",
 | 
					  "config": "Past constanten in het config bestand aan.",
 | 
				
			||||||
  "corona": "Coronatracker voor [Land].\nIndien je geen land opgeeft is dit standaard België.\nCorona Global voor wereldwijde cijfers.",
 | 
					  "corona": "Coronatracker voor [Land].\nIndien je geen land opgeeft is dit standaard België.\nCorona Global voor wereldwijde cijfers.",
 | 
				
			||||||
  "corona vaccinations": "Vaccinatiecijfers voor België.",
 | 
					  "corona vaccinations": "Vaccinatiecijfers voor België.",
 | 
				
			||||||
 | 
					  "custom": "Geeft een lijst van custom commands. Didier > Dyno confirmed once more.",
 | 
				
			||||||
  "dadjoke": "Didier vertelt een dad joke.",
 | 
					  "dadjoke": "Didier vertelt een dad joke.",
 | 
				
			||||||
  "define": "Geeft de definitie van [Woord] zoals het in de Urban Dictionary staat.\nZoektermen met spaties moeten **niet** tussen aanhalingstekens staan.",
 | 
					  "define": "Geeft de definitie van [Woord] zoals het in de Urban Dictionary staat.\nZoektermen met spaties moeten **niet** tussen aanhalingstekens staan.",
 | 
				
			||||||
  "detect": "Didier probeert de taal van [Tekst] te detecteren.",
 | 
					  "detect": "Didier probeert de taal van [Tekst] te detecteren.",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue