Add command for detailed view of request
This commit is contained in:
parent
07a7b25964
commit
21f766b6d2
@ -216,7 +216,7 @@ class Tickets(commands.Cog):
|
|||||||
@commands.command()
|
@commands.command()
|
||||||
async def view(self, ctx, id=None):
|
async def view(self, ctx, id=None):
|
||||||
if not id:
|
if not id:
|
||||||
await ctx.send('Please include at least one Request ID to close.')
|
await ctx.send('Please include the id of the request you would like to view.')
|
||||||
return
|
return
|
||||||
|
|
||||||
admin = False
|
admin = False
|
||||||
@ -235,29 +235,25 @@ class Tickets(commands.Cog):
|
|||||||
request = await request_resp.json()
|
request = await request_resp.json()
|
||||||
requestor = ctx.guild.get_member(int(request['author']))
|
requestor = ctx.guild.get_member(int(request['author']))
|
||||||
if requestor == ctx.author or admin:
|
if requestor == ctx.author or admin:
|
||||||
pag = Paginator(self.bot)
|
pag = Paginator(self.bot, prefix='```md', suffix='```')
|
||||||
title = (f"<{'Request ID':^20} {'Requested By':^20}>\n"
|
header = f''
|
||||||
f"<{request['id']:^20} {requestor.display_name if requestor else 'None':^20}>")
|
if request_resp.status == 200:
|
||||||
orig_channel = ctx.guild.get_channel(int(request.get('channel')))
|
request = await request_resp.json()
|
||||||
comments_resp = await self.bot.aio_session.get(
|
requestor = ctx.guild.get_member(int(request["author"]))
|
||||||
f'{self.bot.api_base}/messages/{ctx.guild.id}/requests/{request["id"]}/comments/',
|
header += (f'Original Request by {requestor.mention if requestor else "`User cannot be found`"}:\n'
|
||||||
headers=self.bot.auth_header)
|
f'```{request["content"]}```')
|
||||||
comments_text = 'Comments: '
|
pag.set_header(header)
|
||||||
if comments_resp.status == 200:
|
|
||||||
comments_text += '\n'
|
if request.get('comments'):
|
||||||
for comment in await comments_resp.json():
|
comments = request['comments']
|
||||||
|
for comment in comments:
|
||||||
author = ctx.guild.get_member(int(comment['author']))
|
author = ctx.guild.get_member(int(comment['author']))
|
||||||
comments_text += f'{author.display_name}: {comment["content"]}\n\n'
|
pag.add(f'{author.display_name}: {comment["content"]}', keep_intact=True)
|
||||||
else:
|
if ctx.author != requestor and requestor:
|
||||||
comments_text += 'None'
|
for page in pag.pages(page_headers=False):
|
||||||
pag.add(f"\n\n{title}\n"
|
await requestor.send(page)
|
||||||
f"{request['content']}\n\n"
|
book = Book(pag, (None, ctx.channel, self.bot, ctx.message))
|
||||||
f"{comments_text}"
|
await book.create_book()
|
||||||
f"Requested at: "
|
|
||||||
f"{request['requested_at'].split('.')[0].replace('T', ' ')} GMT\n"
|
|
||||||
f"In {orig_channel.name if orig_channel else 'N/A'}", keep_intact=True)
|
|
||||||
for page in pag.pages():
|
|
||||||
await ctx.send(page)
|
|
||||||
else:
|
else:
|
||||||
await ctx.send('That is not your request to close.')
|
await ctx.send('That is not your request to close.')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user