Allow giving credit to other users for GitLab issues

This commit is contained in:
Zeva Rose 2022-03-23 01:25:30 -06:00
parent 2308342de7
commit d3449fc5ed

View file

@ -7,6 +7,7 @@ from dis_snek import InteractionContext, Scale, Snake
from dis_snek.ext.paginators import Paginator
from dis_snek.models.discord.embed import Embed, EmbedField
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
from dis_snek.models.discord.user import Member
from dis_snek.models.snek.application_commands import (
OptionTypes,
SlashCommandChoice,
@ -422,11 +423,16 @@ class GitlabCog(Scale):
await paginator.send(ctx)
@slash_command(
name="gl", sub_cmd_name="report", sub_cmd_description="Report an issue", scopes=guild_ids
@slash_command(name="issue", description="Report an issue on GitLab", scopes=guild_ids)
@slash_option(
name="user",
description="Credit someone else for this issue",
opt_type=OptionTypes.USER,
required=False,
)
@cooldown(bucket=Buckets.USER, rate=1, interval=600)
async def _open_issue(self, ctx: InteractionContext) -> None:
async def _open_issue(self, ctx: InteractionContext, user: Member = None) -> None:
user = user or ctx.author
modal = Modal(
title="Open a new issue on GitLab",
components=[
@ -454,7 +460,7 @@ class GitlabCog(Scale):
return
if not title.startswith("[Discord]"):
title = "[Discord] " + title
desc = f"Opened by `@{ctx.author.username}` on Discord\n\n" + desc
desc = f"Opened by `@{user.username}` on Discord\n\n" + desc
issue = self.project.issues.create(data={"title": title, "description": desc})
embed = build_embed(
title=f"Issue #{issue.id} Created",