public async Task RewardUserAsync([Remainder] string args = "") { if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN)) { return; } if (string.IsNullOrWhiteSpace(args)) { await ReplyAsync(BotUtils.KamtroText("Please specify a user!")); return; } // This command is used as an easy way to give a user rewards after winning a tournament. List <SocketGuildUser> users = BotUtils.GetUsers(args); if (users.Count == 0) { await ReplyAsync(BotUtils.KamtroText("I can't find a user with that name, make sure the name is spelt correctly!")); return; } else if (users.Count > 10) { await ReplyAsync(BotUtils.KamtroText("Please be more specific! You can attach a discriminator if you need to (Username#1234)")); return; } else if (users.Count == 1) { await RewardUser(users[0]); } else { UserSelectionEmbed use = new UserSelectionEmbed(users, RewardUser, BotUtils.GetGUser(Context)); await use.Display(Context.Channel); } }
public override async Task PerformMessageAction(SocketUserMessage message) { await base.PerformMessageAction(message); // first start off with the base func // now for special rendering if (PageNum == 2 || PageNum == 4 || PageNum == 9) { // Autofill. List <SocketGuildUser> users; switch (PageNum) { case 2: users = BotUtils.GetUsers(ServerUsername); break; case 4: users = BotUtils.GetUsers(ServerUsername4); break; case 9: users = BotUtils.GetUsers(ServerUsername9); break; default: users = new List <SocketGuildUser>(); break; } SocketGuildUser user; if (users.Count < 1) { // fail check if (PageNum == 2) { InputFields[PageNum][CursorPos].SetValue($"Unable to find user: {ServerUsername}"); } else if (PageNum == 4) { InputFields[PageNum][CursorPos].SetValue($"Unable to find user: {ServerUsername4}"); } else if (PageNum == 9) { InputFields[PageNum][CursorPos].SetValue($"Unable to find user: {ServerUsername9}"); } Autofill = null; } else { user = users[0]; if (PageNum == 2 || PageNum == 4 || PageNum == 9) { InputFields[PageNum][CursorPos].SetValue(user.Mention); } Autofill = user; } await UpdateEmbed(); } }
public async Task GiveItemAsync([Remainder] string args = "") { if (!ServerData.HasPermissionLevel(BotUtils.GetGUser(Context), ServerData.PermissionLevel.ADMIN)) { return; } List <string> data = args.Split(' ').ToList(); int id_ind = data.Count - 2; int count_ind = data.Count - 1; uint id; int count; if (!uint.TryParse(data[id_ind], out id) || ItemManager.GetItem(ItemId) == null) { await ReplyAsync(BotUtils.KamtroText("Please specify a valid item ID")); return; } if (!int.TryParse(data[count_ind], out count)) { await ReplyAsync(BotUtils.KamtroText("The count must be over 0!")); return; } ItemId = id; Count = count; data.RemoveRange(id_ind, 2); string search = ""; foreach (string s in data) { search += $"{s} "; } List <SocketGuildUser> users = BotUtils.GetUsers(search.Trim(' ')); if (users.Count == 0) { await ReplyAsync(BotUtils.KamtroText("I can't find a user with that name, make sure the name is spelt correctly!")); return; } else if (users.Count > 10) { await ReplyAsync(BotUtils.KamtroText("Please be more specific! You can attach a discriminator if you need to (Username#1234)")); return; } else if (users.Count == 1) { await GiveItem(users[0]); } else { UserSelectionEmbed use = new UserSelectionEmbed(users, GiveItem, BotUtils.GetGUser(Context)); await use.Display(Context.Channel); } }