29
29
from jishaku .types import ContextA , ContextT
30
30
31
31
UserIDConverter = commands .IDConverter [typing .Union [discord .Member , discord .User ]]
32
- ChannelIDConverter = commands .IDConverter [typing .Union [discord .abc .GuildChannel , discord .abc .PrivateChannel , discord .Thread ]]
32
+ ChannelIDConverter = commands .IDConverter [
33
+ typing .Union [discord .abc .GuildChannel , discord .abc .PrivateChannel , discord .Thread ]
34
+ ]
33
35
34
36
35
37
class SlimUserConverter (UserIDConverter ): # pylint: disable=too-few-public-methods
@@ -39,7 +41,7 @@ class SlimUserConverter(UserIDConverter): # pylint: disable=too-few-public-meth
39
41
40
42
async def convert (self , ctx : ContextA , argument : str ) -> typing .Union [discord .Member , discord .User ]:
41
43
"""Converter method"""
42
- match = self ._get_id_match (argument ) or re .match (r' <@!?([0-9]{15,20})>$' , argument ) # type: ignore
44
+ match = self ._get_id_match (argument ) or re .match (r" <@!?([0-9]{15,20})>$" , argument ) # type: ignore
43
45
44
46
if match is not None :
45
47
user_id = int (match .group (1 ))
@@ -61,15 +63,18 @@ class SlimChannelConverter(ChannelIDConverter): # pylint: disable=too-few-publi
61
63
does not perform plaintext name or guild checks.
62
64
"""
63
65
64
- async def convert (self , ctx : ContextA , argument : str ) -> typing .Union [discord .abc .GuildChannel , discord .abc .PrivateChannel , discord .Thread ]:
66
+ async def convert (
67
+ self , ctx : ContextA , argument : str
68
+ ) -> typing .Union [discord .abc .GuildChannel , discord .abc .PrivateChannel , discord .Thread ]:
65
69
"""Converter method"""
66
- match = self ._get_id_match (argument ) or re .match (r' <#([0-9]{15,20})>$' , argument )
70
+ match = self ._get_id_match (argument ) or re .match (r" <#([0-9]{15,20})>$" , argument )
67
71
68
72
if match is not None :
69
73
channel_id = int (match .group (1 ))
70
- if ctx .guild :
74
+ result = None
75
+ if ctx .guild is not None :
71
76
result = ctx .guild .get_channel_or_thread (channel_id )
72
- if not result :
77
+ if result is None :
73
78
result = ctx .bot .get_channel (channel_id )
74
79
if result is not None :
75
80
return result
@@ -84,13 +89,7 @@ class InvocationFeature(Feature):
84
89
OVERRIDE_SIGNATURE = typing .Union [SlimUserConverter , SlimChannelConverter ]
85
90
86
91
@Feature .Command (parent = "jsk" , name = "override" , aliases = ["execute" , "exec" , "override!" , "execute!" , "exec!" ])
87
- async def jsk_override (
88
- self ,
89
- ctx : ContextT ,
90
- overrides : commands .Greedy [OVERRIDE_SIGNATURE ],
91
- * ,
92
- command_string : str
93
- ):
92
+ async def jsk_override (self , ctx : ContextT , overrides : commands .Greedy [OVERRIDE_SIGNATURE ], * , command_string : str ):
94
93
"""
95
94
Run a command with a different user, channel, or thread, optionally bypassing checks and cooldowns.
96
95
@@ -100,7 +99,7 @@ async def jsk_override(
100
99
kwargs : typing .Dict [str , typing .Any ] = {}
101
100
102
101
if ctx .prefix :
103
- kwargs ["content" ] = ctx .prefix + command_string .lstrip ('/' )
102
+ kwargs ["content" ] = ctx .prefix + command_string .lstrip ("/" )
104
103
else :
105
104
await ctx .send ("Reparsing requires a prefix" )
106
105
return
@@ -128,12 +127,12 @@ async def jsk_override(
128
127
129
128
if alt_ctx .command is None :
130
129
if alt_ctx .invoked_with is None :
131
- await ctx .send (' This bot has been hard-configured to ignore this user.' )
130
+ await ctx .send (" This bot has been hard-configured to ignore this user." )
132
131
return
133
132
await ctx .send (f'Command "{ alt_ctx .invoked_with } " is not found' )
134
133
return
135
134
136
- if ctx .invoked_with and ctx .invoked_with .endswith ('!' ):
135
+ if ctx .invoked_with and ctx .invoked_with .endswith ("!" ):
137
136
await alt_ctx .command .reinvoke (alt_ctx )
138
137
return
139
138
@@ -209,17 +208,14 @@ async def jsk_source(self, ctx: ContextA, *, command_name: str):
209
208
pass
210
209
211
210
# getsourcelines for some reason returns WITH line endings
212
- source_text = '' .join (source_lines )
211
+ source_text = "" .join (source_lines )
213
212
214
213
if use_file_check (ctx , len (source_text )): # File "full content" preview limit
215
- await ctx .send (file = discord .File (
216
- filename = filename ,
217
- fp = io .BytesIO (source_text .encode ('utf-8' ))
218
- ))
214
+ await ctx .send (file = discord .File (filename = filename , fp = io .BytesIO (source_text .encode ("utf-8" ))))
219
215
else :
220
- paginator = WrappedPaginator (prefix = ' ```py' , suffix = ' ```' , max_size = 1980 )
216
+ paginator = WrappedPaginator (prefix = " ```py" , suffix = " ```" , max_size = 1980 )
221
217
222
- paginator .add_line (source_text .replace (' ```' , ' ``\N{zero width space} `' ))
218
+ paginator .add_line (source_text .replace (" ```" , " ``\N{zero width space} `" ))
223
219
224
220
interface = PaginatorInterface (ctx .bot , paginator , owner = ctx .author )
225
221
await interface .send_to (ctx )
0 commit comments