示例#1
0
        public async Task BlockAsync()
        {
            IUserMessage ourMsg;

            ourMsg = await ReplyAsync("Would you like to remove a block, or add one? [Remove, Add]");

            var mRes = await borkInteract.WaitForMessage(Context.User, ourMsg.Channel, TimeSpan.FromSeconds(60));

            if (mRes != null)
            {
                if (mRes.Content.ToLower() == "remove")
                {
                    ourMsg = await DoMessages(ourMsg.Channel, ourMsg, "Please provide the user Id to remove from the block list.");

                    mRes = await borkInteract.WaitForMessage(mRes.Author, ourMsg.Channel, TimeSpan.FromSeconds(60));

                    if (mRes != null)
                    {
                        borkConfig.RemoveUserBlock(Convert.ToUInt64(mRes.Content));
                    }

                    await DoMessages(ourMsg.Channel, ourMsg, $"Thank you, I've removed `{borkClient.GetUser(Convert.ToUInt64(mRes.Content))}` from the Block List.");
                }
                else if (mRes.Content.ToLower() == "add")
                {
                    ourMsg = await DoMessages(ourMsg.Channel, ourMsg, "Please provide the user Id to add.");

                    mRes = await borkInteract.WaitForMessage(mRes.Author, ourMsg.Channel, TimeSpan.FromSeconds(60));

                    if (mRes != null)
                    {
                        ulong userId = Convert.ToUInt64(mRes.Content);

                        ourMsg = await DoMessages(ourMsg.Channel, ourMsg, "Is this permanent? [true, false]");

                        mRes = await borkInteract.WaitForMessage(mRes.Author, ourMsg.Channel, TimeSpan.FromSeconds(60));

                        if (mRes != null)
                        {
                            bool Permanent = Convert.ToBoolean(mRes.Content);

                            ourMsg = await DoMessages(ourMsg.Channel, ourMsg, "Please provide a reason for the block.");

                            mRes = await borkInteract.WaitForMessage(mRes.Author, ourMsg.Channel, TimeSpan.FromSeconds(60));

                            if (mRes != null)
                            {
                                borkConfig.AddUserBlock(userId, Permanent, DateTime.Now, mRes.Content);

                                await DoMessages(ourMsg.Channel, ourMsg, $"Thank you, I've added `{borkClient.GetUser(userId)}` to the block list.\n\n`Reason:` {mRes.Content}\n`Permanent:` {Permanent}");
                            }
                        }
                    }
                }
                else
                {
                    await DoMessages(ourMsg.Channel, ourMsg, "Your request was invalid, try again.");
                }
            }
            else
            {
                await DoMessages(ourMsg.Channel, ourMsg, "Your request timed out, try again.");
            }

            //if (borkConfig.BlockedUsers.ContainsKey(Id))
            //    await ReplyAsync("That user has already been blocked :x:");
            //else
            //{
            //    borkConfig.AddUserBlock(Id, isTemp, DateTime.Today, reason);
            //    await ReplyAsync($"Alrighty, I've added `{borkClient.GetUser(Id).Username}` to the block list.\n\n`Reason:` *{reason}*\n`Temp:` *{isTemp}*");
            //}
        }