示例#1
0
        public async Task Dialogue(CommandContext ctx)
        {
            var inputStep = new TextStep("Say: abc", null);
            var funnyStep = new IntStep("Haha, funny", null, 100);

            string input = string.Empty;
            int    value = 0;

            inputStep.OnValidResult += (result) =>
            {
                input = result;
                if (result == "abc")
                {
                    inputStep.SetNextStep(funnyStep);
                }
            };

            funnyStep.OnValidResult += (result) => value = result;

            var userChannel = await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);

            var inputDialogueHandler = new DialogueHandler(ctx.Client, userChannel, ctx.User, inputStep);

            bool succeeded = await inputDialogueHandler.ProcessDialogue().ConfigureAwait(false);

            if (!succeeded)
            {
                return;
            }

            await ctx.Channel.SendMessageAsync(input).ConfigureAwait(false);

            await ctx.Channel.SendMessageAsync(value.ToString()).ConfigureAwait(false);
        }
示例#2
0
        public async Task Dialogue(CommandContext ctx)
        {
            var inputStep = new TextStep("Enter smth interesting", null, 5);
            var funnyStep = new IntStep("MUR MUR MUR", null, maxValue: 100);

            var input = string.Empty;
            var value = 0;

            inputStep.OnValidResult += result =>
            {
                input = result;
                if (result == "SupDvach!")
                {
                    inputStep.SetNextStep(funnyStep);
                }
            };

            funnyStep.OnValidResult += result => value = result;

            var userChannel = await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);

            var inputDialogueHandler = new DialogueHandler(ctx.Client, userChannel, ctx.User, inputStep);
            var succeeded            = await inputDialogueHandler.ProcessDialogue().ConfigureAwait(false);

            if (!succeeded)
            {
                return;
            }
            await ctx.Channel.SendMessageAsync(input).ConfigureAwait(false);

            await ctx.Channel.SendMessageAsync($"{value}").ConfigureAwait(false);
        }
示例#3
0
        public async Task Dialogue(CommandContext ctx)
        {
            TextStep inputStep = new TextStep("Enter something interesting", null);
            TextStep funnyStep = new TextStep("Haha, funny", null);

            string input = string.Empty;

            inputStep.OnValidResult += (result) =>
            {
                input = result;

                if (result == "something interesting")
                {
                    inputStep.SetNextStep(funnyStep);
                }
            };

            DiscordDmChannel userChannel = await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);

            DialogueHandler inputDialogueHandler = new DialogueHandler(ctx.Client, userChannel, ctx.User, inputStep);

            bool succeeded = await inputDialogueHandler.ProcessDialogue().ConfigureAwait(false);

            if (!succeeded)
            {
                return;
            }

            await ctx.Channel.SendMessageAsync(input).ConfigureAwait(false);
        }
示例#4
0
        public async Task dialogue(CommandContext ctx)
        {
            var inputStep = new TextStep("Say yes or no.", null);
            var yesStep   = new TextStep("Noice", null);

            string input = string.Empty;

            inputStep.onValidResult += (result) =>
            {
                input = result;

                if (result == "yes")
                {
                    inputStep.SetNextStep(yesStep);
                }
            };

            var userChannel = await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);

            var inputDialogueHandler = new DialogueHandler(
                ctx.Client,
                userChannel,
                ctx.User,
                inputStep
                );

            bool succeeded = await inputDialogueHandler.ProcessDialogue().ConfigureAwait(false);

            if (!succeeded)
            {
                return;
            }

            await ctx.Channel.SendMessageAsync(input).ConfigureAwait(false);
        }
示例#5
0
        public async Task Dialogue(CommandContext ctx)
        {
            await ctx.Message.DeleteAsync().ConfigureAwait(false);

            var inputStep = new TextStep("Введите анонимное сообщение!", null, 2);
            var funnyStep = new IntStep("ну привет!", null, maxValue: 100);

            string input = string.Empty;

            int value = 0;

            inputStep.OnValidResult += (result) => {
                input = result;

                if (result == "привет")
                {
                    inputStep.SetNextStep(funnyStep);
                }
            };

            funnyStep.OnValidResult += (result) => value = result;

            var userChannel = await ctx.Member.CreateDmChannelAsync().ConfigureAwait(false);

            var inputDialogueHandler = new DialogueHandler(ctx.Client, userChannel, ctx.User, inputStep);

            bool succeeded = await inputDialogueHandler.ProcessDialogue().ConfigureAwait(false);

            if (!succeeded)
            {
                return;
            }

            await ctx.Channel.SendMessageAsync(input).ConfigureAwait(false);

            //await ctx.Channel.SendMessageAsync(value.ToString()).ConfigureAwait(false);
        }
示例#6
0
        public async Task Dialogue(CommandContext ctx)
        {
            var inputStep = new TextStep("Enter something interesting!", null, 1, 150);
            var funnyStep = new IntStep("Haha, funny", null, maxValue: 100);

            string input = string.Empty;
            int    value = 0;

            inputStep.OnValidResult += (result) =>
            {
                input = result;
                if (result == "something interesting")
                {
                    inputStep.SetNextStep(funnyStep);
                }
            };

            funnyStep.OnValidResult += (result) => value = result;


            var userChannel = await ctx.Member.CreateDmChannelAsync();

            var inputDialogueHandler = new DialogueHandler(ctx.Client, userChannel, ctx.User, inputStep);

            bool succeeded = await inputDialogueHandler.ProcessDialogue();

            if (!succeeded)
            {
                return;
            }

            if (succeeded)
            {
                await userChannel.SendMessageAsync(input);
            }
        }