Skip to content

Commit a5ade26

Browse files
committed
Added a help message and a disable command
1 parent fa69da1 commit a5ade26

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

bot.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ def overwrites(self, ctx):
132132

133133
return overwrites
134134

135+
def help_embed(self):
136+
em = discord.Embed(color=0x00FFFF)
137+
em.set_author(name='Mod Mail - Help', icon_url=self.user.avatar_url)
138+
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.'
140+
cmds = '`m.setup [modrole] <- (optional)` - Command that sets up the bot.\n' \
141+
'`m.reply <message...>` - Sends a message to the current thread\'s recipient.\n' \
142+
'`m.close` - Closes the current thread and deletes the channel.\n' \
143+
'`m.disable` - Closes all threads and disables modmail for the server.'
144+
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.'
146+
em.add_field(name='Commands', value=cmds)
147+
em.add_field(name='Warning', value=warn)
148+
149+
return em
150+
135151
@commands.command()
136152
@commands.has_permissions(administrator=True)
137153
async def setup(self, ctx):
@@ -141,8 +157,29 @@ async def setup(self, ctx):
141157

142158
categ = await ctx.guild.create_category(name='modmail', overwrites=self.overwrites(ctx))
143159
await categ.edit(position=0)
160+
c = await ctx.guild.create_text_channel(name='information', category=categ)
161+
await c.send(embed=self.help_embed())
144162
await ctx.send('Successfully set up server.')
145163

164+
@commands.command()
165+
@commands.has_permissions(administrator=True)
166+
async def disable(self, ctx):
167+
'''Close all threads and disable modmail.'''
168+
categ = discord.utils.get(ctx.guild.categories, name='modmail')
169+
if not categ:
170+
return await ctx.send('This server is not set up.')
171+
for category, channels in ctx.guild.by_category():
172+
if category == categ:
173+
for chan in channels:
174+
if 'User ID:' in str(chan.topic):
175+
user_id = int(chan.topic.split(': ')[1])
176+
user = self.get_user(user_id)
177+
await user.send('A moderator has closed this modmail session.')
178+
await chan.delete()
179+
await categ.delete()
180+
await ctx.send('Disabled modmail.')
181+
182+
146183
@commands.command(name='close')
147184
@commands.has_permissions(manage_guild=True)
148185
async def _close(self, ctx):

0 commit comments

Comments
 (0)