public async Task ListBackupsDiscord(DSharpPlus.EventArgs.MessageCreateEventArgs e, string src) { var embed = Tools.GenerateEmbed("Fetching...", "", "", DSharpPlus.Entities.DiscordColor.Yellow); var msg = await e.Message.RespondAsync(embed : embed); ArkIOInterface_SavedContext context = new ArkIOInterface_SavedContext(); context.msg = msg; CreateRequest(RequestType.DirList, src, "", 0, 0, new RSN_ClientResponse(ListBackupsCallback), context); }
private async Task TryEditMessage(int id, DSharpPlus.Entities.DiscordEmbedBuilder embed) { try { ArkIOInterface_SavedContext context = savedContexts[id]; await context.msg.ModifyAsync(embed : embed); } catch { //Not found } }
public async Task BackupServerDiscord(DSharpPlus.EventArgs.MessageCreateEventArgs e, string src, string destFolder) { var embed = Tools.GenerateEmbed("Backing Up...", "0% Complete", "Wait a moment. Server is backing up.", DSharpPlus.Entities.DiscordColor.Yellow, "https://romanport.com/static/ArkBot/loader.gif"); var msg = await e.Message.RespondAsync(embed : embed); //Create dest file DateTime now = DateTime.Now; bool isAm = now.Hour < 12; string amPm = "AM"; if (isAm) { amPm = "PM"; } string fileName = "Backup at " + (now.Hour % 12).ToString() + "_" + now.Minute.ToString() + "_" + amPm + " " + now.Month.ToString() + "_" + now.Day.ToString() + "_" + now.Year.ToString() + " " + DateTime.UtcNow.Ticks.ToString() + ".zip"; string dest = destFolder.TrimEnd('\\') + "\\" + fileName; //Actually commit ArkIOInterface_SavedContext context = new ArkIOInterface_SavedContext(); context.msg = msg; CreateRequest(RequestType.Compress, src, dest, 0, 0, new RSN_ClientResponse(BackupServerCallback), context); }
private void CreateRequest(RequestType type, string strOne, string strTwo, int intOne, int intTwo, RSN_ClientResponse callback = null, ArkIOInterface_SavedContext context = null) { ArkIOInterfaceRequestData data = new ArkIOInterfaceRequestData(); data.strArgOne = strOne; data.strArgTwo = strTwo; data.intArgOne = intOne; data.intArgTwo = intTwo; data.type = type; if (callback == null) { callback = new RSN_ClientResponse(Callback); } int id = client.SendData(callback, data); if (context != null) { savedContexts.Add(id, context); } }