-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.py
More file actions
76 lines (68 loc) · 2.48 KB
/
Copy pathhelp.py
File metadata and controls
76 lines (68 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import discord
from discord.ext import commands
import os
import dotenv
import asyncio
class CustomHelp(commands.HelpCommand):
EXCLUDED_COMMANDS = {"help"}
async def send_bot_help(self, mapping):
destination = self.get_destination()
embed = discord.Embed(
title="Help Categories",
description="Use `-help <category>` to see commands in a category.",
color=discord.Color.blue()
)
for cog, commands_list in mapping.items():
filtered = [
cmd for cmd in commands_list
if not cmd.hidden and cmd.name not in self.EXCLUDED_COMMANDS
]
if filtered:
cog_name = getattr(cog, "qualified_name", "No Category")
embed.add_field(
name=f"{cog_name}",
value=f"",
inline=True
)
await destination.send(embed=embed)
async def send_cog_help(self, cog):
destination = self.get_destination()
embed = discord.Embed(
title=f"{cog.qualified_name} (1/1)",
color=discord.Color.blue()
)
filtered = [
cmd for cmd in cog.get_commands()
if (
not cmd.hidden and
(cmd.short_doc or cmd.help)
)
]
for cmd in filtered:
params = [
f"[{name}]" for name, param in cmd.clean_params.items()
]
param_str = " " + " ".join(params) if params else ""
embed.add_field(
name=f"-{cmd.name}{param_str}",
value=cmd.short_doc or cmd.help,
inline=False
)
await destination.send(embed=embed)
def command_not_found(self, string: str, /) -> str:
return f"No category called `{string}` found."
maybe_coro = discord.utils.maybe_coroutine
# disable command
async def send_command_help(self, command):
destination = self.get_destination()
await destination.send(f"No category called `{command.name}` found.")
# disable command
async def send_group_help(self, group):
destination = self.get_destination()
await destination.send(f"No category called `{group.name}` found.")
def get_cog_case_insensitive(self, name):
name = name.lower()
for cog in self.cogs.values():
if cog.qualified_name.lower() == name:
return cog
return None