public async Task Deliver(int id) { if (id > 0) { if (SS.toBeDelivered.Contains(id)) { if (SS.activeOrders.FirstOrDefault(s => s.Value.Id == id).Value != null) { Chef c = SS.chefList.FirstOrDefault(a => a.Value.ChefId == Context.User.Id).Value; Sandwich order = SS.activeOrders.FirstOrDefault(s => s.Value.Id == id).Value; if (order.Status == OrderStatus.ReadyToDeliver) { try { Console.WriteLine("passed finish"); await ReplyAsync("DMing you an invite! Go deliver it! Remember to be nice and ask for `;feedback`"); IGuild s = await Context.Client.GetGuildAsync(order.GuildId); ITextChannel ch = await s.GetTextChannelAsync(order.ChannelId); IGuildUser u = await s.GetUserAsync(order.UserId); IDMChannel dm = await u.CreateDMChannelAsync(); await dm.SendMessageAsync($"Your sandwich is being delivered soon! Watch out!"); IInvite inv = await ch.CreateInviteAsync(0, 1, false, true); IDMChannel artistdm = await Context.User.CreateDMChannelAsync(); var builder = new EmbedBuilder(); builder.ThumbnailUrl = order.AvatarUrl; builder.Title = $"Your order is being delivered by {Context.User.Username}#{Context.User.Discriminator}!"; var desc = $"```{order.Desc}```\n" + $"**Incoming sandwich! Watch {order.GuildName}!**"; builder.Description = desc; builder.Color = new Color(163, 198, 255); builder.WithFooter(x => { x.IconUrl = u.GetAvatarUrl(); x.Text = $"Ordered at: {order.date}."; }); builder.Timestamp = DateTime.UtcNow; await artistdm.SendMessageAsync(inv.ToString()); SS.cache.Add(order); order.Status = OrderStatus.Delivered; SS.toBeDelivered.Remove(order.Id); SS.activeOrders.Remove(order.Id); SS.hasAnOrder.Remove(order.UserId); c.ordersDelivered += 1; //await e.Channel.SendMessage("The Order has been completed and removed from the system. You cannot go back now!"); SS.Save(); } catch (Exception ex) { await ReplyAsync(":ghost:"); await ReplyAsync($"```{ex}```"); return; } } else { await ReplyAsync($"This order is not ready to be delivered just yet! It is currently Order Status {order.Status}"); return; } } else { await ReplyAsync("Invalid order probably (tell Fires its a problem with the checky thingy, the thing thing)"); return; } } else { await ReplyAsync("You are not high enough rank to deliver orders!"); return; } } else { await ReplyAsync("This order is not ready to be delivered yet! (this error can also occur if you are not using the right id)"); return; } }
public async Task Deliver(string id) { _SS.Save(); using (Context.Channel.EnterTypingState()) { Sandwich o = await _DB.FindOrder(id); if (o.ArtistId == Context.User.Id) { if (o.Status == OrderStatus.ReadyToDeliver) { Artist a = await _ADB.FindArtist(Context.User.Id); //Collect variables await ReplyAsync($"{Context.User.Mention} DMing you an invite! Go deliver it! Remember to be nice and ask for `;feedback`."); IGuild s = await Context.Client.GetGuildAsync(o.GuildId); SandwichUser user = await _UDB.FindUser(o.UserId); await _UDB.UpOrders(user.Id); ITextChannel ch = await s.GetTextChannelAsync(o.ChannelId); IGuildUser u = await s.GetUserAsync(o.UserId); IDMChannel dm = await u.GetOrCreateDMChannelAsync(); //Create Invite IInvite inv = await ch.CreateInviteAsync(1800, 1, false, true); IDMChannel artistdm = await Context.User.GetOrCreateDMChannelAsync(); //Build embed var builder = new EmbedBuilder(); builder.ThumbnailUrl = o.AvatarUrl; builder.Title = $"Your order is being delivered by {Context.User.Username}#{Context.User.Discriminator}!"; var desc = $"```{o.Desc}```\n" + $"**Incoming sandwich! Watch {o.GuildName}!**"; builder.Description = desc; builder.Color = new Color(255, 181, 10); builder.WithFooter(x => { x.IconUrl = u.GetAvatarUrl(); x.Text = $"Ordered at: {o.date}."; }); builder.Timestamp = DateTime.UtcNow; await dm.SendMessageAsync($"Your sandwich is being delivered soon! Watch out!", embed : builder); //Finish up await artistdm.SendMessageAsync("Invite: " + inv.ToString() + " \r\n Name: " + o.UserName); o.Status = OrderStatus.Delivered; await _ADB.UpdateMostRecentOrder(a); await _UDB.GiveUserCredits(Context.User as IGuildUser, 5.0f); await _DB.DelOrder(id); } else { await ReplyAsync("This order is not ready to be delivered yet."); } } else { await ReplyAsync("You have not claimed this order!"); } } }