public async Task TrackUser(DiscordGuild g, ulong discordID, string uplayNickname, string relevantChannelName) { try { // SocketGuildUser trackedPerson = g.GetSingleUser(discordID); string queryR6ID = await _data.QueryMapping(discordID); if (queryR6ID != null) { await g.ReplyToUser("Vas discord ucet uz sledujeme. / We are already tracking your Discord account.", relevantChannelName, discordID); return; } string r6TabId = await TRNHttpProvider.GetID(uplayNickname); if (r6TabId == null) { await g.ReplyToUser("Nepodarilo se nam najit vas Uplay ucet. / We failed to find your Uplay account data.", relevantChannelName, discordID); return; } await _data.InsertIntoMapping(discordID, r6TabId); await g.ReplyToUser($"Nove sledujeme vase uspechy pod prezdivkou {uplayNickname} na platforme PC. / We now track you as {uplayNickname} on PC.", relevantChannelName, discordID); // Update the newly added user. bool ret = await Bot.Instance.UpdateOne(discordID); if (ret) { // Print user's rank too. Rank r = await TRNHttpProvider.GetCurrentRank(r6TabId); if (r.Digits()) { await g.ReplyToUser($"Aktualne vidime vas rank jako {r.FullPrint()}", relevantChannelName, discordID); } else { await g.ReplyToUser($"Aktualne vidime vas rank jako {r.CompactFullPrint()}", relevantChannelName, discordID); } } else { await g.ReplyToUser("Stala se chyba pri nastaven noveho ranku.", relevantChannelName, discordID); } } catch (RankParsingException e) { await g.ReplyToUser("Communication to the R6Tab server failed. Please try again or contact the local Discord admins.", relevantChannelName, discordID); await g.Reply("Pro admina: " + e.Message, relevantChannelName); } }
public async Task AddLoudRoles(Discord.WebSocket.SocketUser Author, Rank rank) { var Us = (Discord.WebSocket.SocketGuildUser)Author; // First add the non-digit role. string nonDigitLoudName = rank.CompactMetalPrint(); var LoudRole = _socket.Roles.FirstOrDefault(x => x.Name == nonDigitLoudName); if (LoudRole != null) { await Us.AddRoleAsync(LoudRole); } // Then, if the rank has a digit role, add that too. if (rank.Digits()) { string digitLoudName = rank.CompactFullPrint(); var LoudDigitRole = _socket.Roles.FirstOrDefault(x => x.Name == digitLoudName); if (LoudDigitRole != null) { await Us.AddRoleAsync(LoudDigitRole); } } }
public async Task Track(string nick) { if (!await InstanceCheck()) { return; } var author = (Discord.WebSocket.SocketGuildUser)Context.Message.Author; try { string queryR6ID = await Bot.Instance._data.QueryMapping(author.Id); if (queryR6ID != null) { await ReplyAsync(author.Username + ": Vas discord ucet uz sledujeme. / We are already tracking your Discord account."); return; } string r6TabId = await TRNHttpProvider.GetID(nick); if (r6TabId == null) { await ReplyAsync(author.Username + ": Nepodarilo se nam najit vas Uplay ucet. / We failed to find your Uplay account data."); return; } await Bot.Instance._data.InsertIntoMapping(author.Id, r6TabId); await ReplyAsync(author.Username + ": nove sledujeme vase uspechy pod prezdivkou " + nick + " na platforme PC. / We now track you as " + nick + " on PC."); // Update the newly added user. bool ret = await Bot.Instance.UpdateOne(author.Id); if (ret) { // Print user's rank too. Rank r = await TRNHttpProvider.GetCurrentRank(r6TabId); if (r.Digits()) { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.FullPrint()); } else { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.CompactFullPrint()); } } else { await ReplyAsync(author.Username + ": Stala se chyba pri nastaven noveho ranku."); } } catch (RankParsingException) { await ReplyAsync("Communication to the R6Tab server failed. Please try again or contact the local Discord admins."); return; } }
public async Task Rank() { if (!await InstanceCheck()) { return; } var author = (Discord.WebSocket.SocketGuildUser)Context.Message.Author; string authorR6TabId = await Bot.Instance._data.QueryMapping(author.Id); if (authorR6TabId == null) { await ReplyAsync(author.Username + ": vas rank netrackujeme, tak nemuzeme slouzit."); return; } else { try { Rank r = await TRNHttpProvider.GetCurrentRank(authorR6TabId); if (r.Digits()) { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.FullPrint()); } else { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.CompactFullPrint()); } } catch (RankParsingException) { await ReplyAsync("Communication to the R6Tab server failed. Please try again or contact the Discord admins."); } } }
public async Task Update() { if (!await InstanceCheck()) { return; } try { var author = (Discord.WebSocket.SocketGuildUser)Context.Message.Author; string authorR6TabId = await Bot.Instance._data.QueryMapping(author.Id); if (authorR6TabId == null) { await ReplyAsync(author.Username + ": vas rank netrackujeme, tak nemuzeme slouzit."); return; } bool ret = await Bot.Instance.UpdateOne(author.Id); if (ret) { await ReplyAsync(author.Username + ": Aktualizovali jsme vase MMR a rank. Nezapomente, ze to jde jen jednou za 30 minut."); // Print user's rank too. Rank r = await TRNHttpProvider.GetCurrentRank(authorR6TabId); if (r.Digits()) { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.FullPrint()); } else { await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.CompactFullPrint()); } } else { await ReplyAsync(author.Username + ": Stala se chyba pri aktualizaci ranku, mate stale predchozi rank."); } } catch (RankParsingException) { await ReplyAsync("Communication to the R6Tab server failed. Please try again or contact the local Discord admins."); return; } }