-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
48 lines (37 loc) · 1.6 KB
/
data.py
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
import discord
from utils import permissions
from discord.ext.commands import AutoShardedBot, DefaultHelpCommand
class Bot(AutoShardedBot):
def __init__(self, *args, prefix=None, **kwargs):
super().__init__(*args, **kwargs)
self.prefix = prefix
async def on_message(self, msg):
if not self.is_ready() or msg.author.bot or not permissions.can_handle(msg, "send_messages"):
return
await self.process_commands(msg)
class HelpFormat(DefaultHelpCommand):
def get_destination(self, no_pm: bool = False):
if no_pm:
return self.context.channel
else:
return self.context.author
async def send_error_message(self, error):
destination = self.get_destination(no_pm=True)
await destination.send(error)
async def send_command_help(self, command):
self.add_command_formatting(command)
self.paginator.close_page()
await self.send_pages(no_pm=True)
async def send_pages(self, no_pm: bool = False):
try:
if permissions.can_handle(self.context, "add_reactions"):
await self.context.message.add_reaction(chr(0x2709))
except discord.Forbidden:
pass
try:
destination = self.get_destination(no_pm=no_pm)
for page in self.paginator.pages:
await destination.send(page)
except discord.Forbidden:
destination = self.get_destination(no_pm=True)
await destination.send("Couldn't send help to you due to blocked DMs...")