Removed personal settings from help module

master
Jef Roosens 2020-08-26 13:48:41 +02:00
parent 491bb74768
commit 0afb14203e
2 changed files with 14 additions and 21 deletions

View File

@ -52,7 +52,7 @@ Frank.
pass pass
@frank.default() @frank.default()
async def default_cmd(prefix, author, channel, mid): async def default_cmd(self):
# do some default action # do some default action
pass pass
``` ```

View File

@ -3,10 +3,10 @@
from __future__ import annotations from __future__ import annotations
# Third-party imports # Third-party imports
import discord from discord import Embed
# Own imports # Own imports
from suzybot.frank import Module, default, command from .. import Module, default, regex_command
# Typing imports # Typing imports
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -28,38 +28,31 @@ class HelpMod(Module):
NAME = 'help' NAME = 'help'
HELP = 'Shows help info about all modules' HELP = 'Shows help info about all modules'
def pre_start(self):
self.theme = discord.Color.dark_green()
@default(help_str='Show help about all modules.') @default(help_str='Show help about all modules.')
async def send_all(self, author: User, channel: Messageable, mid: int): async def send_all(self, author: User, channel: Messageable, mid: int):
embed = discord.Embed(colour=self.theme) embed = Embed()
embed.set_author(name='Suzy')
for mod in self._client._modules: for mod in self._client._modules:
embed.add_field(name=mod.NAME, value=mod.HELP, inline=False) embed.add_field(name=mod.NAME, value=mod.HELP, inline=False)
await channel.send(embed=embed) await channel.send(embed=embed)
@command(cmd='.+', help_str='Show help about a certain module.') @regex_command(cmd='.+', help_str='Show help about a certain module.')
async def show_module_help(self, cmd: List[str], author: User, async def show_module_help(self, prefix: str, cmd: List[str], author: User,
channel: Messageable, mid: int): channel: Messageable, mid: int):
# Exit if no arguments are given # Yes, this command just ignores cmd at the moment
if not cmd: mod_name = prefix.lower()
return
mod_name = cmd[0].lower()
mod = next((mod for mod in self._client._modules mod = next((mod for mod in self._client._modules
if mod.NAME.lower() == mod_name), None) if mod.NAME.lower() == mod_name), None)
if mod: if mod:
embed = discord.Embed(colour=self.theme) embed = Embed()
if mod._DEFAULT: if mod.default:
embed.add_field(name='default', value=mod._help, inline=False) embed.add_field(name='default', value=mod.default.help_str,
for cmd in mod._COMMANDS:
embed.add_field(name=cmd._command, value=mod._help,
inline=False) inline=False)
for cmd in mod._COMMANDS:
embed.add_field(name=cmd.cmd, value=mod.help_str, inline=False)
await channel.send(embed=embed) await channel.send(embed=embed)