Allow giving credit to other users for GitLab issues
This commit is contained in:
parent
2308342de7
commit
d3449fc5ed
1 changed files with 10 additions and 4 deletions
|
@ -7,6 +7,7 @@ from dis_snek import InteractionContext, Scale, Snake
|
||||||
from dis_snek.ext.paginators import Paginator
|
from dis_snek.ext.paginators import Paginator
|
||||||
from dis_snek.models.discord.embed import Embed, EmbedField
|
from dis_snek.models.discord.embed import Embed, EmbedField
|
||||||
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
|
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 (
|
from dis_snek.models.snek.application_commands import (
|
||||||
OptionTypes,
|
OptionTypes,
|
||||||
SlashCommandChoice,
|
SlashCommandChoice,
|
||||||
|
@ -422,11 +423,16 @@ class GitlabCog(Scale):
|
||||||
|
|
||||||
await paginator.send(ctx)
|
await paginator.send(ctx)
|
||||||
|
|
||||||
@slash_command(
|
@slash_command(name="issue", description="Report an issue on GitLab", scopes=guild_ids)
|
||||||
name="gl", sub_cmd_name="report", sub_cmd_description="Report an issue", 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)
|
@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(
|
modal = Modal(
|
||||||
title="Open a new issue on GitLab",
|
title="Open a new issue on GitLab",
|
||||||
components=[
|
components=[
|
||||||
|
@ -454,7 +460,7 @@ class GitlabCog(Scale):
|
||||||
return
|
return
|
||||||
if not title.startswith("[Discord]"):
|
if not title.startswith("[Discord]"):
|
||||||
title = "[Discord] " + title
|
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})
|
issue = self.project.issues.create(data={"title": title, "description": desc})
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title=f"Issue #{issue.id} Created",
|
title=f"Issue #{issue.id} Created",
|
||||||
|
|
Loading…
Add table
Reference in a new issue