public async Task CreateRoleSyncAsync(SocketRole socketRole, string productId, ulong?watchMessageId = null) { var result = await _gumroad.GetProductAsync(_config["gumroad:token"], productId); if (!result.IsSuccess) { await ReplyAsync("Sorry, I couldn't find any products matching that ID."); return; } var product = new RexoProduct { Id = result.Product.Id, Name = result.Product.Name, PreviewImageUrl = result.Product.PreviewUrl, ShortUrl = result.Product.ShortUrl, GuildId = Context.Guild.Id, RoleId = socketRole.Id, WatchMessageId = watchMessageId }; _db.Products.Add(product); _db.SaveChanges(); await ReplyAsync($"Successfully added `{product.Name}` to the syncing service!"); }
public Task SetSyncMessageAsync(RexoProduct product, ulong msgId) { product.WatchMessageId = msgId; _db.Update(product); _db.SaveChanges(); return(Task.CompletedTask); }
public RexoProduct RemoveProduct(RexoProduct product, ulong msgId) { if (_syncedProducts.TryRemove(msgId, out RexoProduct result)) { return(result); } return(null); }
public void AddProduct(RexoProduct product) { if (product.WatchMessageId == null) { return; } _syncedProducts.TryAdd(product.WatchMessageId.Value, product); }
public async Task CreateSyncMessageAsync(RexoProduct product, SocketTextChannel channel, [Remainder] string message = null) { var role = Context.Guild.GetRole(product.RoleId); var embed = new EmbedBuilder() .WithTitle(product.Name) .WithThumbnailUrl(product.PreviewImageUrl) .WithUrl(product.ShortUrl) .WithDescription(message != null ? message : $"If you would like to sync your Gumroad purchase for this product to Discord for the {role.Mention} role, add a reaction to this message!"); var msg = await channel.SendMessageAsync(embed : embed.Build()); await msg.AddReactionAsync(new Emoji("👍")); await SetSyncMessageAsync(product, msg.Id); }
public async Task RemoveRoleSyncAsync(RexoProduct product) { await ReplyAsync($"Are you sure you want to remove `{product.Name}` from the sycning service? Reply yes/no"); var response = await _responsive.WaitForMessageAsync((msg) => { return(msg.Content.ToLower() == "yes"); }); if (response == null) { return; } _db.Remove(product); _db.SaveChanges(); await ReplyAsync($"Successfully removed `{product.Name}` from the syncing service!"); }
public async Task LinkAsync([Remainder] RexoProduct product) { await _linking.LinkUserAsync(Context.User.Id, product); }