public async Task AddKink(params string[] kinkdata) { if (kinkdata != null && kinkdata.Length > 1) { string replyString = "Adding kink" + "\n" + "Name: - " + kinkdata[0] + "\n" + "Descrption: - " + kinkdata[1] + "\n"; var replyMessage = await Context.Channel.SendMessageAsync(replyString); bool kinkAdded = await DataMethods.AddKink(kinkdata[0], kinkdata[1]); if (kinkAdded) { replyString += "Kink added successfully!" + "\n"; } else { replyString += "Kink already in database, not added!" + "\n"; } await replyMessage.ModifyAsync(x => x.Content = replyString); return; } string initMessage = "Welcome " + Context.User.Mention + "\n" + "New Kink Creation Step 1 - Enter Kink Name:"; var replymessage = await Context.Channel.SendMessageAsync(initMessage); if (Vars.activeCommands.Where(x => x.ActorID == Context.User.Id).Count() > 0) { // eventually delete the old posts here too Vars.activeCommands.RemoveAll(x => x.ActorID == Context.User.Id); } var newCommand = new Command { CommandName = "addkink", CommandData = "start", ActorID = Context.User.Id, ChannelID = Context.Channel.Id, MessageID = replymessage.Id, }; Vars.activeCommands.Add(newCommand); /* * if (Vars.usersAddingKinks.Count > 0 && Vars.usersAddingKinks.Exists(x => x == Context.User.Id)) * { * Vars.usersAddingKinks.RemoveAll(x => x == Context.User.Id); * } * * * Vars.usersAddingKinks.Add(Context.User.Id); * * * * * * * * await DataMethods.RemoveKinkAdder(Context.User.Id); * await DataMethods.AddKinkAdder(replymessage.Id, Context.User.Id, Context.Channel.Id); */ }
public async Task AddKinkData(SocketCommandContext Context) { ulong userID = Context.User.Id; Command kinkCommand = Vars.activeCommands.Where(x => x.ActorID == userID).FirstOrDefault(); Console.WriteLine(" kink command data is - " + kinkCommand.CommandData); /* * Command kinkCommand = DataMethods.GetKinkAdder(Context.User.Id); */ if (Context.Channel.Id != kinkCommand.ChannelID) { return; } if (kinkCommand.CommandData.Equals("start")) { string kinkName = Context.Message.Content; kinkCommand.CommandData = kinkName; //await DataMethods.UpdateKinkAdder(kinkCommand.CommandID, kinkName ); string newMessage = "Welcome " + Context.User.Mention + "\n" + "New Kink Creation Step 2 - Enter Kink Description:"; ulong msgToEditID = kinkCommand.MessageID; var msgToEdit = (RestUserMessage)await Context.Channel.GetMessageAsync(msgToEditID, CacheMode.AllowDownload); await msgToEdit.ModifyAsync(x => x.Content = newMessage); await Context.Message.DeleteAsync(); } else { Console.WriteLine(" entering 2nd else "); string kinkDesc = Context.Message.ToString(); string kinkName = kinkCommand.CommandData; Console.WriteLine(" attempting to add kink "); bool kinkAdded = await DataMethods.AddKink(kinkName, kinkDesc); Console.WriteLine(" kink should be added " + kinkCommand.CommandData); // need to remove description message // need to remove command list entry await Context.Message.DeleteAsync(); Vars.activeCommands.RemoveAll(x => x.ActorID == Context.User.Id && x.CommandName == "addkink"); /* * // need to delete commands record * // need to delete vars list entry * Vars.usersAddingKinks.Remove(Context.User.Id); * await DataMethods.RemoveKinkAdder(Context.User.Id); * */ ulong msgToDelID = kinkCommand.MessageID; var msgToDel = (RestUserMessage)await Context.Channel.GetMessageAsync(msgToDelID); string newMessage = "Welcome " + Context.User.Mention + "\n"; if (kinkAdded) { newMessage += "New kink added - " + kinkName + " - " + kinkDesc; } else { newMessage += "Kinkname in DB already, not added!"; } await msgToDel.ModifyAsync(x => x.Content = newMessage); /* * await Task.Delay(5000); * * await msgToDel.DeleteAsync(); * * Console.WriteLine(" bot message deleted "); */ } //return "fartz"; }