コード例 #1
0
ファイル: ProfileModule.cs プロジェクト: DavidXLiu/Kamtro-Bot
        public async Task RepUserAsync([Remainder] string username = "")
        {
            TimeSpan ts = BotUtils.GetTimeDelay(BotUtils.TimeScale.WEEK);

            if (!UserDataManager.CanAddRep(BotUtils.GetGUser(Context)))
            {
                await ReplyAsync(BotUtils.KamtroText($"You have no more reputation points left to give! Resets in {ts.Days} day{((ts.Days == 1) ? "" : "s")}, {ts.Hours} hour{((ts.Hours == 1) ? "" : "s")}, {ts.Minutes} minute{((ts.Minutes == 1) ? "" : "s")}, and {ts.Seconds} second{((ts.Seconds == 1) ? "" : "s")}"));

                return;
            }

            if (string.IsNullOrEmpty(username))
            {
                int rep = UserDataManager.GetUserData(BotUtils.GetGUser(Context)).ReputationToGive;
                await ReplyAsync(BotUtils.KamtroText($"You have {rep} reputation point{(rep == 1 ? "" : "s")} left to give. Resets in {ts.Days} day{((ts.Days == 1) ? "" : "s")}, {ts.Hours} hour{((ts.Hours == 1) ? "" : "s")}, {ts.Minutes} minute{((ts.Minutes == 1) ? "" : "s")}, and {ts.Seconds} second{((ts.Seconds == 1) ? "" : "s")}"));

                return;
            }

            List <SocketGuildUser> users = BotUtils.GetUser(Context.Message);

            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 AddRep(users[0]);
            }
            else
            {
                UserSelectionEmbed use = new UserSelectionEmbed(users, AddRep, BotUtils.GetGUser(Context));
                await use.Display(Context.Channel);
            }
        }