Пример #1
0
        public async Task EditGroupData(SocketCommandContext Context)
        {
            ulong userID = Context.User.Id;

            Command groupCommand = Vars.activeCommands.Where(x => x.ActorID == userID).FirstOrDefault();

            Console.WriteLine(" we've got our group command ");


            KinkGroup groupToEdit = Vars.tableEntries.Where(x => x.GetType().Name == "KinkGroup").ToList().Cast <KinkGroup>().ToList().Where(x => x.KinkGroupID.ToString() == groupCommand.CommandData).FirstOrDefault();

            Console.WriteLine(" we've got our group to edit ");



            if (groupCommand.CommandData == "start")
            {
                string groupName = Context.Message.Content;


                KinkGroup groupFromDB = DataMethods.GetGroup(groupName);


                if (groupFromDB == null)
                {
                    ulong msgEndID = groupCommand.MessageID;

                    var msgEnd = (RestUserMessage)await Context.Channel.GetMessageAsync(msgEndID);

                    string endMessage = "Welcome " + Context.User.Mention + "\n" +
                                        "Group not found, quitting!";

                    await msgEnd.ModifyAsync(x => x.Content = endMessage);

                    Vars.activeCommands.RemoveAll(x => x.ActorID == Context.User.Id);


                    await Context.Message.DeleteAsync();

                    return;
                }

                Vars.tableEntries.Add(groupFromDB);

                groupCommand.CommandData = groupFromDB.KinkGroupID.ToString();
                groupCommand.CommandStep = 1;

                string newMessage = "Welcome " + Context.User.Mention + "\n" +
                                    "Edit Group Step 1: Enter New Name, or Fartz to skip";

                ulong msgToEditID = groupCommand.MessageID;

                var msgToEdit = (RestUserMessage)await Context.Channel.GetMessageAsync(msgToEditID, CacheMode.AllowDownload);

                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await Context.Message.DeleteAsync();
            }

            else if (groupToEdit != null && groupCommand.CommandStep == 1)
            {
                string newGroupName = Context.Message.Content;

                if (!newGroupName.Equals("fartz", StringComparison.OrdinalIgnoreCase))
                {
                    groupToEdit.KinkGroupName = newGroupName;

                    KinkGroup kinkToCheck = Vars.tableEntries.Where(x => x.GetType().Name == "KinkGroup").ToList().Cast <KinkGroup>().ToList().Where(x => x.KinkGroupID.ToString() == groupCommand.CommandData).FirstOrDefault();

                    if (groupToEdit.KinkGroupName != kinkToCheck.KinkGroupName)
                    {
                        Console.WriteLine("Kink in edit list not updating");
                    }
                }

                groupCommand.CommandStep = 2;

                string newMessage = "Welcome " + Context.User.Mention + "\n" +
                                    "Edit Kink Step 2: Enter New Description, or Fartz to skip";

                ulong msgToEditID = groupCommand.MessageID;

                var msgToEdit = (RestUserMessage)await Context.Channel.GetMessageAsync(msgToEditID, CacheMode.AllowDownload);

                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await Context.Message.DeleteAsync();
            }

            else if (groupToEdit != null && groupCommand.CommandStep == 2)
            {
                string newKinkDescrip = Context.Message.Content;
                if (!newKinkDescrip.Equals("fartz", StringComparison.OrdinalIgnoreCase))
                {
                    groupToEdit.KinkGroupDescrip = newKinkDescrip;

                    KinkGroup kinkToCheck = Vars.tableEntries.Where(x => x.GetType().Name == "KinkGroup").ToList().Cast <KinkGroup>().ToList().Where(x => x.KinkGroupID.ToString() == groupCommand.CommandData).FirstOrDefault();

                    if (groupToEdit.KinkGroupDescrip != kinkToCheck.KinkGroupDescrip)
                    {
                        Console.WriteLine("Kink in edit list not updating");
                    }
                }

                await Context.Message.DeleteAsync();


                string newMessage = "Welcome " + Context.User.Mention + "\n" +
                                    "Now updating entry with new Name and Description: \n"
                                    + "Name: " + groupToEdit.KinkGroupName + "\n"
                                    + "Desc: " + groupToEdit.KinkGroupDescrip + "\n";


                ulong msgToEditID = groupCommand.MessageID;

                var msgToEdit = (RestUserMessage)await Context.Channel.GetMessageAsync(msgToEditID, CacheMode.AllowDownload);

                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await DataMethods.EditGroup(groupToEdit.KinkGroupID, groupToEdit.KinkGroupName, groupToEdit.KinkGroupDescrip);


                await Task.Delay(1000);

                newMessage += "\n.";
                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await Task.Delay(1000);

                newMessage += ".";
                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await Task.Delay(1000);

                newMessage += ".";
                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                await Task.Delay(1000);

                newMessage += " Done.";
                await msgToEdit.ModifyAsync(x => x.Content = newMessage);

                Vars.activeCommands.RemoveAll(x => x.ActorID == Context.User.Id);

                Vars.tableEntries.RemoveAll(x => x.GetType().Name == "KinkGroup" && (x as KinkGroup).KinkGroupID == groupToEdit.KinkGroupID);
            }
        }