Skip to content

Commit b69afd7

Browse files
committed
Make default cogs always appear first,
1 parent b0b2638 commit b69afd7

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

cogs/utility.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,24 @@ async def format_cog_help(self, cog):
7878
def process_help_msg(self, help_: str):
7979
return help_.format(prefix=self.clean_prefix) if help_ else "No help message."
8080

81-
async def send_bot_help(self, mapping):
81+
async def send_bot_help(self, cogs):
8282
embeds = []
8383
# TODO: Implement for no cog commands
84-
for cog in sorted(
85-
(key for key in mapping.keys() if key is not None),
86-
key=lambda c: c.qualified_name,
87-
):
84+
85+
cogs = list(filter(None, cogs))
86+
87+
bot = self.context.bot
88+
89+
# always come first
90+
default_cogs = [
91+
bot.get_cog("Modmail"),
92+
bot.get_cog("Utility"),
93+
bot.get_cog("Plugins"),
94+
]
95+
96+
default_cogs.extend(c for c in cogs if c not in default_cogs)
97+
98+
for cog in default_cogs:
8899
embeds.extend(await self.format_cog_help(cog))
89100

90101
p_session = PaginatorSession(
@@ -285,11 +296,12 @@ async def sponsors(self, ctx):
285296
async def debug(self, ctx):
286297
"""Shows the recent application-logs of the bot."""
287298

288-
log_file_name = self.bot.config.token.split('.')[0]
299+
log_file_name = self.bot.config.token.split(".")[0]
289300

290301
with open(
291302
os.path.join(
292-
os.path.dirname(os.path.abspath(__file__)), f"../temp/{log_file_name}.log"
303+
os.path.dirname(os.path.abspath(__file__)),
304+
f"../temp/{log_file_name}.log",
293305
),
294306
"r+",
295307
) as f:
@@ -340,11 +352,12 @@ async def debug_hastebin(self, ctx):
340352
"""Posts application-logs to Hastebin."""
341353

342354
haste_url = os.environ.get("HASTE_URL", "https://hasteb.in")
343-
log_file_name = self.bot.config.token.split('.')[0]
355+
log_file_name = self.bot.config.token.split(".")[0]
344356

345357
with open(
346358
os.path.join(
347-
os.path.dirname(os.path.abspath(__file__)), f"../temp/{log_file_name}.log"
359+
os.path.dirname(os.path.abspath(__file__)),
360+
f"../temp/{log_file_name}.log",
348361
),
349362
"r+",
350363
) as f:
@@ -376,11 +389,12 @@ async def debug_hastebin(self, ctx):
376389
async def debug_clear(self, ctx):
377390
"""Clears the locally cached logs."""
378391

379-
log_file_name = self.bot.config.token.split('.')[0]
392+
log_file_name = self.bot.config.token.split(".")[0]
380393

381394
with open(
382395
os.path.join(
383-
os.path.dirname(os.path.abspath(__file__)), f"../temp/{log_file_name}.log"
396+
os.path.dirname(os.path.abspath(__file__)),
397+
f"../temp/{log_file_name}.log",
384398
),
385399
"w",
386400
):
@@ -1362,9 +1376,11 @@ async def oauth_whitelist(self, ctx, target: Union[User, Role]):
13621376
embed = Embed(color=self.bot.main_color)
13631377
embed.title = "Success"
13641378

1365-
if not hasattr(target, 'mention'):
1366-
target = self.bot.get_user(target.id) or self.bot.modmail_guild.get_role(target.id)
1367-
1379+
if not hasattr(target, "mention"):
1380+
target = self.bot.get_user(target.id) or self.bot.modmail_guild.get_role(
1381+
target.id
1382+
)
1383+
13681384
embed.description = (
13691385
f"{'Un-w' if removed else 'W'}hitelisted " f"{target.mention} to view logs."
13701386
)

0 commit comments

Comments
 (0)