def quoteadd(self, ctx, target: discord.User, *, text: str):
"""Add a quote.
Usage: quoteadd [member] [text here]"""
if len(text) > 360:
await ctx.send(ctx.mention + ' Your text is too long!')
return
if target == self.bot.user:
if not check_perms(ctx, ('bot_owner',)):
await ctx.send(ctx.mention + ' You can\'t add a quote as me!')
return
fmt_time = [int(i) for i in time.strftime("%m/%d/%Y").split('/')]
q_template = {
'id': 0,
'quote': 'Say-whaaaa?',
'author': ctx.author.display_name,
'author_ids': [''],
'date': fmt_time
}
mauthor = target
q_template['quote'] = text.replace('\n', ' ').replace('@everyone', '@\u200beveryone').replace('@here', '@\u200bhere')
q_template['author'] = mauthor.display_name
if mauthor.display_name != mauthor.name:
q_template['author'] += ' (' + mauthor.name + ')'
q_template['author_ids'] = [mauthor.id, ctx.author.id]
q_template['id'] = len(self.bot.store['quotes']) # +1 for next id, but len() counts from 1
self.bot.store['quotes'].append(q_template)
await ctx.send(f'Quote **#{q_template["id"] + 1}** added!')
评论列表
文章目录