async def reidentify(self, ctx, report_id, identifier): """Owner only - Changes the identifier of a report.""" if not ctx.message.author.id == constants.OWNER_ID: return identifier = identifier.upper() id_num = get_next_report_num(identifier) report = Report.from_id(report_id) new_report = copy.copy(report) await report.resolve(ctx, f"Reassigned as `{identifier}-{id_num}`.", False) report.commit() new_report.report_id = f"{identifier}-{id_num}" msg = await self.bot.get_channel(constants.TRACKER_CHAN ).send(embed=new_report.get_embed()) new_report.message = msg.id if new_report.github_issue: await new_report.update_labels() await new_report.edit_title( f"{new_report.report_id} {new_report.title}") new_report.commit() await ctx.send( f"Reassigned {report.report_id} as {new_report.report_id}.")
async def downvote(ctx, _id, *, msg=''): """Adds a downvote to the selected feature request.""" report = Report.from_id(_id) await report.downvote(ctx.message.author.id, msg) report.commit() await bot.say(f"Ok, I've added a note to `{report.report_id}` - {report.title}.") await report.update(ctx)
async def update(ctx, build_id: int, *, msg=""): """Owner only - To be run after an update. Resolves all -P2 reports.""" if not ctx.message.author.id == OWNER_ID: return changelog = "" for _id in bot.db.jget("pending-reports", []): report = Report.from_id(_id) await report.resolve(ctx, f"Patched in build {build_id}", ignore_closed=True) report.commit() action = "Fixed" if report.report_id.startswith("AFR"): action = "Added" if report.get_issue_link(): changelog += f"- {action} [`{report.report_id}`]({report.get_issue_link()}) {report.title}\n" else: changelog += f"- {action} `{report.report_id}` {report.title}\n" changelog += msg bot.db.jset("pending-reports", []) await bot.send_message(ctx.message.channel, embed=discord.Embed(title=f"**Build {build_id}**", description=changelog, colour=0x87d37c)) await bot.delete_message(ctx.message)
async def note(ctx, _id, *, msg=''): """Adds a note to a report.""" report = Report.from_id(_id) await report.addnote(ctx.message.author.id, msg) report.commit() await bot.say(f"Ok, I've added a note to `{report.report_id}` - {report.title}.") await report.update(ctx)
async def unresolve(ctx, _id, *, msg=''): """Owner only - Unresolves a report.""" if not ctx.message.author.id == OWNER_ID: return report = Report.from_id(_id) await report.unresolve(ctx, msg) report.commit() await bot.say(f"Unresolved `{report.report_id}`: {report.title}.")
async def cannotrepro(ctx, _id, *, msg=''): """Adds nonreproduction to a report.""" report = Report.from_id(_id) await report.cannotrepro(ctx.message.author.id, msg, ctx) report.commit() await bot.say( f"Ok, I've added a note to `{report.report_id}` - {report.title}.") await report.update(ctx)
async def resolve(self, ctx, _id, *, msg=''): """Owner only - Resolves a report.""" if not ctx.message.author.id == constants.OWNER_ID: return report = Report.from_id(_id) await report.resolve(ctx, msg) report.commit() await ctx.send(f"Resolved `{report.report_id}`: {report.title}.")
async def upvote(ctx, _id, *, msg=''): """Adds an upvote to the selected feature request.""" report = Report.from_id(_id) await report.upvote(ctx.message.author.id, msg, ctx) report.subscribe(ctx) await report.update(ctx) report.commit() await ctx.send( f"Ok, I've added a note to `{report.report_id}` - {report.title}.")
async def attach(ctx, report_id, message_id): """Attaches a recent message to a report.""" report = Report.from_id(report_id) try: msg = next(m for m in bot.messages if m.id == message_id) except StopIteration: return await bot.say("I cannot find that message.") await report.addnote(msg.author.id, msg.content) report.commit() await bot.say(f"Ok, I've added a note to `{report.report_id}` - {report.title}.") await report.update(ctx)
async def subscribe(ctx, report_id): """Subscribes to a report.""" report = Report.from_id(report_id) if ctx.message.author.id in report.subscribers: report.unsubscribe(ctx) await ctx.send( f"OK, unsubscribed from `{report.report_id}` - {report.title}.") else: report.subscribe(ctx) await ctx.send( f"OK, subscribed to `{report.report_id}` - {report.title}.") report.commit()
async def rename(self, ctx, report_id, *, name): """Owner only - Changes the title of a report.""" if not ctx.message.author.id == constants.OWNER_ID: return report = Report.from_id(report_id) report.title = name if report.github_issue: await report.edit_title(f"{report.report_id} {report.title}") await report.update(ctx) report.commit() await ctx.send(f"Renamed {report.report_id} as {report.title}.")
async def priority(ctx, _id, pri: int, *, msg=''): """Owner only - Changes the priority of a report.""" if not ctx.message.author.id == OWNER_ID: return report = Report.from_id(_id) report.severity = pri if msg: report.addnote(ctx.message.author.id, f"Priority changed to {pri} - {msg}") report.commit() await report.update(ctx) await bot.say(f"Changed priority of `{report.report_id}`: {report.title} to P{pri}.")
async def pending(ctx, *reports): """Owner only - Marks reports as pending for next patch.""" if not ctx.message.author.id == OWNER_ID: return not_found = 0 for _id in reports: try: report = Report.from_id(_id) except ReportException: not_found += 1 continue report.severity = -2 report.commit() await report.update(ctx) if not not_found: await bot.say(f"Marked {len(reports)} reports as patch pending.") else: await bot.say(f"Marked {len(reports)} reports as patch pending. {not_found} reports were not found.")
async def reidentify(ctx, report_id, identifier): """Owner only - Changes the identifier of a report.""" if not ctx.message.author.id == OWNER_ID: return identifier = identifier.upper() id_num = get_next_report_num(identifier) report = Report.from_id(report_id) new_report = copy.copy(report) await report.resolve(ctx, f"Reassigned as `{identifier}-{id_num}`.", False) report.commit() new_report.report_id = f"{identifier}-{id_num}" msg = await bot.send_message(bot.get_channel(TRACKER_CHAN), embed=new_report.get_embed()) new_report.message = msg.id new_report.commit() await bot.say(f"Reassigned {report.report_id} as {new_report.report_id}.")
async def priority(self, ctx, _id, pri: int, *, msg=''): """Owner only - Changes the priority of a report.""" if not ctx.message.author.id == constants.OWNER_ID: return report = Report.from_id(_id) report.severity = pri if msg: await report.addnote(ctx.message.author.id, f"Priority changed to {pri} - {msg}", ctx) if report.github_issue: await report.update_labels() await report.update(ctx) report.commit() await ctx.send( f"Changed priority of `{report.report_id}`: {report.title} to P{pri}." )
async def unpend(self, ctx, *reports): if not ctx.message.author.id == constants.OWNER_ID: return not_found = 0 for _id in reports: try: report = Report.from_id(_id) except ReportException: not_found += 1 continue report.unpend() await report.update(ctx) report.commit() if not not_found: await ctx.send(f"Unpended {len(reports)} reports.") else: await ctx.send( f"Unpended {len(reports) - not_found} reports. {not_found} reports were not found." )
async def viewreport(ctx, _id): """Gets the detailed status of a report.""" await ctx.send(embed=Report.from_id(_id).get_embed(True, ctx))