mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-26 00:23:57 +01:00
Compare commits
No commits in common. "b0334021e9869fc56d7638f39341a0d8411060f6" and "b08f24b9c9a4bfda7f6292cb2b70df7aef04acd5" have entirely different histories.
b0334021e9
...
b08f24b9c9
|
@ -81,41 +81,3 @@ 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,10 +79,6 @@ 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