def whip(self, ctx, *, person: discord.User=None):
"""Whip someone.
If no arguments provided, shows how many whips you
received.
The command has a 5/1800s cooldown per-user
"""
if not person:
whip = await self.whip_coll.find_one({'user_id': ctx.author.id})
if not whip:
return await ctx.send(f'**{ctx.author}** was never whipped')
return await ctx.send(f'**{ctx.author}** was whipped'
f' {whip["whips"]} times')
if person == ctx.author:
return await ctx.send('no')
uid = person.id
whip = await self.whip_coll.find_one({'user_id': uid})
if not whip:
whip = {
'user_id': uid,
'whips': 0,
}
await self.whip_coll.insert_one(whip)
await self.whip_coll.update_one({'user_id': uid},
{'$inc': {'whips': 1}})
await ctx.send(f'**{ctx.author}** whipped **{person}** '
f'They have been whipped {whip["whips"] + 1} times.')
评论列表
文章目录