@@ -20,16 +20,16 @@ def __init__(self, bot):
20
20
async def setup (self , ctx ):
21
21
'''Sets up a server for modmail'''
22
22
if self .bot .main_category :
23
- return await ctx .send ('This server is already set up.' )
23
+ return await ctx .send (f' { self . bot . modmail_guild } is already set up.' )
24
24
25
- categ = await ctx . guild .create_category (
25
+ categ = await self . bot . modmail_guild .create_category (
26
26
name = 'Mod Mail' ,
27
27
overwrites = self .bot .overwrites (ctx , modrole = modrole )
28
28
)
29
29
30
30
await categ .edit (position = 0 )
31
31
32
- c = await ctx . guild .create_text_channel (name = 'thread-logs' , category = categ )
32
+ c = await self . bot . modmail_guild .create_text_channel (name = 'thread-logs' , category = categ )
33
33
await c .edit (topic = 'Manually add user id\' s to block users.\n \n '
34
34
'Blocked\n -------\n \n ' )
35
35
@@ -163,11 +163,11 @@ async def _close(self, ctx):
163
163
@commands .command ()
164
164
async def nsfw (self , ctx ):
165
165
'''Flags a modmail thread as nsfw.'''
166
- if ctx . channel . category and ctx . channel . category . name == 'Mod Mail' :
167
- await ctx . edit ( nsfw = True )
168
- em = discord . Embed ( description = desc , color = discord . Color . green ())
169
- em . set_author ( name = 'Thread closed' , url = log_url )
170
- await ctx .send ( 'Done ' )
166
+ thread = self . bot . threads . find ( channel = ctx . channel )
167
+ if thread is None :
168
+ return
169
+ await ctx . edit ( nsfw = True )
170
+ await ctx .message . add_reaction ( '✅ ' )
171
171
172
172
@commands .command ()
173
173
@trigger_typing
@@ -228,7 +228,7 @@ async def reply(self, ctx, *, msg=''):
228
228
'''
229
229
ctx .message .content = msg
230
230
thread = await self .bot .threads .find (channel = ctx .channel )
231
- if thread and thread . channel . category . name == 'Mod Mail' :
231
+ if thread :
232
232
await thread .reply (ctx .message )
233
233
234
234
@commands .command ()
@@ -241,27 +241,29 @@ async def edit(self, ctx, message_id: Optional[int]=None, *, new_message):
241
241
`<new_message>` is the new message that will be edited in.
242
242
'''
243
243
thread = await self .bot .threads .find (channel = ctx .channel )
244
- print (message_id , new_message )
245
- if thread and thread .channel .category .name == 'Mod Mail' :
246
- linked_message_id = None
247
-
248
- async for msg in ctx .channel .history ():
249
- if message_id is None and msg .embeds :
250
- em = msg .embeds [0 ]
251
- if 'Moderator' not in str (em .footer .text ):
252
- continue
253
- linked_message_id = int (re .findall (r'\d+' , em .author .url )[0 ])
254
- break
255
- elif message_id and msg .id == message_id :
256
- url = msg .embeds [0 ].author .url
257
- linked_message_id = int (re .findall (r'\d+' , url )[0 ])
258
- break
244
+
245
+ if thread is None :
246
+ return
247
+
248
+ linked_message_id = None
259
249
260
- if not linked_message_id :
261
- raise commands .UserInputError
250
+ async for msg in ctx .channel .history ():
251
+ if message_id is None and msg .embeds :
252
+ em = msg .embeds [0 ]
253
+ if 'Moderator' not in str (em .footer .text ):
254
+ continue
255
+ linked_message_id = int (re .findall (r'\d+' , em .author .url )[0 ])
256
+ break
257
+ elif message_id and msg .id == message_id :
258
+ url = msg .embeds [0 ].author .url
259
+ linked_message_id = int (re .findall (r'\d+' , url )[0 ])
260
+ break
261
+
262
+ if not linked_message_id :
263
+ raise commands .UserInputError
262
264
263
- await thread .edit_message (linked_message_id , new_message )
264
- await ctx .message .add_reaction ('✅' )
265
+ await thread .edit_message (linked_message_id , new_message )
266
+ await ctx .message .add_reaction ('✅' )
265
267
266
268
@commands .command ()
267
269
@trigger_typing
@@ -363,8 +365,8 @@ async def unblock(self, ctx, id=None):
363
365
else :
364
366
raise commands .UserInputError
365
367
366
- categ = discord . utils . get ( ctx . guild . categories , name = 'Mod Mail' )
367
- top_chan = categ .channels [0 ] #bot-info
368
+ categ = self . bot . main_category
369
+ top_chan = categ .channels [0 ] #thread-logs
368
370
topic = str (top_chan .topic )
369
371
topic = topic .replace ('\n ' + id , '' )
370
372
0 commit comments