mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-25 16:33:57 +01:00
Added a Admin-Only command for admins (Maintainers) to see the credits of other users
This commit is contained in:
parent
02f7780761
commit
c9ea838d5d
|
@ -57,3 +57,27 @@ async def get_credits(interaction):
|
||||||
await embedder.info(interaction, f"""### Your credits
|
await embedder.info(interaction, f"""### Your credits
|
||||||
Amount: **{amount_credits if amount_credits < 1000000 else '∞'}**
|
Amount: **{amount_credits if amount_credits < 1000000 else '∞'}**
|
||||||
""", ephemeral=True)
|
""", 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)
|
|
@ -75,6 +75,10 @@ async def account(interaction: nextcord.Interaction):
|
||||||
async def credits_(interaction: nextcord.Interaction):
|
async def credits_(interaction: nextcord.Interaction):
|
||||||
return await accounts.get_credits(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.')
|
@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