static void Main(string[] args) { XMLWrite test = new XMLWrite(); test.WriteXML(); XMLRead test2 = new XMLRead(); test2.ReadXML(); Console.ReadLine(); }
public async Task johnAsync() { List <string> rndJohn = new List <string>(); rndJohn.Add("Here is a recent picture of @Rolfokvar - http://i.imgur.com/kfWjfcq.png"); rndJohn.Add("John has a unique view on Ascended Chest drops - http://i.imgur.com/1B3RAkp.png"); rndJohn.Add("Johns favourite song is - https://www.youtube.com/watch?v=5NV6Rdv1a3I&feature=youtu.be"); Random rnd = new Random(); string johnMessage = rndJohn[rnd.Next(0, rndJohn.Count)]; XMLWrite.ReadThenWrite(commandName, clickAmount); XMLRead.ReadXML(commandName); int newAmount = XMLRead.commandAmountRead; await ReplyAsync(johnMessage + " This command has been called " + newAmount + " times."); return; }
private void ShowSaveAsFileDialog(string filter) { SaveFileDialog sfd = new SaveFileDialog(); { sfd.RestoreDirectory = true; sfd.FilterIndex = 1; if (filter == "xml") { //sfd.InitialDirectory = Directory.GetCurrentDirectory(); sfd.DefaultExt = ".xml"; sfd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"; sfd.Title = "Save file as XML."; } else if (filter == "doc") { sfd.DefaultExt = "*.doc"; sfd.Filter = "Doc files (*.doc)|*.doc|All files (*.*)|*.*"; sfd.Title = "Save file as Word."; } }; if (sfd.ShowDialog() == DialogResult.OK) { filePath = sfd.FileName; previousPath = Path.GetDirectoryName(sfd.FileName); lastFullNameandFolder = previousPath + "\\" + Path.GetFileName(sfd.FileName); if (filter == "xml") { XMLWrite xwWrite = new XMLWrite(filePath, sysData, columnMaterial, geoTex, soilList); } else if (filter == "doc") { WordExport doc = new WordExport(filePath, richTxtResults.Rtf); } MessageBox.Show("File saved as " + filePath, "File saved.", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void saveFile(string lastFullPath) { string lastPath = lastFullPath; if (String.IsNullOrEmpty(lastPath)) { ShowSaveAsFileDialog("xml"); } else { try { XMLWrite xwWrite = new XMLWrite(lastPath, sysData, columnMaterial, geoTex, soilList); MessageBox.Show("File saved as " + filePath, "File saved.", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Could not save file. Try \"File save as\" " + ex.Message, "Error saved.", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public async Task bannedAsync(string name = "") { //RANDOM DAYS HANDLING, WE'RE JUST CREATE A RANDOM VALUE AND CONVERTING THAT VALUE TO "DAYS" Random rnd = new Random(); float dayss = rnd.Next(1, 2500); TimeSpan t = TimeSpan.FromDays(dayss); string str = t.ToString(@"dd"); string output = str + " days"; //SIMPLE LIST TO PICK A RANDOM RESPONSE FROM List <string> rndBanned = new List <string>(); rndBanned.Add(" https://www.youtube.com/watch?v=9B6bZSpQHxU"); rndBanned.Add(" https://i.imgur.com/O3DHIA5.gif"); string bannedMessage = rndBanned[rnd.Next(0, rndBanned.Count)]; //ARGUMENT HANDLING //IF NO NAME IS ENTERED if (name == "") { //THE BOT WILL RESPOND WITH A GENERIC BAN string fullMessage = "You have requested a ban... now banning the target for " + output + bannedMessage; await ReplyAsync(fullMessage); return; } //IF THE BOT CREATOR IS ENTERED if (name == "Indi" || name == "indi") { //GIT OUT await ReplyAsync("NOT THIS TIME BUSTER BROWN"); return; } //IF "counts" IS ENTERED. IN FUTURE WE'LL BE LISTING A TABLE OF BAN AMOUNTS AND DAYS BANNED. if (name == "counts") { await ReplyAsync("BANNED COUNTS WILL BE HERE AT SOMEPOINT IF I FIGURE IT OUT"); return; } //COMMAND HELP if (name == "help") { await ReplyAsync("PANIC"); return; } //WHEN A TARGET NAME IS ENTERED "!banned someone" else { //WRITE TO THE XML FILE : THE COMMAND NAME, VICTIM NAME, HOW MANY DAYS AND "1" TO ADD 1 TO THE TIMES COMMAND CALLED XMLWrite.BannedXML("banned", name, dayss, 1); //READ THE FILE THAT WAS WRITTEN TO XMLRead.BannedReadXML(name); //SET SOME VARIABLES BASED ON THAT FILE int daysAmount = XMLRead.daysRead; int bannedAmount = XMLRead.commandAmountRead; //SET A STRING BASED ON WHO CALLED THE COMMAND string description = Context.User.ToString() + " has requested a ban!"; //EMBEDBUILDER FUNCTIONS ARE EXPLAINED IN builds.CS //HERE WE'RE FILLING AN EMBED WITH DATA EmbedBuilder builder = new EmbedBuilder(); builder.WithTitle("BAN REQUESTED!").WithDescription(description).WithColor(Color.DarkRed); builder.AddInlineField("Target", name).AddInlineField("Ban Amount", output); builder.AddInlineField("Lifetime Bans", bannedAmount).AddInlineField("Lifetime Days Banned", daysAmount); //REPLY WITH THE RANDOM RESPONSE AND THEN THE EMBED await ReplyAsync(bannedMessage); await ReplyAsync("", false, builder.Build()); return; } }