mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-25 16:43:58 +01:00
Fixed setcredits and resetkey
This commit is contained in:
parent
e21ecaa619
commit
c22fe673ba
|
@ -93,29 +93,31 @@ async def set_credits(interaction, user, amount):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
userinfo = await request_user_by_discord_id(user.id)
|
account = await request_user_by_discord_id(user.id)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
await embedder.error(interaction, """Sorry, there was an error while checking if you have an account.
|
await embedder.error(interaction, """Sorry, there was an error while checking if you have an account.
|
||||||
Please report this issue to the staff!""", ephemeral=True)
|
Please report this issue to the staff!""", ephemeral=True)
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
if userinfo.status_code == 404:
|
if account.status_code == 404:
|
||||||
await embedder.error(interaction, """You don't have an account yet!""", ephemeral=True)
|
await embedder.error(interaction, """You don't have an account yet!""", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
account = userinfo.json()
|
|
||||||
account["credits"] = amount
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
account = account.json()
|
||||||
|
|
||||||
requests.put(
|
requests.put(
|
||||||
url=f'http://localhost:2333/users?discord_id={account["auth"]["discord"]}',
|
url=f'http://localhost:2333/users',
|
||||||
timeout=3,
|
timeout=3,
|
||||||
headers={
|
headers={
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': os.getenv('CORE_API_KEY')
|
'Authorization': os.getenv('CORE_API_KEY')
|
||||||
},
|
},
|
||||||
data=json.dumps(account)
|
data=json.dumps({
|
||||||
|
"discord_id": account["auth"]["discord"],
|
||||||
|
"updates": {"$set": {"credits": amount}}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
@ -126,9 +128,6 @@ Please report this issue to the staff!""", ephemeral=True)
|
||||||
await embedder.ok(interaction, f"""Successfully set the credits of {user.name} to **{amount}**.""", ephemeral=True)
|
await embedder.ok(interaction, f"""Successfully set the credits of {user.name} to **{amount}**.""", ephemeral=True)
|
||||||
|
|
||||||
async def reset_key(interaction):
|
async def reset_key(interaction):
|
||||||
|
|
||||||
return await embedder.error(interaction, """Not finished yet""", ephemeral=True)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
account = await get_account(interaction)
|
account = await get_account(interaction)
|
||||||
|
|
||||||
|
@ -165,4 +164,4 @@ async def new_api_key() -> str:
|
||||||
|
|
||||||
new_api_key = f'nv-{prefix}{infix}{suffix}'
|
new_api_key = f'nv-{prefix}{infix}{suffix}'
|
||||||
|
|
||||||
return new_api_key
|
return new_api_key
|
||||||
|
|
Loading…
Reference in a new issue