|
1 | 1 | import os |
| 2 | +import discord |
2 | 3 |
|
3 | | -from discord.ext.commands import HelpFormatter |
| 4 | +from discord.ext.commands import DefaultHelpCommand |
4 | 5 | from data import Bot |
5 | 6 | from utils import permissions, default |
6 | 7 |
|
|
11 | 12 | """ |
12 | 13 |
|
13 | 14 |
|
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 |
18 | 22 |
|
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...") |
20 | 36 |
|
21 | 37 |
|
22 | 38 | 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()) |
25 | 40 |
|
26 | 41 | for file in os.listdir("cogs"): |
27 | 42 | if file.endswith(".py"): |
|
0 commit comments