Added a Admin-Only command for admins (Maintainers) to see the credits of other users

This commit is contained in:
henceiusegentoo 2023-08-08 14:27:31 +02:00
parent 02f7780761
commit c9ea838d5d
2 changed files with 28 additions and 0 deletions

View file

@ -57,3 +57,27 @@ async def get_credits(interaction):
await embedder.info(interaction, f"""### Your credits
Amount: **{amount_credits if amount_credits < 1000000 else ''}**
""", ephemeral=True)
async def get_credits_of(interaction, user):
if "Maintainer" not in interaction.user.roles:
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()
amount_credits = account["credits"]
await embedder.info(interaction, f"""### Credits of {user.name}
Amount: **{amount_credits if amount_credits < 1000000 else ''}**
""", ephemeral=True)

View file

@ -75,6 +75,10 @@ async def account(interaction: nextcord.Interaction):
async def credits_(interaction: nextcord.Interaction):
return await accounts.get_credits(interaction)
@bot.slash_command(description='Get credits of a certain user. Admin only.')
async def credits_of(interaction: nextcord.Interaction, user: nextcord.User):
return await accounts.get_credits_of(interaction, user)
@bot.slash_command(description='View examples and tips for implementing NovaAI\'s API.')
async def tutorial(interaction: nextcord.Interaction,
how_can_i: str = SlashOption(#