mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-25 21:33:58 +01:00
Compare commits
2 commits
b08f24b9c9
...
b0334021e9
Author | SHA1 | Date | |
---|---|---|---|
b0334021e9 | |||
5540143da9 |
|
@ -81,3 +81,41 @@ Please report this issue to the staff!""", ephemeral=True)
|
||||||
await embedder.info(interaction, f"""### Credits of {user.name}
|
await embedder.info(interaction, f"""### Credits of {user.name}
|
||||||
Amount: **{amount_credits if amount_credits < 1000000 else '∞'}**
|
Amount: **{amount_credits if amount_credits < 1000000 else '∞'}**
|
||||||
""", ephemeral=True)
|
""", ephemeral=True)
|
||||||
|
|
||||||
|
async def set_credits(interaction, user, amount):
|
||||||
|
if not interaction.user.guild_permissions.administrator:
|
||||||
|
await embedder.error(interaction, """Sorry, you don't have the permission to do that.""", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
userinfo = await request_user_by_discord_id(user.id)
|
||||||
|
|
||||||
|
except Exception as exc:
|
||||||
|
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)
|
||||||
|
raise exc
|
||||||
|
|
||||||
|
if userinfo.status_code == 404:
|
||||||
|
await embedder.error(interaction, """You don't have an account yet!""", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
account = userinfo.json()
|
||||||
|
account["credits"] = amount
|
||||||
|
|
||||||
|
try:
|
||||||
|
requests.put(
|
||||||
|
url=f'https://api.nova-oss.com/users?discord_id={account["auth"]["discord"]}',
|
||||||
|
timeout=3,
|
||||||
|
headers={
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': os.getenv('CORE_API_KEY')
|
||||||
|
},
|
||||||
|
data=json.dumps(account)
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception as exc:
|
||||||
|
await embedder.error(interaction, """Sorry, there was an error while setting your credits.
|
||||||
|
Please report this issue to the staff!""", ephemeral=True)
|
||||||
|
raise exc
|
||||||
|
|
||||||
|
await embedder.ok(interaction, f"""Successfully set the credits of {user.name} to **{amount}**.""", ephemeral=True)
|
||||||
|
|
|
@ -79,6 +79,10 @@ async def credits_(interaction: nextcord.Interaction):
|
||||||
async def credits_of(interaction: nextcord.Interaction, user: nextcord.User):
|
async def credits_of(interaction: nextcord.Interaction, user: nextcord.User):
|
||||||
return await accounts.get_credits_of(interaction, user)
|
return await accounts.get_credits_of(interaction, user)
|
||||||
|
|
||||||
|
@bot.slash_command(description='Manually set the credits of a certain user. Admin only.')
|
||||||
|
async def set_credits(interaction: nextcord.Interaction, user: nextcord.User, amount: int):
|
||||||
|
return await accounts.set_credits(interaction, user, amount)
|
||||||
|
|
||||||
@bot.slash_command(description='View examples and tips for implementing NovaAI\'s API.')
|
@bot.slash_command(description='View examples and tips for implementing NovaAI\'s API.')
|
||||||
async def tutorial(interaction: nextcord.Interaction,
|
async def tutorial(interaction: nextcord.Interaction,
|
||||||
how_can_i: str = SlashOption(#
|
how_can_i: str = SlashOption(#
|
||||||
|
|
Loading…
Reference in a new issue