@@ -903,8 +903,8 @@ async def _eval(self, ctx, *, body: str, edit=True):
903
903
else :
904
904
await ctx .message .add_reaction ('\u2705 ' )
905
905
906
- async def edit_to_codeblock (self , ctx , body , pycc = False ):
907
- if not pycc :
906
+ async def edit_to_codeblock (self , ctx , body , pycc = 'blank' ):
907
+ if pycc == 'blank' :
908
908
msg = f'{ ctx .prefix } eval\n ```py\n { body } \n ```'
909
909
else :
910
910
msg = f'{ ctx .prefix } cc make { pycc } \n ```py\n { body } \n ```'
@@ -1066,9 +1066,9 @@ async def make(self, ctx, name, *, content):
1066
1066
commands ['pycc' ][name ]
1067
1067
except KeyError :
1068
1068
if '{pycc}' in content :
1069
- commands ['pycc' ].update ({name : content })
1069
+ commands ['pycc' ].update ({name : content . strip ( '{pycc}' ) })
1070
1070
cmdtype = 'pycc'
1071
- await self .edit_to_codeblock (ctx , content , pycc = True )
1071
+ await self .edit_to_codeblock (ctx , content . strip ( '{pycc}' ) , pycc = name )
1072
1072
else :
1073
1073
commands ['textcc' ].update ({name : content })
1074
1074
cmdtype = 'text'
@@ -1145,27 +1145,51 @@ async def _list(self, ctx, option:str = 'all'):
1145
1145
else :
1146
1146
await ctx .send ('Invalid option. Available options: `text`, `pycc`, `all`' )
1147
1147
1148
+ def agreecheck (self , message ):
1149
+ return message .content .lower () == 'yes' and message .author == self .bot .user
1150
+
1151
+ @cc .command ()
1152
+ async def wipe (self , ctx ):
1153
+ """Wipes all your custom commands!"""
1154
+ message1 = await ctx .send ('Are you sure you want to delete all your custom commands?' )
1155
+ try :
1156
+ message2 = await self .bot .wait_for ('message' , check = self .agreecheck , timeout = 5 )
1157
+ except asyncio .TimeoutError :
1158
+ await message1 .delete ()
1159
+ return
1160
+ else :
1161
+ await message1 .delete ()
1162
+ await message2 .delete ()
1163
+ await ctx .send ('Wiping...' , delete_after = 2 )
1164
+ if await ctx .updatedata ('data/cc.json' , json .dumps ({"pycc" :{},"textcc" :{}}, indent = 4 ), f'Wipe custom commands' ):
1165
+ await ctx .send ('Wiped all commands.' , delete_after = 2 )
1148
1166
1149
1167
#reading cc
1150
1168
async def on_message (self , message ):
1151
1169
if message .author != self .bot .user : return
1152
- if message .content .startswith (await self .bot .get_pre (self .bot , message )):
1170
+ prefix = await self .bot .get_pre (self .bot , message )
1171
+ if message .content .startswith (prefix ):
1153
1172
with open ('data/cc.json' ) as f :
1154
1173
commands = json .load (f )
1155
1174
try :
1156
- await message . channel . send ( commands ['textcc' ][message .content .strip (await self . bot . get_pre ( self . bot , message ))])
1175
+ commands ['textcc' ][message .content .strip (prefix )]
1157
1176
except KeyError :
1158
1177
try :
1159
- utils = self .bot .get_cog ('Utility' )
1160
- await (await self .bot .get_context (message )).invoke (utils ._eval , body = commands ['pycc' ][message .content .strip (await self .bot .get_pre (self .bot , message ))], edit = False )
1178
+ commands ['pycc' ][message .content .strip (prefix )]
1161
1179
except KeyError :
1162
1180
pass
1181
+ else :
1182
+ utils = self .bot .get_cog ('Utility' )
1183
+ await (await self .bot .get_context (message )).invoke (utils ._eval , body = str (commands ['pycc' ][message .content .strip (prefix )]), edit = False )
1184
+ else :
1185
+ await message .channel .send (commands ['textcc' ][message .content .strip (prefix )])
1163
1186
1164
1187
@commands .group (invoke_without_command = True )
1165
1188
async def options (self , ctx ):
1166
1189
pass
1167
1190
@options .command ()
1168
1191
async def edit (self , ctx , name , * , value ):
1192
+ """Edits an option"""
1169
1193
name = name .upper ()
1170
1194
with open ('data/options.json' ) as f :
1171
1195
options = json .load (f )
@@ -1180,6 +1204,7 @@ async def edit(self, ctx, name, *, value):
1180
1204
1181
1205
@options .command (name = 'list' )
1182
1206
async def __list (self , ctx ):
1207
+ """Lists all options"""
1183
1208
with open ('data/options.json' ) as f :
1184
1209
await ctx .send ('```json\n ' + json .dumps (json .load (f ), indent = 4 ) + '\n ```' )
1185
1210
0 commit comments