Package: discloud
Installingpip install discloudDev installingNote: needhttps://git-scm.comto downloadpip install git+https://github.com/discloud/python-discloud-status@masterUsageGet StartedFirst of all, you need to get your Discloud API-Token. You can create a new one by typing.apiin theDiscloud Server.
If you're in trouble on getting your Discloud API-Token, you can DM the Ticket bot (DisCloud ModMail#6424) in the server. The supporters will be glad on helping youUnderstanding the returnsActionAll methods that doesn't get information(e.g. start app/change ram/add mod) returns anAction. It has.statusattribute, which is either "ok" when no issues happened, or "error" when something happened. It also contains.messageattribute which is always returned when an error ocurrs, and is given on almost all actions.BackupBackup has a.urlattribute that gives the application's backup link.LogsLogs has a.smallattribute which returns the last ~1800 chars of your app logs, and a.fullattribute that gives the complete logsUserWIPApplicationWIPCreating a clientimportdiscloudclient=discloud.Client("API-Token")Userinfouser=awaitclient.user_info()print(f"ID: '{user.id}'")plan=user.planprint(f"Plan '{plan}'")print(f"Expire date '{plan.expire_date}'")print(f"Ends in '{plan.expires_in}'")print(f"Used ram '{user.using_ram}'")print(f"Total ram '{user.total_ram}'")print(f"Locale '{user.locale}'")ApplicationInfobot=awaitclient.app_info(target="APP_ID")print(f"ID '{bot.id}'")print(f"Status '{bot.status}'")print(f"CPU '{bot.cpu}'")print(f"Memory '{bot.memory}'")print(f"Memory available '{bot.memory.available}'")print(f"Using memory '{bot.memory.using}'")print(f"Mem usada '{bot.memory.using}'")print(f"SSD '{bot.ssd}'")print(f"Download '{bot.net_info.download}'")print(f"Upload '{bot.net_info.upload}'")print(f"Online since '{bot.online_since}'")print(f"Started at '{bot.start_date}'")LogsClient.app_logs()returns a Logs. The.logsattribute will give you the full logs content,.small_logswill give the last 1800 characterslogs=awaitclient.logs(target="APP_ID")print(logs.full)# complete logsprint(logs.small)# around last 1800 characters of your logsStart/Restart/StopClient.start()/Client.restart()/Client.stop()returns anAction.# note: don't expect to get the results there if you use inside of your bot since its going to get shutdownstart_result=awaitclient.start(target="APP_ID")restart_result=awaitclient.restart(target="APP_ID")stop_result=awaitclient.stop(target="APP_ID")print(start_result)# See if the start was successfulprint(restart_result)# See if the restart was successfulprint(stop_result)# See if the stop was successfulCommitClient.commit()returns anAction.# note: this always restart your bot so you won't get a result if its inside of your botfile=discloud.File("eggs.zip")# Must be .zipresult=awaitclient.commit(app_id="APP_ID",file=file)print(result.message)# See if the commit was successfulBackupClient.backup()returns a Backup. The.urlattribute will give you the linkbackup=awaitclient.backup(target="APP_ID")print(backup.url)# Get backup urlUpdate RamClient.ram()returns anAction.result=awaitclient.ram(app_id="APP_ID",NEW_RAM)print(result.message)# See if ram memory was updatedUploadClient.upload_app()returns anAction.
Note: the .zip must have adiscloud.configfile, more info atdocumentationresult=awaitclient.upload_app(file=discloud.File("my_bot.zip"))print(result.message)# See if the app was successfully addedDeleteClient.delete_app()returns anAction.result=awaitclient.delete_app(app_id="APP_ID")print(result.message)# See if the app was successfully deletedMods SystemFirst you need to setup a specific client to manage bot mods or manage a bot as mod.importdiscloudclient=discloud.Client("API-Token")mod_client=discloud.ModManager(client,"APP_ID")Second, be aware of what mods can currently do, actually they can have one or more of these permissions:
"start_app", "stop_app", "restart_app", "logs_app", "commit_app", "edit_ram", "backup_app", "status_app"Application OwnersTo add a moderator to your app you must first have aGold Planor above.Adding a moderatorModManager.add_mod()permissions=["start_app"]awaitmod_client.add_mod(mod_id="MOD_ID",permissions)Removing a moderatorModManager.remove_mod()awaitmod_client.remove_mod(mod_id="MOD_ID")Changing moderator permissionsModManager.edit_mod_perms()new_permissions=["start_app","restart_app"]# note: this remove existing perms if they are not thereawaitmod_client.edit_mod_perms(mod_id="MOD_ID",new_permissions)Getting all moderatorsModManager.get_mods()mods=awaitmod_client.get_mods()print(mods)#Application moderatorsFor each command you can do you will need the respective permission as mentioned above
Commands:ModManager.start(),ModManager.restart(),ModManager.stop(),ModManager.commit(),ModManager.backup(),ModManager.logs(),ModManager.ram(),ModManager.status(),