2020-01-04 02:46:12 +01:00
|
|
|
# Created by romain at 04/01/2020
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import discord
|
|
|
|
from discord.ext import commands
|
|
|
|
|
|
|
|
from bot import TuxBot
|
2020-01-04 21:16:37 +01:00
|
|
|
from utils import Texts
|
2020-01-04 02:46:12 +01:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class HelpCommand(commands.HelpCommand):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.ignore_cogs = ["Monitoring", "Help", "Logs"]
|
|
|
|
self.owner_cogs = []
|
|
|
|
|
|
|
|
async def send_bot_help(self, mapping):
|
2020-01-04 21:16:37 +01:00
|
|
|
owners = self.context.bot.owners
|
|
|
|
owners_name = [
|
|
|
|
f"{owner.name}#{owner.discriminator}"
|
|
|
|
for owner in owners
|
|
|
|
]
|
|
|
|
|
|
|
|
e = discord.Embed(
|
|
|
|
color=discord.colour.Color.blue(),
|
|
|
|
description=Texts(
|
|
|
|
'help', self.context
|
|
|
|
).get(
|
|
|
|
'main_page.description'
|
|
|
|
).format(
|
|
|
|
', '.join(owners_name[:-1]) + ' & ' + owners_name[-1]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
e.set_author(
|
|
|
|
icon_url=self.context.author.avatar_url_as(format='png'),
|
|
|
|
name=self.context.author
|
|
|
|
)
|
2020-01-04 02:46:12 +01:00
|
|
|
|
|
|
|
cogs = ""
|
|
|
|
for extension in self.context.bot.cogs.values():
|
2020-01-04 21:16:37 +01:00
|
|
|
if self.context.author not in owners \
|
|
|
|
and extension.qualified_name in self.owner_cogs:
|
2020-01-04 02:46:12 +01:00
|
|
|
continue
|
2020-01-04 21:16:37 +01:00
|
|
|
if self.context.author in owners \
|
|
|
|
and extension.qualified_name in self.ignore_cogs:
|
2020-01-04 02:46:12 +01:00
|
|
|
continue
|
|
|
|
if extension.qualified_name == "Jishaku":
|
|
|
|
continue
|
|
|
|
cogs += f"• {extension.icon} **{extension.qualified_name}**\n"
|
|
|
|
|
2020-01-04 21:16:37 +01:00
|
|
|
e.add_field(
|
|
|
|
name=Texts(
|
|
|
|
'help', self.context
|
|
|
|
).get(
|
|
|
|
'main_page.categories'
|
|
|
|
),
|
|
|
|
value=cogs
|
|
|
|
)
|
|
|
|
|
|
|
|
await self.context.send(embed=e)
|
2020-01-04 02:46:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Help(commands.Cog):
|
|
|
|
def __init__(self, bot: TuxBot):
|
|
|
|
bot.help_command = HelpCommand()
|
|
|
|
|
|
|
|
|
|
|
|
def setup(bot: TuxBot):
|
|
|
|
bot.add_cog(Help(bot))
|