-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathhelp_command.py
More file actions
102 lines (79 loc) · 3.48 KB
/
help_command.py
File metadata and controls
102 lines (79 loc) · 3.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import discord
from discord.ext import commands
bot_links = """[Support](https://discord.gg/KgZRMch3b6)\u2800\
[Github](https://github.com/FalseDev/Tech-struck)\u2800\
[Suggestions](https://github.com/FalseDev/Tech-struck/issues)"""
class HelpCommand(commands.HelpCommand):
"""
An Embed help command
Based on https://gist.github.com/Rapptz/31a346ed1eb545ddeb0d451d81a60b3b
"""
COLOUR = discord.Colour.greyple()
def get_ending_note(self):
return "Use {0}{1} [command] for more info on a command.".format(
self.clean_prefix, self.invoked_with
)
def get_command_signature(self, command):
return "{0.qualified_name} {0.signature}".format(command)
async def send_bot_help(self, mapping):
embed = discord.Embed(title="Bot Commands", colour=self.COLOUR)
if description := self.context.bot.description:
embed.description = description
for cog, cmds in mapping.items():
if cog is None:
continue
name = cog.qualified_name
filtered = await self.filter_commands(cmds, sort=True)
if filtered:
value = "\u2002".join(f"`{c.name}`" for c in cmds)
if cog and cog.description:
value = "{0}\n{1}".format(cog.description, value)
embed.add_field(name=name, value=value)
embed.set_footer(text=self.get_ending_note())
self.add_support_server(embed)
await self.get_destination().send(embed=embed)
async def send_cog_help(self, cog):
embed = discord.Embed(
title="{0.qualified_name} Commands".format(cog), colour=self.COLOUR
)
if cog.description:
embed.description = cog.description
filtered = await self.filter_commands(cog.get_commands(), sort=True)
for command in filtered:
embed.add_field(
name=command.qualified_name,
value=command.short_doc or "...",
inline=False,
)
embed.set_footer(text=self.get_ending_note())
self.add_support_server(embed)
await self.get_destination().send(embed=embed)
async def send_group_help(self, group):
embed = discord.Embed(title=group.qualified_name, colour=self.COLOUR)
if group.help:
embed.description = group.help
filtered = await self.filter_commands(group.commands, sort=True)
for command in filtered:
embed.add_field(
name=command.qualified_name,
value=command.short_doc or "...",
inline=False,
)
embed.set_footer(text=self.get_ending_note())
self.add_support_server(embed)
await self.get_destination().send(embed=embed)
def add_support_server(self, embed):
return embed.add_field(name="Links", value=bot_links, inline=False)
async def send_command_help(self, command):
embed = discord.Embed(title=command.qualified_name, colour=self.COLOUR)
embed.add_field(name="Signatute", value=self.get_command_signature(command))
if command.help:
embed.description = command.help
embed.set_footer(text=self.get_ending_note())
self.add_support_server(embed)
await self.get_destination().send(embed=embed)
def setup(bot: commands.Bot):
bot._default_help_command = bot.help_command
bot.help_command = HelpCommand()
def teardown(bot):
bot.help_command = bot._default_help_command