public async Task Stop(CommandContext ctx) { var config = DateBot.Instance.GetGuild(ctx.Guild.Id); _ = DialogFramework.QuickVolatileMessage(ctx.Channel, "Stopped activity"); config.StopActivity(); }
public async Task PostHere(CommandContext ctx, [RemainingText] string text) { await DialogFramework.CreateQuestion(ctx.Channel, text, new Answer[] { new Answer(EmojiProvider.One, async e => { await DialogFramework.QuickVolatileMessage(ctx.Channel, "thx", TimeSpan.FromSeconds(1)).ConfigureAwait(false); }) }, behavior : MessageBehavior.Permanent, deleteAnswer : true, deleteAnswerTimeout : TimeSpan.Zero); }
private async Task SetMessage(CommandContext ctx, string messageType) { string info = ""; if (messageType == "Welcome") { info = "setting gender, and age preferences"; } else if (messageType == "Controls") { info = "conrolls during a date, setting likes or adding time"; } else { return; } var config = DateBot.Instance.GetGuild(ctx.Guild.Id) as GuildConfig; ctx.Guild.Channels.TryGetValue(config.DateTextChannelId, out var channel); await DialogFramework.CreateQuestion(ctx.Channel, $"Set {messageType} message content, it will be used for {info}", s => true, async e => { //TODO Check regex to have only numbers? if (ulong.TryParse(e.Message.Content, out var id)) { var message = await channel.GetMessageAsync(id); if (message == null) { //Error message not found _ = DialogFramework.QuickVolatileMessage(ctx.Channel, "This Seemed to be a message Id, but it wasn't found"); } else { if (messageType == "Welcome") { config.WelcomeMessageId = id; } else if (messageType == "Controls") { config.PrivateControlsMessageId = id; } } } else { if (messageType == "Welcome") { config.WelcomeMessageBody = e.Message.Content; } else if (messageType == "Controls") { config.PrivateMessageBody = e.Message.Content; } } }, ctx.User.Id, deleteAnswer : true, deleteAnswerTimeout : TimeSpan.Zero, wrongAnswer : "Enter a message body, or paste existing messages Id"); _ = MainMenu(ctx); }
private async Task MainMenu(CommandContext ctx) { await DialogFramework.CreateQuestion(ctx.Channel, $"Choose what you want to set:\n" + $"{EmojiProvider.Rose} to set Date Category\n" + $"{EmojiProvider.Detective} to set Secret Category\n" + $"{EmojiProvider.Handsahke} to set Welcome message\n" + $"{EmojiProvider.ControlKnobs} to set Controls message\n" + $"{EmojiProvider.WhiteHeartInRed} to set Emojis\n" + $"{EmojiProvider.Timer} to set timeout length\n" + $"{EmojiProvider.ArrowsClockwise} to apply changes (reinit bot on this guild)\n" + $"{EmojiProvider.CrossOnGreen} to quit this dialog", new Answer[] { new Answer(EmojiProvider.Rose, e => { _ = SetCategory(ctx, "Date Category"); }), new Answer(EmojiProvider.Detective, e => { _ = SetCategory(ctx, "Secret Category"); }), new Answer(EmojiProvider.Handsahke, e => { _ = SetMessage(ctx, "Welcome"); }), new Answer(EmojiProvider.ControlKnobs, e => { _ = SetMessage(ctx, "Controls"); }), new Answer(EmojiProvider.WhiteHeartInRed, e => { _ = SetEmoji(ctx); }), new Answer(EmojiProvider.Timer, e => { _ = SetTimeout(ctx); }), new Answer(EmojiProvider.ArrowsClockwise, e => { var gt = DateBot.Instance.GetGuild(ctx.Guild.Id); _ = gt.Initialize(ctx.Guild); }), new Answer(EmojiProvider.CrossOnGreen, e => { DialogFramework.QuickVolatileMessage(ctx.Channel, "Thank you for interaction, bye."); }) }, ctx.User.Id, deleteAnswer : true, deleteAnswerTimeout : TimeSpan.Zero, timeoutMessage : "Thank you for interaction, bye.").ConfigureAwait(false); }
public async Task Config(CommandContext ctx) { await ctx.Message.DeleteAsync().ConfigureAwait(false); var isNew = !DummyBot.Instance.GuildRegistered(ctx.Guild.Id); if (isNew) { var newGuildTask = new GuildTask() { GuildId = ctx.Guild.Id }; DummyBot.Instance.AddGuild(newGuildTask); await DummyBot.Instance.SaveStates().ConfigureAwait(false); } await MainMenu().ConfigureAwait(false); //Ask what to set up // Voice Channel to connect // Channel>Message id's to set random reaction async Task MainMenu() { //Menu message await DialogFramework.CreateQuestion(ctx.Channel, $"What we should set up?" + Environment.NewLine + $"{EmojiProvider.One} Voice channel to connect to " + Environment.NewLine + $"{EmojiProvider.Two} Message id to react to", new Answer[] { new Answer(EmojiProvider.One, new string[] { "one", "voice", "channel" }, async e => { await SetVoiceChannel().ConfigureAwait(false); }), new Answer(EmojiProvider.Two, new string[] { "two", "message", "react" }, async e => { await SetMessageChannel().ConfigureAwait(false); }) }, ctx.User.Id, timeoutBeforeDelete : TimeSpan.Zero, deleteAnswer : true).ConfigureAwait(false); } //Continue configuring or quit? async Task Continue() { //ask await DialogFramework.CreateQuestion(ctx.Channel, "Would you go over?", new Answer[] { new Answer(EmojiProvider.CheckMarkOnGreen, new string[] { "yes", "sure", "go" }, async e => { await MainMenu().ConfigureAwait(false); }), new Answer(EmojiProvider.CrossOnGreen, new string[] { "no", "stop", "done" }, async e => { await DialogFramework.QuickVolatileMessage(ctx.Channel, "Thank you. We are done here. Have a nice day.").ConfigureAwait(false); }) }, ctx.User.Id, timeoutBeforeDelete : TimeSpan.Zero, deleteAnswer : true).ConfigureAwait(false); } //Setvoice channel async Task SetVoiceChannel() { //Message DiscordChannel channel = null; await DialogFramework.CreateQuestion(ctx.Channel, $"Enter channel name, to connect to.", message => { channel = ctx.Guild.Channels.FirstOrDefault(c => c.Value.Name.Contains(message)).Value; return(channel != null); }, async e => { var gt = DummyBot.Instance.GetGuild(ctx.Guild.Id); gt.ConnectToVoiceName = channel.Name; gt.ConnectToVoice = channel; //Apply changes in task await DummyBot.Instance.GetGuild(ctx.Guild.Id).Initialize().ConfigureAwait(false); //Continue to next step await Continue().ConfigureAwait(false); }, ctx.User.Id, timeoutBeforeDelete : TimeSpan.Zero, deleteAnswer : true, wrongAnswer : "Couldn't find that channel. Try again.").ConfigureAwait(false); } //Set channel id to react on a message async Task SetMessageChannel() { DiscordChannel channel = null; await DialogFramework.CreateQuestion(ctx.Channel, #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously $"Paste Channel Id, where to set random reaction.", message => { if (ulong.TryParse(message, out var id)) { channel = ctx.Guild.GetChannel(id); } return(channel != null); }, async e => { #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously var gt = DummyBot.Instance.GetGuild(ctx.Guild.Id); gt.SetRandomReactionOnChannelId = channel.Id; gt.SetRandomReactionOnChannel = channel; //Continue to next step await SetMessage().ConfigureAwait(false); }, ctx.User.Id, timeoutBeforeDelete : TimeSpan.Zero, deleteAnswer : true, wrongAnswer : "Couldn't find that channel. Try again.").ConfigureAwait(false); } //Set message id to react to async Task SetMessage() { GuildTask gt = null; DiscordMessage msg = null; await DialogFramework.CreateQuestion(ctx.Channel, $"Paste Message Id, where to set random reaction.", message => { ulong.TryParse(message, out var id); gt = DummyBot.Instance.GetGuild(ctx.Guild.Id); msg = gt.SetRandomReactionOnChannel.GetMessageAsync(id).Result; return(msg != null); }, async e => { gt.SetRandomReactionOnMessageId = msg.Id; gt.SetRandomReactionOnMessage = msg; //Apply changes in task _ = DummyBot.Instance.GetGuild(ctx.Guild.Id).Initialize(); //Continue to next step await Continue().ConfigureAwait(false); }, ctx.User.Id, timeoutBeforeDelete : TimeSpan.Zero, deleteAnswer : true, wrongAnswer : "Couldn't find that message. Try again.").ConfigureAwait(false); } }