예제 #1
0
        public Task UpdateAsync(string id, [Remainder] string state)
        {
            id = id.Replace("#", "");

            SocketRole role;

            try { role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Staff"); } catch { return(Task.CompletedTask); }
            var user = Context.User as SocketGuildUser;

            if (!user.Roles.Contains(role))
            {
                return(Task.CompletedTask);
            }
            if (Program.ProcessedOrders.Count(x => x.ID.ToString() == id) == 0)
            {
                return(ReplyAsync("Sorry, I couldn't find that order."));
            }
            Program.ProcessedOrders.Where(x => x.ID.ToString() == id).First().State = state;
            Order o = Program.ProcessedOrders.Where(x => x.ID.ToString() == id).First();

            Context.Client.GetUser(o.Sender.DiscordID).SendMessageAsync("", false, OrderEmbed.GenOrder(o));
            try { Context.Client.GetUser(o.Recipient.DiscordID).SendMessageAsync("", false, OrderEmbed.GenOrder(o, Context)); } catch { }
            var c = Context.Client.GetChannel(531083554927542284) as ITextChannel;

            c.SendMessageAsync($"Order #{o.ID} updated with state new state: {o.State}.", false, OrderEmbed.GenOrder(o, Context));

            Program.Save();
            return(ReplyAsync("State has been updated and the users have been notified."));
        }
예제 #2
0
        public Task OrderASync()
        {
            if (Program.unProcessedOrders.Count(x => x.Sender.DiscordID == Context.User.Id) == 0)
            {
                return(ReplyAsync("It seems like you are not in the process of creating an order. \nIf you'd like to create one, use `!order new <recipient>`.\nIf you want a list of your current orders, do `!orders`."));
            }

            Order o = Program.unProcessedOrders.Where(x => x.Sender.DiscordID == Context.User.Id).First();

            return(ReplyAsync("", false, OrderEmbed.GenOrder(o, Context)));
        }
예제 #3
0
        public Task OrderASync(string id)
        {
            id = id.Replace("#", "");

            if (Program.ProcessedOrders.Count(x => x.ID.ToString() == id && (x.Sender.DiscordID == Context.User.Id || x.Recipient.DiscordID == Context.User.Id)) == 0)
            {
                return(ReplyAsync("It seems like I couldn't find any orders with that tracking number for you. \nIf you'd like to create one, use `!order new <recipient>`.\nIf you want a list of your current orders, do `!orders`."));
            }

            Order o = Program.ProcessedOrders.Where(x => x.ID.ToString() == id).First();

            return(ReplyAsync("", false, OrderEmbed.GenOrder(o, Context)));
        }
예제 #4
0
        public Task OrdersAsync()
        {
            if (Program.ProcessedOrders.Count(x => x.Sender.DiscordID == Context.User.Id) == 0)
            {
                return(ReplyAsync("It seems like you are do not have any active orders. \nIf you'd like to create one, use `!order new <recipient>`."));
            }

            Program.Load();

            List <Order> orders = Program.ProcessedOrders.Where(x => x.Sender.DiscordID == Context.User.Id || x.Recipient.DiscordID == Context.User.Id).ToList();

            foreach (var order in orders)
            {
                Context.User.SendMessageAsync("", false, OrderEmbed.GenOrder(order, Context));
            }

            if (!Context.IsPrivate)
            {
                ReplyAsync("I've sent you your orders.");
            }

            return(Task.CompletedTask);
        }
예제 #5
0
        public Task RemoveAsync(string id, [Remainder] string reason = "Not specified")
        {
            SocketRole role;

            try { role = Context.Guild.Roles.FirstOrDefault(x => x.Name == "Staff"); } catch { return(Task.CompletedTask); }
            var user = Context.User as SocketGuildUser;

            if (!user.Roles.Contains(role))
            {
                return(Task.CompletedTask);
            }
            if (Program.ProcessedOrders.Count(x => x.ID.ToString() == id) == 0)
            {
                return(ReplyAsync("Sorry, I couldn't find that order."));
            }
            Order o = Program.ProcessedOrders.Where(x => x.ID.ToString() == id).First();

            o.State = "Removed";
            Program.ProcessedOrders.Remove(o);
            Program.Save();

            Context.Client.GetUser(o.Sender.DiscordID).SendMessageAsync($"Hello, your order `#{o.ID}` has been marked removed by {Context.User.Mention} for '{reason}'.\nIf you believe this is an error, please contact DOD staff.", false, OrderEmbed.GenOrder(o));
            try { Context.Client.GetUser(o.Recipient.DiscordID).SendMessageAsync($"Hello, your order `#{o.ID}` has been marked removed by {Context.User.Mention} for '{reason}'.\nIf you believe this is an error, please contact DOD staff.", false, OrderEmbed.GenOrder(o)); } catch { }
            var c = Context.Client.GetChannel(531083554927542284) as ITextChannel;

            c.SendMessageAsync($"Order `#{o.ID}` has been removed by {Context.User.Mention}.\nReason: {reason}", false, OrderEmbed.GenOrder(o, Context));

            return(ReplyAsync("The order has been removed."));
        }
예제 #6
0
        public Task OrderConfirmASync()
        {
            if (Program.unProcessedOrders.Count(x => x.Sender.DiscordID == Context.User.Id) == 0)
            {
                return(ReplyAsync("It seems like you are not in the process of creating an order. \nIf you'd like to create one, use `!order new <recipient>`.\nIf you want a list of your current orders, do `!orders`."));
            }

            Order o = Program.unProcessedOrders.Where(x => x.Sender.DiscordID == Context.User.Id).First();

            if (string.IsNullOrWhiteSpace(o.PickUpLocation))
            {
                return(ReplyAsync("Please also set a pick-up location using !order pickup <coords/po box>"));
            }
            if (string.IsNullOrWhiteSpace(o.DropOffLocation))
            {
                return(ReplyAsync("Please also set a drop-off location using !order dropoff <coords/po box>"));
            }

            Program.unProcessedOrders.Remove(o);
            o.State = "Order acknowledged";
            Program.ProcessedOrders.Add(o);
            Program.Save();

            try { Context.Client.GetUser(o.Recipient.DiscordID).SendMessageAsync($"Hello.\n{Context.User.Mention} has sent you an order!\nWe will deliver it as soon as possible.\nHere's the receipt.", false, OrderEmbed.GenOrder(o, Context)); } catch { }
            Context.Client.GetUser(o.Sender.DiscordID).SendMessageAsync("Hello, thank you for using DOD!\nHere's your order reciept.", false, OrderEmbed.GenOrder(o, Context));

            var c = Context.Client.GetChannel(531083554927542284) as ITextChannel;

            c.SendMessageAsync($"New order from {Context.User.Mention} to { OrderEmbed.GetRec(o.Recipient.DiscordID, o.Recipient.Username)}.", false, OrderEmbed.GenOrder(o, Context));

            return(ReplyAsync("Your order has been confirmed."));
        }