Skip to content

Commit 9d4fb27

Browse files
committed
v3.2.0 dev
1 parent 91c7418 commit 9d4fb27

File tree

10 files changed

+331
-125
lines changed

10 files changed

+331
-125
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
56
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
67
however, insignificant breaking changes does not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319).
78

9+
# v3.2.0
10+
11+
### Added
12+
13+
- Ability to change permission levels of individual commands.
14+
- See `?permissions override` for more information.
15+
16+
### Fixed
17+
18+
- `?help <some sub command>`, will return `Perhaps you meant: <some sub command>`, now its fixed.
19+
- For example, `?help add` used to return `Perhaps you meant: add`, now it wouldn't do this.
20+
- Aliases and Permissions command names are always saved lowercase now.
21+
22+
### Internal
23+
24+
- Use regex to parse Changes, Added, Fixed, etc and description.
25+
826
# v3.1.1
927

1028
### Fixed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ This list is ever-growing thanks to active development and our exceptional contr
8282

8383
## Installation
8484

85-
Where is the Modmail bot invite link? Unfortunately, due to how this bot functions, it cannot be invited. This is to ensure the individuality to your server and grant you full control over your bot and data. Nonetheless, you can easily obtain a free copy of Modmail for your server by following one of the methods listed below (roughly takes 15 minutes of your time):
85+
Where can I find the Modmail bot invite link?
86+
87+
Unfortunately, due to how this bot functions, it cannot be invited. This is to ensure the individuality to your server and grant you full control over your bot and data. Nonetheless, you can easily obtain a free copy of Modmail for your server by following one of the methods listed below (roughly takes 15 minutes of your time)...
8688

8789
### Heroku
8890

@@ -104,7 +106,7 @@ If you don't want to go through the trouble of setting up your very own Modmail
104106

105107
### Locally
106108

107-
Local hosting of Modmail is also possible, first you will need [`python 3.7`](https://www.python.org/downloads/).
109+
Local hosting of Modmail is also possible, first you will need [`Python 3.7`](https://www.python.org/downloads/).
108110

109111
Follow the [**installation guide**](https://github.com/kyb3r/modmail/wiki/Installation) and disregard deploying the Heroku bot application. If you run into any problems, join our [Modmail Discord Server](https://discord.gg/etJNHCQ) for help and support.
110112

bot.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.1.1"
1+
__version__ = "3.2.0"
22

33
import asyncio
44
import logging
@@ -382,6 +382,34 @@ def recipient_color(self) -> int:
382382
def main_color(self) -> int:
383383
return self._parse_color("main_color")
384384

385+
def command_perm(self, command_name: str) -> PermissionLevel:
386+
level = self.config["override_command_level"].get(command_name)
387+
if level is not None:
388+
try:
389+
return PermissionLevel[level.upper()]
390+
except KeyError:
391+
logger.warning(
392+
"Invalid override_command_level for command %s.", command_name
393+
)
394+
self.config["override_command_level"].pop(command_name)
395+
396+
command = self.get_command(command_name)
397+
if command is None:
398+
logger.debug("Command %s not found.", command_name)
399+
return PermissionLevel.INVALID
400+
level = next(
401+
(
402+
check.permission_level
403+
for check in command.checks
404+
if hasattr(check, "permission_level")
405+
),
406+
None,
407+
)
408+
if level is None:
409+
logger.debug("Command %s does not have a permission level.", command_name)
410+
return PermissionLevel.INVALID
411+
return level
412+
385413
async def on_connect(self):
386414
logger.line()
387415
try:
@@ -1039,12 +1067,23 @@ async def on_command_error(self, context, exception):
10391067
await context.send_help(context.command)
10401068
elif isinstance(exception, commands.CheckFailure):
10411069
for check in context.command.checks:
1042-
if not await check(context) and hasattr(check, "fail_msg"):
1043-
await context.send(
1044-
embed=discord.Embed(
1045-
color=discord.Color.red(), description=check.fail_msg
1070+
if not await check(context):
1071+
if hasattr(check, "fail_msg"):
1072+
await context.send(
1073+
embed=discord.Embed(
1074+
color=discord.Color.red(), description=check.fail_msg
1075+
)
1076+
)
1077+
if hasattr(check, 'permission_level'):
1078+
corrected_permission_level = self.command_perm(
1079+
context.command.qualified_name
1080+
)
1081+
logger.warning(
1082+
"User %s does not have permission to use this command: `%s` (%s).",
1083+
context.author.name,
1084+
context.command.qualified_name,
1085+
corrected_permission_level.name,
10461086
)
1047-
)
10481087
logger.warning("CheckFailure: %s", exception)
10491088
else:
10501089
logger.error("Unexpected exception:", exc_info=exception)

cogs/modmail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,10 @@ async def blocked(self, ctx):
912912
line = mention + f" - `{reason or 'No reason provided'}`\n"
913913
if len(embed.description) + len(line) > 2048:
914914
embed = discord.Embed(
915-
title="Blocked Users (Continued)",
916-
color=self.bot.main_color,
917-
description=line,
918-
)
915+
title="Blocked Users (Continued)",
916+
color=self.bot.main_color,
917+
description=line,
918+
)
919919
embeds.append(embed)
920920
else:
921921
embed.description += line

0 commit comments

Comments
 (0)