async def deletequote(self, ctx: aoi.AoiContext, quote: int): qid, user, guild = (await (await self.bot.db.conn.execute( "select id, user, guild from quotes where id=?", (quote, ))).fetchone()) if user != ctx.author.id and not ctx.author.guild_permissions.administrator: return ctx.send_error( "You must be administrator to delete quotes that aren't yours." ) await self.bot.db.conn.execute("delete from quotes where id=?", (qid, )) await self.bot.db.conn.commit()
async def warnp(self, ctx: aoi.AoiContext, warns: int, *, action: str = None): if not action: await self.bot.db.del_warnp(ctx.guild.id, warns) return await ctx.send( f"No punishment will be applied at {warns} warns") res = await self._validate_warnp(action) if res: return ctx.send_error(res) await self.bot.db.set_warnp(ctx.guild.id, warns, action) return await ctx.send_ok(f"`{action}` will be applied at {warns} warns" )
async def punishmentclear(self, ctx: aoi.AoiContext, member: discord.Member, num: int = 1): punishments: List[PunishmentModel] = sorted( await self.bot.db.lookup_punishments(member.id), key=lambda punishment: punishment.time, reverse=True) if num < 1 or num > len(punishments): return ctx.send_error("Invalid warning number") p = punishments[num - 1] if "del" in ctx.flags: await self.bot.db.conn.execute( "delete from punishments where user=? and guild=? and timestamp=?", (p.user, p.guild, p.time.timestamp())) else: await self.bot.db.conn.execute( "update punishments set cleared=1,cleared_by=? where user=? and guild=? " "and timestamp=?", (ctx.author.id, p.user, p.guild, p.time.timestamp())) await self.bot.db.conn.commit() await ctx.send_ok(f"Cleared punishment #{num} for {member}")