@@ -84,17 +84,17 @@ def run_wizard():
8484 os .execv (sys .executable , ['python' ] + sys .argv )
8585
8686 @classmethod
87- def init (bot , token = None ):
87+ def init (cls , token = None ):
8888 '''Starts the actual bot'''
89- selfbot = bot ()
89+ bot = cls ()
9090 if token :
9191 to_use = token .strip ('"' )
9292 else :
93- to_use = selfbot .token .strip ('"' )
93+ to_use = bot .token .strip ('"' )
9494 try :
95- selfbot .run (to_use , reconnect = True )
95+ bot .run (to_use , reconnect = True )
9696 except Exception as e :
97- print ( e )
97+ raise e
9898
9999 async def on_connect (self ):
100100 print ('---------------' )
@@ -121,41 +121,51 @@ async def on_ready(self):
121121 ---------------
122122 ''' ))
123123
124- def overwrites (self , ctx ):
124+ def overwrites (self , ctx , modroles = None ):
125125 '''Permision overwrites for the guild.'''
126126 overwrites = {
127127 ctx .guild .default_role : discord .PermissionOverwrite (read_messages = False )
128128 }
129129
130- for role in self .guess_modroles (ctx ):
131- overwrites [role ] = discord .PermissionOverwrite (read_messages = True )
130+ if modroles :
131+ for role in modroles :
132+ overwrites [role ] = discord .PermissionOverwrite (read_messages = True )
133+ else :
134+ for role in self .guess_modroles (ctx ):
135+ overwrites [role ] = discord .PermissionOverwrite (read_messages = True )
132136
133137 return overwrites
134138
135139 def help_embed (self ):
136140 em = discord .Embed (color = 0x00FFFF )
137141 em .set_author (name = 'Mod Mail - Help' , icon_url = self .user .avatar_url )
138142 em .description = 'This bot is a python implementation of a stateless "Mod Mail" bot. ' \
139- 'Made by verixx and improved by the suggestions of others. This bot saves no data and utilises channel topics for storage and syncing.'
143+ 'Made by verixx and improved by the suggestions of others. This bot ' \
144+ 'saves no data and utilises channel topics for storage and syncing.'
145+
140146 cmds = '`m.setup [modrole] <- (optional)` - Command that sets up the bot.\n ' \
141147 '`m.reply <message...>` - Sends a message to the current thread\' s recipient.\n ' \
142148 '`m.close` - Closes the current thread and deletes the channel.\n ' \
143149 '`m.disable` - Closes all threads and disables modmail for the server.'
144150
145- warn = 'Do not manually delete the category or channels as it will break the system. Modifying the channel topic will also break the system.'
151+ warn = 'Do not manually delete the category or channels as it will break the system. ' \
152+ 'Modifying the channel topic will also break the system.'
146153 em .add_field (name = 'Commands' , value = cmds )
147154 em .add_field (name = 'Warning' , value = warn )
148155
149156 return em
150157
151158 @commands .command ()
152159 @commands .has_permissions (administrator = True )
153- async def setup (self , ctx ):
160+ async def setup (self , ctx , * modroles : discord . Role = None ):
154161 '''Sets up a server for modmail'''
155162 if discord .utils .get (ctx .guild .categories , name = 'modmail' ):
156163 return await ctx .send ('This server is already set up.' )
157164
158- categ = await ctx .guild .create_category (name = 'modmail' , overwrites = self .overwrites (ctx ))
165+ categ = await ctx .guild .create_category (
166+ name = 'modmail' ,
167+ overwrites = self .overwrites (ctx , modroles = modroles )
168+ )
159169 await categ .edit (position = 0 )
160170 c = await ctx .guild .create_text_channel (name = 'information' , category = categ )
161171 await c .send (embed = self .help_embed ())
@@ -206,7 +216,8 @@ def guess_modroles(self, ctx):
206216 yield role
207217
208218 def format_info (self , user ):
209- '''Get information about a member of a server'''
219+ '''Get information about a member of a server
220+ supports users from the guild or not.'''
210221 server = self .guild
211222 member = self .guild .get_member (user .id )
212223 avi = user .avatar_url
@@ -235,7 +246,6 @@ def format_info(self, user):
235246 em .add_field (name = 'Nick' , value = member .nick , inline = True )
236247 em .add_field (name = 'Roles' , value = rolenames , inline = True )
237248
238-
239249 return em
240250
241251 async def send_mail (self , message , channel , mod ):
0 commit comments