Skip to content

Commit f5ffde1

Browse files
committed
Add about command
1 parent d715504 commit f5ffde1

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

bot.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141

4242

4343
class Modmail(commands.Bot):
44+
45+
version = '1.1.4'
46+
4447
def __init__(self):
4548
super().__init__(command_prefix=self.get_pre)
46-
self.uptime = datetime.datetime.utcnow()
49+
self.start_time = datetime.datetime.utcnow()
4750
self._add_commands()
4851

4952
def _add_commands(self):
@@ -76,7 +79,8 @@ def token(self):
7679
@staticmethod
7780
async def get_pre(bot, message):
7881
'''Returns the prefix.'''
79-
return bot.config.get('PREFIX') or 'm.'
82+
p = bot.config.get('PREFIX') or 'm.'
83+
return [p, bot.user.mention+' ']
8084

8185
async def on_connect(self):
8286
print('---------------')
@@ -199,15 +203,48 @@ def help_embed(self, prefix):
199203
em.add_field(name='Custom Mentions', value=mention)
200204
em.add_field(name='Warning', value=warn)
201205
em.add_field(name='Github', value='https://github.com/kyb3r/modmail')
202-
em.set_footer(text='Modmail v1.1.3 | Star the repository to unlock hidden features! /s')
206+
em.set_footer(text=f'Modmail v{self.version} | Star the repository to unlock hidden features! /s')
203207

204208
return em
205209

210+
@property
211+
def uptime(self):
212+
now = datetime.datetime.utcnow()
213+
delta = now - self.start_time
214+
hours, remainder = divmod(int(delta.total_seconds()), 3600)
215+
minutes, seconds = divmod(remainder, 60)
216+
days, hours = divmod(hours, 24)
217+
218+
fmt = '{h}h {m}m {s}s'
219+
if days:
220+
fmt = '{d}d ' + fmt
221+
222+
return fmt.format(d=days, h=hours, m=minutes, s=seconds)
223+
206224
@commands.command()
207225
async def help(self, ctx):
208226
prefix = self.config.get('PREFIX', 'm.')
209227
em = self.help_embed(prefix)
210228
await ctx.send(embed=em)
229+
230+
@commands.command()
231+
async def about(self, ctx):
232+
em = discord.Embed(color=discord.Color.green())
233+
em.set_author(name='Mod Mail - Information', icon_url=self.user.avatar_url)
234+
em.set_thumbnail(url=self.user.avatar_url)
235+
236+
em.description = 'This is an open source discord bot made by kyb3r and '\
237+
'improved upon suggestions by the users! This bot serves as a means for members to '\
238+
'easily communicate with server leadership in an organised manner.'
239+
240+
em.add_field(name='Uptime', value=self.uptime)
241+
em.add_field(name='Latency', value=f'{self.latency*1000:.2f} ms')
242+
em.add_field(name='Version', value=f'`v{self.version}`')
243+
em.add_field(name='Author', value='[`kyb3r`](https://github.com/kyb3r)')
244+
em.add_field(name='Github', value='https://github.com/kyb3r/modmail')
245+
em.set_footer(text=f'Bot ID: {self.user.id}')
246+
247+
await ctx.send(embed=em)
211248

212249
@commands.command()
213250
@commands.has_permissions(administrator=True)

0 commit comments

Comments
 (0)