public async Task UpUser(IGupUser gupUser) { var user = gupUser.ActualUser; if (!(user is IGuildUser targetUser)) { throw new ArgumentException("user isn't IGupUser"); } var oldScoreData = await Score.GetScoreDataAsync(Context.Client, targetUser.Id); var (scoreData, efficiency, daily) = await Score.UpvoteAsync(Context.Client, targetUser.Id, Context.User.Id); if (daily.HasValue) { await ReplyAsync(GetDailyStr(daily.Value.ScoreData, daily.Value.Amount, daily.Value.Bonus) + " (g!daily was automatically called. To disable this feature, invoke `g!autodaily false`)"); } await ReplyAsync( $"{MentionUtils.MentionUser(Context.User.Id)} gave {MentionUtils.MentionUser(targetUser.Id)} a boost. Their score increased by {scoreData.Score - oldScoreData.Score:F3} (Efficiency: {efficiency * 100:F0}%)."); if (scoreData.BonusScore != oldScoreData.BonusScore) { await ReplyAsync( $"{MentionUtils.MentionUser(targetUser.Id)} reached boost level {scoreData.BoostLevel}! +{scoreData.BonusScore:F1} temporary bonus score."); } }
private static async Task Client_GuildMemberUpdated(DiscordSocketClient client, SocketGuildUser oldUser, SocketGuildUser newUser) { if (!oldUser.Roles.SequenceEqual(newUser.Roles)) { await UpdateUserAsync(client, newUser, await Score.GetScoreDataAsync(client, newUser.Id)); } }
public async Task ChangeNickname([Remainder] string nick) { var user = (IGuildUser)Context.User; var score = await Score.GetScoreDataAsync(Context.Client, user.Id); if (score.ScoreLevel < 4) { throw new Exception("You must be a class of 4 or higher to change your nick."); } await user.ModifyAsync(u => u.Nickname = nick); await ReplyAsync("Your nickname was updated."); }
public async Task DownUser(IGuildUser targetUser) { var oldScoreData = await Score.GetScoreDataAsync(Context.Client, targetUser.Id); var (scoreData, efficiency, daily) = await Score.DownvoteAsync(Context.Client, targetUser.Id, Context.User.Id); if (daily.HasValue) { await ReplyAsync(GetDailyStr(daily.Value.ScoreData, daily.Value.Amount, daily.Value.Bonus) + " (g!daily was automatically called. To disable this feature, invoke `g!autodaily false`)"); } await ReplyAsync( $"{MentionUtils.MentionUser(Context.User.Id)} gave {MentionUtils.MentionUser(targetUser.Id)} a downvote. Their score decreased by {oldScoreData.Score - scoreData.Score:F3} (Efficiency: {efficiency * 100:F0}%)."); }
public async Task ChangeNickname([Remainder] string nick) { var user = (IGuildUser)Context.User; var score = await Score.GetScoreDataAsync(Context.Client, user.Id); if (score.ScoreLevel < 4) { throw new Exception("You must be a class of 4 or higher to change your nick."); } if (!DadbotWatcher.CanChangeNick(user.Id)) { var target = Format.Sanitize(user.Nickname ?? user.Username); var duration = DadbotWatcher.GetTimeLeft(user.Id).ToHumanReadableString(); throw new Exception($"Sorry {target}, but you can't change your nickname for another {duration} (due to Dadbot)."); } await user.ModifyAsync(u => u.Nickname = nick); await ReplyAsync("Your nickname was updated."); }
public async Task Alt(IUser user) { var scoreData = await Score.GetScoreDataAsync(Context.Client, user.Id); await ReplyAsync($"{user.Mention} is an alt of {(scoreData.AltOfUserId.HasValue ? MentionUtils.MentionUser(scoreData.AltOfUserId.Value) : "nobody")}."); }
public async Task Confirm(SocketGuildUser user) { await SocialScoreWatcher.UpdateUserAsync(Context.Client, user, await Score.GetScoreDataAsync(Context.Client, user.Id), true); }