@@ -84,17 +84,17 @@ def run_wizard():
84
84
os .execv (sys .executable , ['python' ] + sys .argv )
85
85
86
86
@classmethod
87
- def init (bot , token = None ):
87
+ def init (cls , token = None ):
88
88
'''Starts the actual bot'''
89
- selfbot = bot ()
89
+ bot = cls ()
90
90
if token :
91
91
to_use = token .strip ('"' )
92
92
else :
93
- to_use = selfbot .token .strip ('"' )
93
+ to_use = bot .token .strip ('"' )
94
94
try :
95
- selfbot .run (to_use , reconnect = True )
95
+ bot .run (to_use , reconnect = True )
96
96
except Exception as e :
97
- print ( e )
97
+ raise e
98
98
99
99
async def on_connect (self ):
100
100
print ('---------------' )
@@ -121,41 +121,51 @@ async def on_ready(self):
121
121
---------------
122
122
''' ))
123
123
124
- def overwrites (self , ctx ):
124
+ def overwrites (self , ctx , modroles = None ):
125
125
'''Permision overwrites for the guild.'''
126
126
overwrites = {
127
127
ctx .guild .default_role : discord .PermissionOverwrite (read_messages = False )
128
128
}
129
129
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 )
132
136
133
137
return overwrites
134
138
135
139
def help_embed (self ):
136
140
em = discord .Embed (color = 0x00FFFF )
137
141
em .set_author (name = 'Mod Mail - Help' , icon_url = self .user .avatar_url )
138
142
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
+
140
146
cmds = '`m.setup [modrole] <- (optional)` - Command that sets up the bot.\n ' \
141
147
'`m.reply <message...>` - Sends a message to the current thread\' s recipient.\n ' \
142
148
'`m.close` - Closes the current thread and deletes the channel.\n ' \
143
149
'`m.disable` - Closes all threads and disables modmail for the server.'
144
150
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.'
146
153
em .add_field (name = 'Commands' , value = cmds )
147
154
em .add_field (name = 'Warning' , value = warn )
148
155
149
156
return em
150
157
151
158
@commands .command ()
152
159
@commands .has_permissions (administrator = True )
153
- async def setup (self , ctx ):
160
+ async def setup (self , ctx , * modroles : discord . Role = None ):
154
161
'''Sets up a server for modmail'''
155
162
if discord .utils .get (ctx .guild .categories , name = 'modmail' ):
156
163
return await ctx .send ('This server is already set up.' )
157
164
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
+ )
159
169
await categ .edit (position = 0 )
160
170
c = await ctx .guild .create_text_channel (name = 'information' , category = categ )
161
171
await c .send (embed = self .help_embed ())
@@ -206,7 +216,8 @@ def guess_modroles(self, ctx):
206
216
yield role
207
217
208
218
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.'''
210
221
server = self .guild
211
222
member = self .guild .get_member (user .id )
212
223
avi = user .avatar_url
@@ -235,7 +246,6 @@ def format_info(self, user):
235
246
em .add_field (name = 'Nick' , value = member .nick , inline = True )
236
247
em .add_field (name = 'Roles' , value = rolenames , inline = True )
237
248
238
-
239
249
return em
240
250
241
251
async def send_mail (self , message , channel , mod ):
0 commit comments