public async Task SetEntry([Remainder][Summary("description of your art trade entry (`optional`)")] string description = null) { var user = Context.Message.Author; if (Storage.xs.Settings.IsTradeMonthActive()) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ERROR, user.Id, "**trade** already started, entries can't be changed anymore"), Utils.Emotion.neutral)); return; } Storage.ApplicationData artHistory0 = Utils.GetAppDataFromHistory(0); if (artHistory0 != null) { Storage.UserData userData = Utils.GetMissingArt(artHistory0).Find(x => x.UserId == user.Id); if (userData != null) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.REF_TRADE_LAST_MONTH_ART_MISSING, user.Id, artHistory0.GetTheme()) + $"\n{string.Format(Properties.Resources.GLOBAL_CMDHELP, Config.CmdPrefix, $"reveal art {artHistory0.GetTheme()}", "register the missing art and I will let you enter")}", Utils.Emotion.negative)); return; } } var attachments = Context.Message.Attachments; if (attachments.Count <= 0 && string.IsNullOrWhiteSpace(description)) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_MISSING_INPUT, user.Id, "description and/or embeded image"), Utils.Emotion.neutral)); return; } Storage.UserData data = new Storage.UserData(user.Id, user.Username); if (attachments.Count > 0) { data.ReferenceUrl = attachments.FirstOrDefault().Url; } if (!string.IsNullOrWhiteSpace(description)) { data.ReferenceDescription = description; } if (user is IGuildUser guildUser) { data.NickName = guildUser.Nickname; } Storage.xs.Entries.Set(data); await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_SUCCESS, user.Id, "I saved your entry"), Utils.Emotion.positive)); }
public async Task RevealArt([Remainder][Summary("theme of the art trade for which you want to register your art (`optional`)")] string theme = null) { var user = Context.Message.Author; Storage.ApplicationData foundTrade = null; if (!string.IsNullOrWhiteSpace(theme)) { theme = theme.ToLower(); for (int i = 0; i < Storage.xs.History.Count() && i < 3; ++i) { var d = Storage.xs.History.GetTrade(i); if (d == null) { continue; } if (string.IsNullOrWhiteSpace(d.GetTheme())) { continue; } if (!theme.Contains(d.GetTheme().ToLower().Trim())) { continue; } foundTrade = d; break; } } if (foundTrade == null) { foundTrade = Storage.xs.Entries; } bool bCurrentTrade = foundTrade == Storage.xs.Entries; if (bCurrentTrade && !Storage.xs.Settings.IsTradeMonthActive()) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ERROR, user.Id, "entry week in progress, partners haven't been assigned yet"), Utils.Emotion.neutral)); return; } bool bPostponeReveal = false; if (bCurrentTrade && !Storage.xs.Settings.HasNotifyFlag(Storage.ApplicationSettings.NofifyFlags.Closing)) { string outputMsg = await Utils.CleanupWrongChannelMessage(Context, "please wait for the trade to end or submit your art in a direct message"); if (string.IsNullOrWhiteSpace(outputMsg)) { bPostponeReveal = true; } else { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ERROR, user.Id, outputMsg), Utils.Emotion.neutral)); return; } } var attachments = Context.Message.Attachments; if (attachments.Count <= 0) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_MISSING_INPUT, user.Id, "embeded image"), Utils.Emotion.neutral)); return; } var data = foundTrade.Get(user.Id); if (data == null) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ITEM_NOT_FOUND, user.Id, "entry"), Utils.Emotion.neutral)); return; } Storage.UserData nextUserData; if (foundTrade.Next(user.Id, out nextUserData)) { data.ArtUrl = attachments.FirstOrDefault().Url; foundTrade.Set(data); if (!bCurrentTrade) { await GoogleDriveHandler.UploadGoogleFile(Storage.xs.HISTORY_PATH); } var client = Context.Client; var nextUser = client.GetUser(nextUserData.UserId); if (nextUser == null) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ERROR, user.Id, "could not find your partner"), Utils.Emotion.neutral)); return; } if (bPostponeReveal) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_WARNING, user.Id, "your art has been saved, but it won't be revealed to your partner until the trade ends"), Utils.Emotion.neutral)); } else { string monthTheme = Storage.xs.Entries.GetTheme(); if (!bCurrentTrade) { monthTheme = foundTrade.GetTheme(); await Utils.CreateOrEditNaughtyList(Context.Client, Storage.xs.Settings.GetWorkingChannel(), user); } if (await SendPartnerArtResponse(Context.Client, data, nextUser, monthTheme)) { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.REF_REVEAL_NOTIFY, user.Id, nextUser.Id), Utils.Emotion.positive)); } else { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ERROR, user.Id, "could not notify your partner"), Utils.Emotion.neutral)); } } } else { await ReplyAsync(embed : Utils.EmbedMessage(Context.Client, string.Format(Properties.Resources.GLOBAL_ITEM_NOT_FOUND, user.Id, "partner"), Utils.Emotion.neutral)); } }