Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Command("sync")]
- public async Task sync(CommandContext ctx) {
- /*
- * MongoDb
- */
- Dictionary<string, ulong> nametoid = new Dictionary<string, ulong> ();
- nametoid.Add("Paulo",155774074885242880);
- nametoid.Add("TheSheepFM 🌵",230127500179668992);
- nametoid.Add("Wysel",272792153623887872);
- nametoid.Add("Fereis",248151841651687424);
- nametoid.Add("CNaville",205133485428572160);
- nametoid.Add("[UBGE] Luiz", 322745409074102282);
- nametoid.Add("[UBGE] Roberto M.", 218160728496930816);
- nametoid.Add("injured", 252489453807861770);
- nametoid.Add("Injured", 252489453807861770);
- nametoid.Add("TheSheepFM", 230127500179668992);
- nametoid.Add("[UBGE] Léo Freitas", 95614784350715904);
- nametoid.Add("[UBGE] Ale184", 173480386343469056);
- nametoid.Add("CØNGO", 95614784350715904);
- var client = new MongoClient();
- var local = client.GetDatabase(UBGEbot.MongoConfig.DbName);
- var Infra = local.GetCollection<Infracao>("Infra");
- /*
- * Google Sheets
- */
- var read = new GoogleSheets.Read();
- var responce = await read.This(UBGEbot.ApiConfig.InfracaoID, UBGEbot.ApiConfig.InfracaoRange);
- List<Infracao> infracoes = new List<Infracao>();
- foreach (var row in responce) {
- if (!String.IsNullOrWhiteSpace(row[0].ToString())) {
- Infracao infra = new Infracao();
- infra.dataInfracao = DateTime.Parse(row[0].ToString());
- infra.idInfrator = ulong.Parse(row[1].ToString());
- if (nametoid.ContainsKey(row[4].ToString()))
- {
- infra.idStaff = nametoid[row[4].ToString()];
- }
- else {
- infra.idStaff = nametoid["Paulo"];
- }
- infra.preso = false;
- infra.motivoInfracao = row[3].ToString();
- var x = new LogPrisao();
- x.tempo = "Sem dados";
- x.cargos = null;
- infra.dadosPrisao = x;
- await Infra.InsertOneAsync(infra);
- Console.WriteLine($"Infração adicionada : {responce.IndexOf(row)} / {responce.Count}");
- }
- }
- await ctx.RespondAsync("DB Sincronizada com o GoogleSheets");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement