/// <summary> /// Posts a notification that a user was unbanned. /// </summary> /// <param name="ban">The ban.</param> /// <param name="rescinder">The person who rescinded the ban.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task <OperationResult> NotifyUserUnbannedAsync(UserBan ban, IGuildUser rescinder) { var guild = _client.GetGuild((ulong)ban.Server.DiscordID); var getChannel = await GetModerationLogChannelAsync(guild); if (!getChannel.IsSuccess) { return(OperationResult.FromError(getChannel)); } var channel = getChannel.Entity; var eb = _feedback.CreateEmbedBase(); eb.WithTitle($"User Unbanned (#{ban.ID})"); eb.WithColor(Color.Green); var whoDidIt = rescinder.IsMe(_client) ? "(expired)" : $"by {rescinder.Mention}"; var bannedID = (ulong)ban.User.DiscordID; eb.WithDescription($"{MentionUtils.MentionUser(bannedID)} (ID {bannedID}) was unbanned {whoDidIt}."); await _feedback.SendEmbedAsync(channel, eb.Build()); return(OperationResult.FromSuccess()); }
public virtual async Task UndoManualAsync(int gameId) { using (var db = new Database()) { var game = db.ManualGameResults.Find(Context.Guild.Id, gameId); if (game == null) { await SimpleEmbedAsync("Invalid game id.", Color.Red); return; } var responseEmbed = new EmbedBuilder(); responseEmbed.AddField("Game Info", $"State: {game.GameState}\n" + $"Submitted by: {MentionUtils.MentionUser(game.Submitter)}\n" + $"Submitted at: {game.CreationTime}"); var updateChanges = new StringBuilder(); var competition = db.GetOrCreateCompetition(Context.Guild.Id); var scoreUpdates = db.ManualGameScoreUpdates.Where(x => x.GuildId == Context.Guild.Id && x.ManualGameId == gameId).ToArray(); var ranks = db.Ranks.Where(x => x.GuildId == Context.Guild.Id).ToArray(); foreach (var scoreUpdate in scoreUpdates) { var player = db.Players.Find(Context.Guild.Id, scoreUpdate.UserId); if (player == null) { continue; } if (game.GameState == ManualGameState.Win) { player.Wins--; } else if (game.GameState == ManualGameState.Lose) { player.Losses--; } else if (game.GameState == ManualGameState.Draw) { player.Draws--; } player.Points -= scoreUpdate.ModifyAmount; if (!competition.AllowNegativeScore && player.Points < 0) { player.Points = 0; } db.ManualGameScoreUpdates.Remove(scoreUpdate); db.Players.Update(player); var gUser = Context.Guild.GetUser(player.UserId); if (gUser == null) { continue; } var _ = Task.Run(() => UserService.UpdateUserAsync(competition, player, ranks, gUser)); } db.ManualGameResults.Remove(game); db.SaveChanges(); await SimpleEmbedAsync("Manual game undone."); } }
private async Task SendLevelChangedMessage(LevelChangedArgs lc) { if (lc.ChannelId == null) { return; } var channel = _client.GetGuild(lc.GuildId)?.GetTextChannel(lc.ChannelId.Value); if (channel == null) { return; } if (lc.ChangeType == LevelChangedArgs.ChangeTypes.Up) { await channel .SendConfirmAsync( $"Herzlichen Glückwunsch {MentionUtils.MentionUser(lc.UserId)}, du bist von Level {lc.OldLevel} auf Level {lc.NewLevel} aufgestiegen!") .ConfigureAwait(false); } else if (lc.ChangeType == LevelChangedArgs.ChangeTypes.Down) { await channel .SendConfirmAsync( $"Schade {MentionUtils.MentionUser(lc.UserId)}, du bist von Level {lc.OldLevel} auf Level {lc.NewLevel} abgestiegen.") .ConfigureAwait(false); } }
public async Task ApproveCampaign(SocketGuildUser promoter, PromotionCampaignEntity campaign) { ThrowIfNotStaff(promoter); var foundUser = CurrentGuild.GetUser((ulong)campaign.PromotionFor.Id); var foundRole = CurrentGuild.Roles.FirstOrDefault(d => d.Id == allowedToCommentRoleID); if (foundRole == null) { throw new InvalidOperationException("The server does not have a 'Regular' role to grant."); } await foundUser.AddRoleAsync(foundRole); campaign.Status = CampaignStatus.Approved; await _repository.UpdateCampaign(campaign); if (PromotionChannel == null) { throw new NullReferenceException(nameof(PromotionChannel)); } await PromotionChannel.SendMessageAsync( $"{MentionUtils.MentionUser((ulong)campaign.PromotionFor.Id)} has been promoted to Regular! 🎉"); }
public virtual async Task <(GameResult, string)> PickOneAsync(Database db, ShardedCommandContext context, GameResult game, SocketGuildUser[] users, TeamCaptain cap1, TeamCaptain cap2) { var uc = users.Count(); var teamCaptain = game.Picks % 2 == 0 ? cap1 : cap2; var offTeamCaptain = game.Picks % 2 == 0 ? cap2 : cap1; if (context.User.Id != teamCaptain.UserId) { await context.Channel.SendMessageAsync("", false, $"{context.User.Mention} - It is currently the other captains turn to pick.".QuickEmbed(Color.Red)); return(null, null); } if (uc == 0) { await context.Channel.SendMessageAsync("", false, $"{context.User.Mention} - You must specify a player to pick.".QuickEmbed(Color.Red)); return(null, null); } else if (uc != 1) { await context.Channel.SendMessageAsync("", false, $"{context.User.Mention} - You can only specify one player for this pick.".QuickEmbed(Color.Red)); return(null, null); } db.TeamPlayers.Add(GetPlayer(game, users[0], game.Picks % 2 == 0 ? 1 : 2)); var pickResponse = $"{MentionUtils.MentionUser(offTeamCaptain.UserId)} can select **1** player for the next pick."; return(game, pickResponse); }
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."); } }
public async Task command_unmute(string user) { var u = getuser(Context.Guild, user); if (u == null) { await ReplyAsync("User not found on this server."); return; } var r = getrole(Context.Guild, "Muted"); if (r != null) { if (!u.Roles.Contains(r)) { await ReplyAsync("This user is not muted."); return; } await u.RemoveRoleAsync(r); await ReplyAsync("User " + MentionUtils.MentionUser(u.Id) + " is no more muted."); } else { await ReplyAsync("This user is not muted."); } }
public async Task Transfer(IUser user1, IUser user2) { await Score.SwapUsers(Context.Client, user1.Id, user2.Id); await ReplyAsync( $"Swapped {MentionUtils.MentionUser(user1.Id)}'s user data with {MentionUtils.MentionUser(user2.Id)}'s."); }
public async Task UnmuteUser(IUser user, bool force) { var mute = await Database.UNSAFE_GetMute(user.Id); if (mute == null) { throw new Exception("User is currently not muted."); } if (mute.IssuerId != Context.User.Id && !force) { throw new Exception("Mute can only be removed by its issuer, " + MentionUtils.MentionUser(mute.IssuerId) + "."); } var state = WarningState.FromDatabase(await Database.UNSAFE_GetWarningsAsync(user.Id)); if (!state.MutedUntil.HasValue) { await MuteWatcher.UnmuteUser(user.Id, null); await ReplyAsync($"{MentionUtils.MentionUser(user.Id)} unmuted."); } else if (state.MutedUntil.Value < mute.ExpiryDate) { var res = await MuteUser(Context.Client.CurrentUser, user, state.MutedUntil.Value, "Mute shortened.", true, false); await ReplyAsync($"{MentionUtils.MentionUser(user.Id)} muted until {res.ExpiryDate}. " + "A reduction of the mute duration beyond this point is not possible due to an active auto-mute from the warnings system."); } else { await ReplyAsync($"{MentionUtils.MentionUser(user.Id)} muted until {mute.ExpiryDate}. " + "A reduction of the mute duration beyond this point is not possible due to an active auto-mute from the warnings system."); } }
public async Task New() { ulong UserId = Context.Message.Author.Id; await DiscordWrapper.SendMessage(Context, $"{MentionUtils.MentionUser(UserId)}, bạn có chắc muốn tạo trò chơi mới? (Yes/No)"); string content = null; SocketMessage msg; Stopwatch s = new Stopwatch(); s.Start(); do { msg = await NextMessageAsync(fromSourceUser : true, inSourceChannel : true, timeout : TimeSpan.FromMinutes(5)); if (msg == null) { break; } content = msg.Content.ToLower(); if (content == "yes" || content == "no") { break; } } while (s.Elapsed < TimeSpan.FromMinutes(5)); if (msg == null) { await DiscordWrapper.SendMessage(Context, $"Mèo không nhận được phản hồi của {MentionUtils.MentionUser(UserId)}... :cry:"); return; } else if (content == "no") { await DiscordWrapper.SendMessage(Context, $"Trò chơi mới sẽ không được tạo."); await Task.Delay(TimeSpan.FromSeconds(5)); await(Context.Channel as ITextChannel).DeleteMessagesAsync(await Context.Channel.GetMessagesAsync(4).FlattenAsync()); return; } await(Context.Channel as ITextChannel).DeleteMessagesAsync(await Context.Channel.GetMessagesAsync(2).FlattenAsync()); Puzzle puzzle = new Puzzle(UserId); Save(ref puzzle); DiscordWrapper.Log($"puzzle new | {Context.Message.Author.Username} ({Context.Message.Author.Id})"); if (!(await Host())) { var embed = new EmbedBuilder { Description = $"Trò chơi của {MentionUtils.MentionUser(puzzle.PlayerId) } đã tạm dừng.", Color = Color.Blue }; await DiscordWrapper.SendMessage(Context, embed : embed.Build()); } }
public async Task ChooseAsync( [Summary("The giveaway message from which users will be drawn.")] AnyGuildMessage <IUserMessage> message, [Summary("How many winners to choose.")] int count = 1) { var anyGiveawayLogChannels = await _designatedChannelService.AnyDesignatedChannelAsync(Context.Guild.Id, DesignatedChannelType.GiveawayLog); if (!anyGiveawayLogChannels) { await ReplyAsync($"There are no {DesignatedChannelType.GiveawayLog} channels to log the giveaway results to."); return; } var result = await _giveawayService.GetWinnersAsync(message.Value, count); if (result.IsError) { await ReplyAsync(result.Error); return; } var mentions = result.WinnerIds.Humanize(id => MentionUtils.MentionUser(id)); var response = $"Congratulations, {mentions}! You've won!"; await _designatedChannelService.SendToDesignatedChannelsAsync(Context.Guild, DesignatedChannelType.GiveawayLog, response); }
private async Task <bool> UpdateRR(string name) { var modelResult = await CheckStaffAndRetrieveModel(); if (modelResult.IsFailure()) { return(false); } _logging.Info($"{Context.User.Username}#{Context.User.Discriminator} in Guild {Context.Guild.Name}({Context.Guild.Id}) calling Update RR..."); await SendChannelMessage( $"**Getting reaction role {name}...** (Called by {MentionUtils.MentionUser(Context.User.Id)})"); var rr = await _rrRepo.GetReactionRole(Context.Guild.Id, name); if (rr.IsFailure()) { await SendChannelMessage($"> Unable to find Reaction Role with identifier {name}!"); return(false); } var rrModel = rr.Get(); await SendChannelMessage($"> Loading current config for reference..."); await SendChannelMessage(embed : CreateReactionRoleRuleEmbed(rrModel)); return(await ManageRR(rrModel, "updated Reaction Role")); }
public async Task WordLengthAsync(int wordLength = 1) { if (wordLength <= 0) { await ReplyAsync("You must specify a minimum length greater than 0."); return; } if (Context.Message.Author.Username.Equals("Luneth")) { await ReplyAsync($"{MentionUtils.MentionUser(Context.Message.Author.Id)} you can't use that!"); return; } var dict = LoadMessages(wordLength); var kv = dict.FirstOrDefault(x => x.Value == dict.Values.Max()); if (string.IsNullOrEmpty(kv.Key)) { await ReplyAsync($"There are no words that are {wordLength} letters long."); } else { if (MentionUtils.TryParseUser(kv.Key, out ulong mention)) { await ReplyAsync("This would ping someone :("); } else { await ReplyAsync($"The most common word with {wordLength} letters is \"{kv.Key}\" with {kv.Value} occurences."); } } }
public async Task ReloadAsync() { if (!Context.Message.Author.Username.Equals("Bali")) { await ReplyAsync($"{MentionUtils.MentionUser(Context.Message.Author.Id)} you can't use that!"); return; } await ReplyAsync("Loading...."); const int messageCount = 10_000_000; var channels = Context.Guild.TextChannels; int numberOfProcessedMessages = 0; _messageRepository.DropMessages(Context.Guild.Id); foreach (var channel in channels) { IEnumerable <IMessage> messages = null; try { messages = await channel.GetMessagesAsync(messageCount).FlattenAsync(); messages = messages.Where(x => !x.Author.IsBot && !x.ToString().StartsWith('$')); _messageRepository.InsertBulkMessage(messages, Context.Guild); } catch (Discord.Net.HttpException) { await ReplyAsync("I can't read " + channel.Name); } numberOfProcessedMessages += messages?.Count() ?? 0; } await ReplyAsync($"Done loading {numberOfProcessedMessages} messages!"); }
private static EmbedFieldBuilder BettorDescription(Bet bet) { var builder = new EmbedFieldBuilder() .WithName("Bettors") .WithIsInline(false); if (bet == null || bet.Bettors.Count() == 0) { return(builder.WithValue("none")); } var groups = bet.Bettors .GroupBy(b => b.BetOptionId) .Select(g => { BetOption option = bet.Options.FirstOrDefault(o => o.Id == g.Key); IEnumerable <string> bettors = g .OrderByDescending(b => b.Amount) .Select(b => $"{MentionUtils.MentionUser(b.UserId)} bet {b.Amount} Attarcoins."); return($"[{option.Id}] ({option.Odds:F}) {option.Name}\n\n{string.Join("\n", bettors)}"); }); string message = string.Join("\n\n", groups); if (message.Length > EmbedFieldBuilder.MaxFieldValueLength) { return(null); } return(builder.WithValue(message)); }
private async Task LogGuildMemberUpdatedAsync(SocketGuildUser beforeUser, SocketGuildUser afterUser) { var builder = CreateDefaultEmbedBuilder(afterUser); var removedRoles = beforeUser.Roles.Except(afterUser.Roles).ToList(); var addedRoles = afterUser.Roles.Except(beforeUser.Roles).ToList(); if (removedRoles.Count > 0) { foreach (var role in removedRoles) { await LogDestructiveAsync(builder .WithBoldDescription($"{MentionUtils.MentionUser(beforeUser.Id)} was removed from `{role.Name}` role.") .WithFooter($"User ID: {beforeUser.Id} | Role ID: {role.Id}") ); } } if (addedRoles.Count > 0) { foreach (var role in addedRoles) { await LogInformationAsync(builder .WithBoldDescription($"{MentionUtils.MentionUser(beforeUser.Id)} was added to `{role.Name}` role.") .WithFooter($"User ID: {beforeUser.Id} | Role ID: {role.Id}") ); } } }
private string GetDailyStr(ScoreData scoreData, int amount, int bonus) { var bonusStr = bonus == 0 ? "" : $" (+3 streak bonus)"; var streakStr = scoreData.DailyStreakCount == 0 ? "" : $" Streak days: {scoreData.DailyStreakCount}"; return $"{MentionUtils.MentionUser(Context.User.Id)} collected their {amount}{bonusStr} daily gems. " + $"They now have {scoreData.Gems} in total.{streakStr}"; }
public EmbedBuilder GetGameEmbed(ManualGameResult game) { var embed = new EmbedBuilder(); if (game.GameState == ManualGameResult.ManualGameState.Win) { embed.Color = Color.Green; embed.Title = "Win"; } else if (game.GameState == ManualGameResult.ManualGameState.Lose) { embed.Color = Color.Red; embed.Title = "Lose"; } else if (game.GameState == ManualGameResult.ManualGameState.Draw) { embed.Color = Color.Gold; embed.Title = "Draw"; } else { embed.Color = Color.Blue; embed.Title = "Legacy"; } embed.Description = $"**GameId:** {game.GameId}\n" + $"**Creation Time:** {game.CreationTime.ToString("dd MMM yyyy")} {game.CreationTime.ToShortTimeString()}\n" + $"**Comment:** {game.Comment ?? "N/A"}\n" + $"**Submitted By:** {MentionUtils.MentionUser(game.Submitter)}\n" + string.Join("\n", game.ScoreUpdates.Select(x => $"{MentionUtils.MentionUser(x.Key)} {(x.Value >= 0 ? $"`+{x.Value}`" : $"`{x.Value}`")}")).FixLength(1024);
public async Task ViewBlacklistedUsers() { var blacklistedUsers = await this._repository.GetBlacklistedUsers(this.Guild); var embed = new KuuhakuEmbedBuilder() .WithColor() .WithFooter(this.Context); const String prefixMessage = "The following users are blacklisted from using my commands: "; var messageLength = prefixMessage.Length; var blacklistedMentions = new List <String>(); foreach (var blacklistedUser in blacklistedUsers.Where(v => v > 0)) { var mention = MentionUtils.MentionUser(blacklistedUser); messageLength += mention.Length + 2; if (messageLength > EmbedBuilder.MaxDescriptionLength - 20) { blacklistedMentions.Add("More…"); } blacklistedMentions.Add(mention); } if (blacklistedMentions.Count == 0) { await this.ReplyAsync( embed.WithDescription("There are no users who are blacklisted from using my commands")); return; } await this.ReplyAsync(embed.WithDescription(prefixMessage + blacklistedMentions.Humanize())); }
public async Task Continue() { var chess = Load(); if (chess.IsOver) { var embed = new EmbedBuilder { Description = "Không có trận đấu nào chưa kết thúc.", Color = Color.Blue }; await Context.Channel.TriggerTypingAsync(); await ReplyAndDeleteAsync(content : null, embed : embed.Build(), timeout : TimeSpan.FromSeconds(5)); } else if (!(await Host())) { var embed = new EmbedBuilder { Description = $"Trận đấu giữa {MentionUtils.MentionUser(chess.Player[ChessBoard.WhitePlayerIndex])} và {MentionUtils.MentionUser(chess.Player[ChessBoard.BlackPlayerIndex])} đã tạm dừng.", Color = Color.Blue }; //await ReplyAsync(embed: embed.Build()); await DiscordWrapper.SendMessage(Context, embed : embed.Build()); } }
public async Task CelebrateBirthday() { var da = new DataAccess(new DatabaseContext()); var birthdays = await da.GetTodaysBirthdaysWithoutGift(); if (!birthdays.Any()) { return; } var guilds = _discord.Guilds; foreach (var guild in guilds) { foreach (var birthday in birthdays) { if (guild.Users.Select(x => x.Id).Contains(birthday.UserID)) { await guild.DefaultChannel .SendMessageAsync($":tada: Happy birthday {MentionUtils.MentionUser(birthday.UserID)} :tada:"); await da.UpdateBirthdayLastGiftGiven(guild.GetUser(birthday.UserID), DateTime.Now); } } } }
/// <summary> /// Posts a notification that a warning was rescinded. /// </summary> /// <param name="warning">The warning.</param> /// <param name="rescinder">The person who rescinded the warning.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task NotifyUserWarningRemoved(UserWarning warning, IGuildUser rescinder) { var guild = _client.GetGuild((ulong)warning.Server.DiscordID); var getChannel = await GetModerationLogChannelAsync(guild); if (!getChannel.IsSuccess) { return; } var channel = getChannel.Entity; var eb = _feedback.CreateEmbedBase(); eb.WithTitle($"Warning Removed (#{warning.ID})"); eb.WithColor(Color.Green); var whoDidIt = rescinder.IsMe(_client) ? "(expired)" : $"by {rescinder.Mention}"; eb.WithDescription ( $"A warning was removed from {MentionUtils.MentionUser((ulong)warning.User.DiscordID)} " + $"(ID {warning.User.DiscordID}) {whoDidIt}." ); await _feedback.SendEmbedAsync(channel, eb.Build()); }
public async Task SetChannel(IChannel channel = null) { // if channel somehow bypasses the channel exeception if (channel == null) { await ReplyAsync( $"{MentionUtils.MentionUser(Context.User.Id)} Could not find a valid channel. Try using channel mention instead."); return; } var guildChannel = await _context.Channels.FirstOrDefaultAsync(c => c.ChannelId == channel.Id || c.GuildId == Context.Guild.Id); if (guildChannel != null) { await ReplyAsync( $"{MentionUtils.MentionUser(Context.User.Id)} Guild already has a channel set for commits. \n(Use **DeleteChannel** command to remove it) {MentionUtils.MentionChannel(guildChannel.ChannelId)}"); return; } await _context.Channels.AddAsync(new RegisteredChannel { ChannelId = channel.Id, GuildId = Context.Guild.Id }); await _context.SaveChangesAsync(); // we have a found channel: process it and save it into database to broadcast too // if we broadcast to the channel, and it's not valid then remove it from the database // and alert an admin? await ReplyAsync($"{MentionUtils.MentionUser(Context.User.Id)} set Garry's Mod commit channel to {MentionUtils.MentionChannel(channel.Id)}!"); }
public async Task Bets() { long ID = (long)Context.User.Id; Logger.Log("getting bets"); List <bet> bets = new List <bet>(); bets = sql.GetBets(ID); string message = string.Format("{0} here are your bets: \n", MentionUtils.MentionUser(Context.User.Id)); Logger.Log("is bets null?"); if (bets != null) { Logger.Log("bets is not null"); foreach (bet bet in bets) { if (bet.Score != null) { message += string.Format(string.Format(" ID: **{4}** **{0}** vs **{1}** -> **{2}** *{3}*★ \n", bet.TeamA, bet.TeamB, bet.Score, bet.Money, bet.MatchID)); } else { message += string.Format(" ID: **{4}** **{0}** vs **{1}** -> **{2}** *{3}*★ \n", bet.TeamA, bet.TeamB, bet.Outcome, bet.Money, bet.MatchID); } } } else { message = string.Format("{0} you have no bets", MentionUtils.MentionUser(Context.User.Id)); } //await UserExtensions.SendMessageAsync(Context.Message.Author,message); // Secret await ReplyAsync(message); // Public }
private async Task RemoveWarningInternalAsync(IUser user, long id, string reason, bool force) { var warning = await Database.UNSAFE_GetWarningAsync(id); if (warning == null) { throw new Exception("Invalid warning ID."); } if (warning.UserId != user.Id) // this check exists to catch typos in warning IDs { throw new Exception("Warning ID does not match with user!"); } if (warning.IssuerId != Context.User.Id && !force) { throw new Exception("Warning can only be deleted by its issuer, " + MentionUtils.MentionUser(warning.IssuerId) + "."); } await Database.UNSAFE_RemoveWarningAsync(id, Context.Message, reason); var state = WarningState.FromDatabase(await Database.UNSAFE_GetWarningsAsync(user.Id)); var embed = AddWarningsToEmbed(GetWarningEmbed(user, warning), state) .WithDescription("**A warning was deleted.**") .Build(); await AnnounceWarningEverywhereAsync(user, embed); }
public async Task DeleteBet(long MatchID) { long ID = (long)Context.User.Id; if (sql.IsMatchLive(MatchID)) { await ReplyAsync(MentionUtils.MentionUser(Context.User.Id) + " lel no"); } else if (!sql.BetExists(ID, MatchID)) { await ReplyAsync(MentionUtils.MentionUser(Context.User.Id) + " you haven't bet on that match yet"); } else if (MatchID == 1) { decimal money = sql.GetBetMoney(ID, MatchID) - 125; sql.AddMoney(ID, money); sql.DeleteBet(ID, MatchID); sql.SubstractMoneyBet(ID, money); await ReplyAsync(MentionUtils.MentionUser(Context.User.Id) + string.Format(" your bet has been deleted and you have been refunded your money", money)); } else { decimal money = sql.GetBetMoney(ID, MatchID); sql.AddMoney(ID, money); sql.DeleteBet(ID, MatchID); sql.SubstractMoneyBet(ID, money); await ReplyAsync(MentionUtils.MentionUser(Context.User.Id) + string.Format(" your bet has been deleted and you have been refunded your money", money)); } }
public EmbedBuilder GetGameEmbed(ManualGameResult game) { var embed = new EmbedBuilder(); if (game.GameState == ManualGameState.Win) { embed.Color = Color.Green; embed.Title = "Win"; } else if (game.GameState == ManualGameState.Lose) { embed.Color = Color.Red; embed.Title = "Lose"; } else if (game.GameState == ManualGameState.Draw) { embed.Color = Color.Gold; embed.Title = "Draw"; } else { embed.Color = Color.Blue; embed.Title = "Legacy"; } using (var db = new Database()) { var scoreUpdates = db.ManualGameScoreUpdates.Where(x => x.GuildId == game.GuildId && x.ManualGameId == game.GameId); embed.Description = $"**GameId:** {game.GameId}\n" + $"**Creation Time:** {game.CreationTime.ToString("dd MMM yyyy")} {game.CreationTime.ToShortTimeString()}\n" + $"**Comment:** {game.Comment ?? "N/A"}\n" + $"**Submitted By:** {MentionUtils.MentionUser(game.Submitter)}\n" + string.Join("\n", scoreUpdates.Select(x => $"{MentionUtils.MentionUser(x.UserId)} {(x.ModifyAmount >= 0 ? $"`+{x.ModifyAmount}`" : $"`{x.ModifyAmount}`")}")); }
private static IEnumerable <EmbedBuilder> BettorEmbeds(Bet bet) { if (bet == null || bet.Bettors.Count() == 0) { return(new List <EmbedBuilder>()); } var groups = bet.Bettors .GroupBy(b => b.BetOptionId) .Select(g => { BetOption option = bet.Options.FirstOrDefault(o => o.Id == g.Key); IEnumerable <string> bettors = g .OrderByDescending(b => b.Amount) .Select(b => $"{MentionUtils.MentionUser(b.UserId)} bet {b.Amount} Attarcoins."); return(new EmbedBuilder() .WithColor(Color.Green) .WithTitle($"Option \"{option.Name}\" on bet \"{bet.Name}\"") .WithDescription($"Id: [{option.Id}]\nOdds: ({option.Odds:F})\n\n{string.Join("\n", bettors)}")); }); return(groups); }
public async Task About() { var embed = new EmbedBuilder(); embed.WithAuthor(new EmbedAuthorBuilder { Name = "Zcheletovci Bot", IconUrl = "https://cdn.discordapp.com/avatars/427814230117580810/d9dd5153d54e5bf1c33892503c96b560.png", }); embed.WithColor(100, 0, 200); embed.WithTitle("About the Zcheletovci Bot"); embed.WithDescription("This bot is meant to be used in the SS Zcheletovci Total Autism™ Discord server"); embed.AddField(new EmbedFieldBuilder { Name = "Built by", Value = MentionUtils.MentionUser(261217297039884300), IsInline = false }); embed.AddField(new EmbedFieldBuilder { Name = "Built using", Value = "Microsoft Visual Studio C#", IsInline = false }); embed.WithFooter(new EmbedFooterBuilder { IconUrl = "https://cdn.discordapp.com/attachments/387541466815135746/467015804819603486/Marok_Navija.png", Text = "Marko Maršić ©" }); embed.WithTimestamp(new DateTimeOffset(new DateTime(2018, 7, 23, 14, 00, 00))); await Context.Channel.SendMessageAsync("", false, embed); }
public async Task <GameResult> PickOneAsync(GameResult game, SocketGuildUser[] users) { var uc = users.Count(); var team = game.GetTeam(); if (Context.User.Id != team.Captain) { await SimpleEmbedAndDeleteAsync($"{Context.User.Mention} - It is currently the other captains turn to pick.", Color.Red); return(null); } if (uc == 0) { await SimpleEmbedAndDeleteAsync($"{Context.User.Mention} - You must specify a player to pick.", Color.Red); return(null); } else if (uc != 1) { await SimpleEmbedAndDeleteAsync($"{Context.User.Mention} - You can only specify one player for this pick.", Color.Red); return(null); } team.Players.Add(users.First().Id); PickResponse = $"{MentionUtils.MentionUser(game.GetOffTeam().Captain)} can select **1** player for the next pick."; game.Picks++; return(game); }