1212
1313from core import checks
1414from core .decorators import trigger_typing
15- from core .models import Bot
15+ from core .models import Bot , PermissionLevel
1616from core .paginator import PaginatorSession
1717from core .time import UserFriendlyTime , human_timedelta
1818from core .utils import format_preview , User
@@ -26,7 +26,7 @@ def __init__(self, bot: Bot):
2626
2727 @commands .command ()
2828 @trigger_typing
29- @checks .has_permissions (administrator = True )
29+ @checks .has_permissions (PermissionLevel . OWNER )
3030 async def setup (self , ctx ):
3131 """Sets up a server for Modmail"""
3232 if self .bot .main_category :
@@ -62,15 +62,18 @@ async def setup(self, ctx):
6262 self .bot .config ['log_channel_id' ] = log_channel .id
6363
6464 await self .bot .config .update ()
65- await ctx .send ('Successfully set up server.' )
65+ await ctx .send ('Successfully set up server.\n '
66+ 'Consider setting permission groups to give access '
67+ 'to roles or users the ability to use Modmail.\n '
68+ f'Type `{ self .bot .prefix } permissions` for more info.' )
69+ if not self .bot .config .permissions :
70+ await self .bot .update_perms (PermissionLevel .REGULAR , - 1 )
71+ await self .bot .update_perms (PermissionLevel .OWNER , ctx .author .id )
6672
67- @commands .group ()
68- @checks .has_permissions (manage_messages = True )
73+ @commands .group (invoke_without_command = True )
74+ @checks .has_permissions (PermissionLevel . SUPPORTER )
6975 async def snippets (self , ctx ):
7076 """Returns a list of snippets that are currently set."""
71- if ctx .invoked_subcommand is not None :
72- return
73-
7477 embeds = []
7578
7679 if self .bot .snippets :
@@ -101,7 +104,7 @@ async def snippets(self, ctx):
101104 await session .run ()
102105
103106 @snippets .command (name = 'add' )
104- @checks .has_permissions (manage_messages = True )
107+ @checks .has_permissions (PermissionLevel . SUPPORTER )
105108 async def add_ (self , ctx , name : str .lower , * , value ):
106109 """Add a snippet to the bot config."""
107110 if 'snippets' not in self .bot .config .cache :
@@ -118,9 +121,9 @@ async def add_(self, ctx, name: str.lower, *, value):
118121
119122 await ctx .send (embed = embed )
120123
121- @snippets .command (name = 'del' )
122- @checks .has_permissions (manage_messages = True )
123- async def del_ (self , ctx , * , name : str .lower ):
124+ @snippets .command (name = 'remove' , aliases = [ ' del', 'delete' , 'rm' ] )
125+ @checks .has_permissions (PermissionLevel . SUPPORTER )
126+ async def remove_ (self , ctx , * , name : str .lower ):
124127 """Removes a snippet from bot config."""
125128
126129 if self .bot .config .snippets .get (name ):
@@ -142,7 +145,7 @@ async def del_(self, ctx, *, name: str.lower):
142145 await ctx .send (embed = embed )
143146
144147 @commands .command ()
145- @checks .has_permissions (manage_messages = True )
148+ @checks .has_permissions (PermissionLevel . MODERATOR )
146149 async def move (self , ctx , * , category : discord .CategoryChannel ):
147150 """Moves a thread to a specified category."""
148151 thread = ctx .thread
@@ -179,6 +182,7 @@ async def send_scheduled_close_message(ctx, after, silent=False):
179182 await ctx .send (embed = embed )
180183
181184 @commands .command (usage = '[after] [close message]' )
185+ @checks .has_permissions (PermissionLevel .SUPPORTER )
182186 @checks .thread_only ()
183187 async def close (self , ctx , * , after : UserFriendlyTime = None ):
184188 """
@@ -236,6 +240,7 @@ async def close(self, ctx, *, after: UserFriendlyTime = None):
236240 )
237241
238242 @commands .command (aliases = ['alert' ])
243+ @checks .has_permissions (PermissionLevel .SUPPORTER )
239244 @checks .thread_only ()
240245 async def notify (self , ctx , * , role = None ):
241246 """
@@ -272,6 +277,7 @@ async def notify(self, ctx, *, role=None):
272277 return await ctx .send (embed = embed )
273278
274279 @commands .command (aliases = ['sub' ])
280+ @checks .has_permissions (PermissionLevel .SUPPORTER )
275281 @checks .thread_only ()
276282 async def subscribe (self , ctx , * , role = None ):
277283 """
@@ -311,6 +317,7 @@ async def subscribe(self, ctx, *, role=None):
311317 return await ctx .send (embed = embed )
312318
313319 @commands .command (aliases = ['unsub' ])
320+ @checks .has_permissions (PermissionLevel .SUPPORTER )
314321 @checks .thread_only ()
315322 async def unsubscribe (self , ctx , * , role = None ):
316323 """Unsubscribe yourself or a given role from a thread."""
@@ -343,13 +350,15 @@ async def unsubscribe(self, ctx, *, role=None):
343350 return await ctx .send (embed = embed )
344351
345352 @commands .command ()
353+ @checks .has_permissions (PermissionLevel .SUPPORTER )
346354 @checks .thread_only ()
347355 async def nsfw (self , ctx ):
348356 """Flags a Modmail thread as nsfw."""
349357 await ctx .channel .edit (nsfw = True )
350358 await ctx .message .add_reaction ('✅' )
351359
352360 @commands .command ()
361+ @checks .has_permissions (PermissionLevel .SUPPORTER )
353362 @checks .thread_only ()
354363 async def loglink (self , ctx ):
355364 """Return the link to the current thread's logs."""
@@ -407,7 +416,7 @@ def format_log_embeds(self, logs, avatar_url):
407416 return embeds
408417
409418 @commands .group (invoke_without_command = True )
410- @checks .has_permissions (manage_messages = True )
419+ @checks .has_permissions (PermissionLevel . SUPPORTER )
411420 async def logs (self , ctx , * , member : User = None ):
412421 """Shows a list of previous Modmail thread logs of a member."""
413422
@@ -440,7 +449,7 @@ async def logs(self, ctx, *, member: User = None):
440449 await session .run ()
441450
442451 @logs .command (name = 'closed-by' )
443- @checks .has_permissions (manage_messages = True )
452+ @checks .has_permissions (PermissionLevel . SUPPORTER )
444453 async def closed_by (self , ctx , * , user : User = None ):
445454 """Returns all logs closed by a user."""
446455 if not self .bot .self_hosted :
@@ -478,8 +487,8 @@ async def closed_by(self, ctx, *, user: User = None):
478487 session = PaginatorSession (ctx , * embeds )
479488 await session .run ()
480489
481- @logs .command (name = 'search' )
482- @checks .has_permissions (manage_messages = True )
490+ @logs .command ()
491+ @checks .has_permissions (PermissionLevel . SUPPORTER )
483492 async def search (self , ctx , limit : Optional [int ] = None , * , query ):
484493 """Searches all logs for a message that contains your query."""
485494
@@ -521,6 +530,7 @@ async def search(self, ctx, limit: Optional[int] = None, *, query):
521530 await session .run ()
522531
523532 @commands .command ()
533+ @checks .has_permissions (PermissionLevel .SUPPORTER )
524534 @checks .thread_only ()
525535 async def reply (self , ctx , * , msg = '' ):
526536 """Reply to users using this command.
@@ -533,6 +543,7 @@ async def reply(self, ctx, *, msg=''):
533543 await ctx .thread .reply (ctx .message )
534544
535545 @commands .command ()
546+ @checks .has_permissions (PermissionLevel .SUPPORTER )
536547 @checks .thread_only ()
537548 async def anonreply (self , ctx , * , msg = '' ):
538549 """Reply to a thread anonymously.
@@ -548,6 +559,7 @@ async def anonreply(self, ctx, *, msg=''):
548559 await ctx .thread .reply (ctx .message , anonymous = True )
549560
550561 @commands .command ()
562+ @checks .has_permissions (PermissionLevel .SUPPORTER )
551563 @checks .thread_only ()
552564 async def note (self , ctx , * , msg = '' ):
553565 """Take a note about the current thread, useful for noting context."""
@@ -556,6 +568,7 @@ async def note(self, ctx, *, msg=''):
556568 await ctx .thread .note (ctx .message )
557569
558570 @commands .command ()
571+ @checks .has_permissions (PermissionLevel .SUPPORTER )
559572 @checks .thread_only ()
560573 async def edit (self , ctx , message_id : Optional [int ] = None ,
561574 * , new_message ):
@@ -599,8 +612,8 @@ async def edit(self, ctx, message_id: Optional[int] = None,
599612 await ctx .message .add_reaction ('✅' )
600613
601614 @commands .command ()
615+ @checks .has_permissions (PermissionLevel .SUPPORTER )
602616 @trigger_typing
603- @checks .has_permissions (manage_messages = True )
604617 async def contact (self , ctx ,
605618 category : Optional [discord .CategoryChannel ] = None , * ,
606619 user : Union [discord .Member , discord .User ]):
@@ -639,8 +652,8 @@ async def contact(self, ctx,
639652 await ctx .send (embed = embed )
640653
641654 @commands .command ()
655+ @checks .has_permissions (PermissionLevel .MODERATOR )
642656 @trigger_typing
643- @checks .has_permissions (manage_channels = True )
644657 async def blocked (self , ctx ):
645658 """Returns a list of blocked users"""
646659 embed = discord .Embed (title = 'Blocked Users' ,
@@ -672,8 +685,8 @@ async def blocked(self, ctx):
672685 await ctx .send (embed = embed )
673686
674687 @commands .command ()
688+ @checks .has_permissions (PermissionLevel .MODERATOR )
675689 @trigger_typing
676- @checks .has_permissions (manage_channels = True )
677690 async def block (self , ctx , user : Optional [User ] = None , * ,
678691 after : UserFriendlyTime = None ):
679692 """
@@ -738,8 +751,8 @@ async def block(self, ctx, user: Optional[User] = None, *,
738751 return await ctx .send (embed = embed )
739752
740753 @commands .command ()
754+ @checks .has_permissions (PermissionLevel .MODERATOR )
741755 @trigger_typing
742- @checks .has_permissions (manage_channels = True )
743756 async def unblock (self , ctx , * , user : User = None ):
744757 """
745758 Unblocks a user from using Modmail.
0 commit comments