joytou commited on
Commit
cc71ee0
1 Parent(s): 5a9ae3b

Add more info for horde api error

Browse files
Files changed (2) hide show
  1. discord_bot.py +3 -3
  2. horde.py +4 -2
discord_bot.py CHANGED
@@ -28,7 +28,7 @@ async def greet(interaction: discord.Interaction, name: str):
28
  async def getKudos(interaction: discord.Interaction):
29
  details = horde.getUserDetails()
30
  if "kudos" not in details:
31
- await interaction.response.send_message(f'Error: {details["code"]} {details["reason"]}')
32
  return
33
  await interaction.response.send_message(f'The amount of Kudos this user has is {details["kudos"]}')
34
 
@@ -36,7 +36,7 @@ async def getKudos(interaction: discord.Interaction):
36
  async def generateStatus(interaction: discord.Interaction, id: str):
37
  details = horde.generateCheck(id)
38
  if "kudos" not in details:
39
- await interaction.response.send_message(f'Error: {details["code"]} {details["reason"]}')
40
  return
41
  if bool(details["is_possible"]) == False:
42
  await interaction.response.send_message("This generation is impossible.")
@@ -47,7 +47,7 @@ async def generateStatus(interaction: discord.Interaction, id: str):
47
  if bool(details["done"]) == True:
48
  generationDetail = horde.generateStatus(id)
49
  if "generations" not in generationDetail:
50
- await interaction.response.send_message(f'Error: {details["code"]} {details["reason"]}')
51
  for i in range(len(generationDetail["generations"])):
52
  await interaction.response.send_message(generationDetail["generations"][i]["img"])
53
  return
 
28
  async def getKudos(interaction: discord.Interaction):
29
  details = horde.getUserDetails()
30
  if "kudos" not in details:
31
+ await interaction.response.send_message(f'Error: {details["code"]} {details["reason"]} {details["rc"]}')
32
  return
33
  await interaction.response.send_message(f'The amount of Kudos this user has is {details["kudos"]}')
34
 
 
36
  async def generateStatus(interaction: discord.Interaction, id: str):
37
  details = horde.generateCheck(id)
38
  if "kudos" not in details:
39
+ await interaction.response.send_message(f'Check Error: {details["code"]} {details["reason"]} {details["rc"]}')
40
  return
41
  if bool(details["is_possible"]) == False:
42
  await interaction.response.send_message("This generation is impossible.")
 
47
  if bool(details["done"]) == True:
48
  generationDetail = horde.generateStatus(id)
49
  if "generations" not in generationDetail:
50
+ await interaction.response.send_message(f'Status Error: {generationDetail["code"]} {generationDetail["reason"]} {generationDetail["rc"]}')
51
  for i in range(len(generationDetail["generations"])):
52
  await interaction.response.send_message(generationDetail["generations"][i]["img"])
53
  return
horde.py CHANGED
@@ -15,7 +15,8 @@ def getResponseByGet(url):
15
  else:
16
  return {
17
  "code": response.status_code,
18
- "reason": response.reason
 
19
  }
20
 
21
  def getResponseByPost(url):
@@ -29,7 +30,8 @@ def getResponseByPost(url):
29
  else:
30
  return {
31
  "code": response.status_code,
32
- "reason": response.reason
 
33
  }
34
 
35
  def getUserDetails():
 
15
  else:
16
  return {
17
  "code": response.status_code,
18
+ "reason": response.reason,
19
+ "rc": response.rc
20
  }
21
 
22
  def getResponseByPost(url):
 
30
  else:
31
  return {
32
  "code": response.status_code,
33
+ "reason": response.reason,
34
+ "rc": response.rc
35
  }
36
 
37
  def getUserDetails():