Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44fe05a

Browse files
Create data.py
1 parent e58c8bc commit 44fe05a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

‎utils/data.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import discord
2+
3+
from utils import permissions
4+
from discord.ext.commands import AutoShardedBot, DefaultHelpCommand
5+
6+
7+
class Bot(AutoShardedBot):
8+
def __init__(self, *args, prefix=None, **kwargs):
9+
super().__init__(*args, **kwargs)
10+
self.prefix = prefix
11+
12+
async def on_message(self, msg):
13+
if not self.is_ready() or msg.author.bot or not permissions.can_handle(msg, "send_messages"):
14+
return
15+
16+
await self.process_commands(msg)
17+
18+
19+
class HelpFormat(DefaultHelpCommand):
20+
def get_destination(self, no_pm: bool = False):
21+
if no_pm:
22+
return self.context.channel
23+
else:
24+
return self.context.author
25+
26+
async def send_error_message(self, error):
27+
destination = self.get_destination(no_pm=True)
28+
await destination.send(error)
29+
30+
async def send_command_help(self, command):
31+
self.add_command_formatting(command)
32+
self.paginator.close_page()
33+
await self.send_pages(no_pm=True)
34+
35+
async def send_pages(self, no_pm: bool = False):
36+
try:
37+
if permissions.can_handle(self.context, "add_reactions"):
38+
await self.context.message.add_reaction(chr(0x2709))
39+
except discord.Forbidden:
40+
pass
41+
42+
try:
43+
destination = self.get_destination(no_pm=no_pm)
44+
for page in self.paginator.pages:
45+
await destination.send(page)
46+
except discord.Forbidden:
47+
destination = self.get_destination(no_pm=True)
48+
await destination.send("Couldn't send help to you due to blocked DMs...")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /