csgo-league/csgo-league-bot

Add end command

cameronshinn opened this issue · 5 comments

Add a command to end a match by the match's ID. There is now an endpoint to do this on the web side, so a corresponding method needs to be added into the ApiHelper as well as the command in the MatchCog. Should require admin permissions.

Calling the command should look like: q!end 123456

Open to other ideas on names for the command.

Okay @thboss we'd have to change the endpoint to a POST request instead so we can give the match ID.

q!end is not working throwing this error
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 83, in
wrapped
ret = await coro(args, **kwargs)
File "/home/sammy/ftp/files/bot/cogs/match.py", line 1032, in end
if await self.bot.api_helper.end_match(args[0]):
File "/home/sammy/ftp/files/bot/helpers/api.py", line 252, in end_match
resp_json = await resp.json()
File "/usr/local/lib/python3.6/dist-packages/aiohttp/client_reqrep.py", line 1031, in js
on
headers=self.headers)
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpe
cted mimetype: text/html; charset=utf-8', url=URL('https://karma5v5.comnow.club/home%27)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py", line 892, in
invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 797, in
invoke
await injected(ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 92, in
wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ContentTypeEr
ror: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8
', url=URL('https://karma5v5.comnow.club/home%27)

@thewickerman22 the issue looks like somehow the endpoint to end the match is redirecting you to the home page, and the error is cause the homepage is returning an HTML response when a JSON is expected. I am not sure that the endpoint for the end command is working properly yet? The bot doesn't even have and end command right now, so I am assuming you are using @thboss's fork

@thewickerman22 the issue looks like somehow the endpoint to end the match is redirecting you to the home page, and the error is cause the homepage is returning an HTML response when a JSON is expected. I am not sure that the endpoint for the end command is working properly yet? The bot doesn't even have and end command right now, so I am assuming you are using @thboss's fork
yes i m using his fork. before his latest update it was working fine. after his last update as well as update of the web panel broke something.