mirror of
https://github.com/NovaOSS/nova-cord.git
synced 2024-11-25 15:33:57 +01:00
old changes
This commit is contained in:
parent
e21ecaa619
commit
cafb05ac5d
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -8,7 +8,8 @@
|
|||
"**/Thumbs.db": true,
|
||||
"**/__pycache__": true,
|
||||
"**/.vscode": true,
|
||||
"**/*.map": true
|
||||
"**/*.map": true,
|
||||
"**/*.css.map": true
|
||||
},
|
||||
"hide-files.files": []
|
||||
}
|
|
@ -93,29 +93,31 @@ async def set_credits(interaction, user, amount):
|
|||
return
|
||||
|
||||
try:
|
||||
userinfo = await request_user_by_discord_id(user.id)
|
||||
account = 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:
|
||||
if account.status_code == 404:
|
||||
await embedder.error(interaction, """You don't have an account yet!""", ephemeral=True)
|
||||
return
|
||||
|
||||
account = userinfo.json()
|
||||
account["credits"] = amount
|
||||
|
||||
try:
|
||||
account = account.json()
|
||||
|
||||
requests.put(
|
||||
url=f'http://localhost:2333/users?discord_id={account["auth"]["discord"]}',
|
||||
url=f'http://localhost:2333/users',
|
||||
timeout=3,
|
||||
headers={
|
||||
'Content-Type': 'application/json',
|
||||
'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:
|
||||
|
@ -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)
|
||||
|
||||
async def reset_key(interaction):
|
||||
|
||||
return await embedder.error(interaction, """Not finished yet""", ephemeral=True)
|
||||
|
||||
try:
|
||||
account = await get_account(interaction)
|
||||
|
||||
|
|
20
cord/bot.py
20
cord/bot.py
|
@ -128,29 +128,9 @@ async def music(interaction: nextcord.Interaction):
|
|||
async def resetkey(interaction: nextcord.Interaction):
|
||||
return await accounts.reset_key(interaction)
|
||||
|
||||
async def status_update():
|
||||
guild = bot.get_guild(int(os.getenv('DISCORD_GUILD')))
|
||||
members = guild.members
|
||||
|
||||
await bot.change_presence(
|
||||
activity=nextcord.Activity(
|
||||
type=nextcord.ActivityType.watching,
|
||||
name=f'{len(members)} members'
|
||||
)
|
||||
)
|
||||
|
||||
async def loop_status_update():
|
||||
while True:
|
||||
await status_update()
|
||||
await nextcord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(minutes=1))
|
||||
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
print(f'Online as {bot.user} (ID: {bot.user.id})')
|
||||
|
||||
await api.start(bot)
|
||||
|
||||
# display status as watching + discord guild member count and update every minute
|
||||
bot.loop.create_task(loop_status_update())
|
||||
|
||||
bot.run(os.getenv('DISCORD_TOKEN'))
|
||||
|
|
Loading…
Reference in a new issue