Skip to content

Commit d220937

Browse files
committed
misc help and return user_typing
1 parent 60b5eb1 commit d220937

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
2121
- Added a minimalistic version of requirements.txt (named requirements.min.txt) that contains only the absolute minimum of Modmail.
2222
- For users having trouble with pipenv or any other reason.
2323
- Multi-step alias, see `?help alias add`. Public beta testing, might be unstable.
24+
- Misc commands without cogs are now displayed in `?help`.
2425

2526
### Changes
2627

@@ -38,7 +39,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
3839

3940
- `?notify` no longer carries over to the next thread.
4041
- `discord.NotFound` errors for `on_raw_reaction_add`.
41-
- `mod_typing` and `user_typing` will no longer show when user is blocked.
42+
- `mod_typing` ~~and `user_typing`~~ (`user_typing` is by-design to show now) will no longer show when user is blocked.
4243
- Better `?block` usage message.
4344
- Resolves errors when message was sent by mods after thread is closed somehow.
4445
- Recipient join/leave server messages are limited to only the guild set by `GUILD_ID`.

bot.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -838,13 +838,6 @@ async def _void(*_args, **_kwargs):
838838
pass
839839

840840
if isinstance(channel, discord.DMChannel):
841-
if await self._process_blocked(
842-
SimpleNamespace(
843-
author=user, channel=SimpleNamespace(send=_void), add_reaction=_void
844-
)
845-
):
846-
return
847-
848841
try:
849842
user_typing = strtobool(self.config["user_typing"])
850843
except ValueError:

cogs/utility.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939

4040

4141
class ModmailHelpCommand(commands.HelpCommand):
42-
async def format_cog_help(self, cog):
42+
async def format_cog_help(self, cog, *, no_cog=False):
4343
bot = self.context.bot
4444
prefix = self.clean_prefix
4545

4646
formats = [""]
4747
for cmd in await self.filter_commands(
48-
cog.get_commands(), sort=True, key=get_perm_level
48+
cog.get_commands() if not no_cog else cog, sort=True, key=get_perm_level
4949
):
5050
perm_level = get_perm_level(cmd)
5151
if perm_level is PermissionLevel.INVALID:
@@ -63,16 +63,19 @@ async def format_cog_help(self, cog):
6363

6464
embeds = []
6565
for format_ in formats:
66+
description = cog.description or "No description." \
67+
if not no_cog else "Miscellaneous commands without a category."
6668
embed = Embed(
67-
description=f'*{cog.description or "No description."}*',
69+
description=f'*{description}*',
6870
color=bot.main_color,
6971
)
7072

7173
embed.add_field(name="Commands", value=format_ or "No commands.")
7274

7375
continued = " (Continued)" if embeds else ""
76+
name = cog.qualified_name + " - Help" if not no_cog else "Miscellaneous Commands"
7477
embed.set_author(
75-
name=cog.qualified_name + " - Help" + continued,
78+
name=name + continued,
7679
icon_url=bot.user.avatar_url,
7780
)
7881

@@ -88,9 +91,8 @@ def process_help_msg(self, help_: str):
8891

8992
async def send_bot_help(self, mapping):
9093
embeds = []
91-
# TODO: Implement for no cog commands
92-
93-
cogs = list(filter(None, mapping))
94+
no_cog_commands = sorted(mapping.pop(None), key=lambda c: c.qualified_name)
95+
cogs = sorted(mapping, key=lambda c: c.qualified_name)
9496

9597
bot = self.context.bot
9698

@@ -105,6 +107,8 @@ async def send_bot_help(self, mapping):
105107

106108
for cog in default_cogs:
107109
embeds.extend(await self.format_cog_help(cog))
110+
if no_cog_commands:
111+
embeds.extend(await self.format_cog_help(no_cog_commands, no_cog=True))
108112

109113
p_session = PaginatorSession(
110114
self.context, *embeds, destination=self.get_destination()

core/config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class ConfigManager:
115115

116116
def __init__(self, bot):
117117
self.bot = bot
118-
self.api = self.bot.api
119118
self._cache = {}
120119
self.ready_event = asyncio.Event()
121120

@@ -207,11 +206,11 @@ async def clean_data(self, key: str, val: typing.Any) -> typing.Tuple[str, str]:
207206

208207
async def update(self):
209208
"""Updates the config with data from the cache"""
210-
await self.api.update_config(self.filter_default(self._cache))
209+
await self.bot.api.update_config(self.filter_default(self._cache))
211210

212211
async def refresh(self) -> dict:
213212
"""Refreshes internal cache with data from database"""
214-
for k, v in (await self.api.get_config()).items():
213+
for k, v in (await self.bot.api.get_config()).items():
215214
k = k.lower()
216215
if k in self.all_keys:
217216
self._cache[k] = v

core/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import discord
99
from discord.ext import commands
1010

11-
from core.models import PermissionLevel
12-
1311

1412
def strtobool(val):
1513
if isinstance(val, bool):
@@ -194,7 +192,9 @@ def match_user_id(text: str) -> int:
194192
return -1
195193

196194

197-
def get_perm_level(cmd) -> PermissionLevel:
195+
def get_perm_level(cmd):
196+
from core.models import PermissionLevel
197+
198198
for check in cmd.checks:
199199
perm = getattr(check, "permission_level", None)
200200
if perm is not None:

0 commit comments

Comments
 (0)