Skip to content

Commit 43ea713

Browse files
committed
Updated to latest HelpFormatter
1 parent 72090bf commit 43ea713

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

cogs/encryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ async def encode(self, ctx):
1414
""" All encode methods """
1515
if ctx.invoked_subcommand is None:
1616
help_cmd = self.bot.get_command('help')
17-
await ctx.invoke(help_cmd, 'encode')
17+
await ctx.invoke(help_cmd, command=str(ctx.command))
1818

1919
@commands.group()
2020
async def decode(self, ctx):
2121
""" All decode methods """
2222
if ctx.invoked_subcommand is None:
2323
help_cmd = self.bot.get_command('help')
24-
await ctx.invoke(help_cmd, 'decode')
24+
await ctx.invoke(help_cmd, command=str(ctx.command))
2525

2626
async def encryptout(self, ctx, convert, input):
2727
if len(input) > 1900:

cogs/mod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ async def prune(self, ctx):
184184

185185
if ctx.invoked_subcommand is None:
186186
help_cmd = self.bot.get_command('help')
187-
await ctx.invoke(help_cmd, 'remove')
187+
await ctx.invoke(help_cmd, command=str(ctx.command))
188188

189189
async def do_removal(self, ctx, limit, predicate, *, before=None, after=None, message=True):
190190
if limit > 2000:

index.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
2+
import discord
23

3-
from discord.ext.commands import HelpFormatter
4+
from discord.ext.commands import DefaultHelpCommand
45
from data import Bot
56
from utils import permissions, default
67

@@ -11,17 +12,31 @@
1112
"""
1213

1314

14-
class HelpFormat(HelpFormatter):
15-
async def format_help_for(self, context, command_or_bot):
16-
if permissions.can_react(context):
17-
await context.message.add_reaction(chr(0x2709))
15+
class HelpFormat(DefaultHelpCommand):
16+
async def get_destination(self, local=False):
17+
try:
18+
if permissions.can_react(self.context):
19+
await self.context.message.add_reaction(chr(0x2709))
20+
except discord.Forbidden:
21+
pass
1822

19-
return await super().format_help_for(context, command_or_bot)
23+
if local:
24+
return self.context.channel
25+
else:
26+
return self.context.author
27+
28+
async def send_pages(self):
29+
destination = await self.get_destination()
30+
try:
31+
for page in self.paginator.pages:
32+
await destination.send(page)
33+
except discord.Forbidden:
34+
destination = await self.get_destination(local=True)
35+
await destination.send("Couldn't send help to you due to blocked DMs...")
2036

2137

2238
print("Logging in...")
23-
help_attrs = dict(hidden=True)
24-
bot = Bot(command_prefix=config.prefix, prefix=config.prefix, pm_help=True, help_attrs=help_attrs, formatter=HelpFormat())
39+
bot = Bot(command_prefix=config.prefix, prefix=config.prefix, command_attrs=dict(hidden=True), help_command=HelpFormat())
2540

2641
for file in os.listdir("cogs"):
2742
if file.endswith(".py"):

0 commit comments

Comments
 (0)