Esempio n. 1
0
        private async Task EditFile(FileInfo file)
        {
            var interactivity = CommandContext.Client.GetInteractivity();

            await DownloadFile(file);

            await CommandContext.RespondAsync("**Please send back the file as an attachment.**");

            var updatedFileAttachment = await interactivity.WaitForMessageAsync(
                x => x.Author.Id == CommandContext.User.Id && x.Channel.Id == CommandContext.Channel.Id &&
                x.Attachments.Any(
                    y => y.FileName.EndsWith(file.Extension)),
                TimeSpan.FromMinutes(5));

            if (FitsMask(updatedFileAttachment.Result.Attachments[0].FileName))
            {
                await CommandContext.RespondAsync("This File Type is banned.");

                return;
            }

            var updatedFileContent = DownloadString(updatedFileAttachment.Result.Attachments[0].Url);

            FileSystem.DeleteFile(file.FullName);
            FileSystem.AppendTextFile(file.FullName, Encoding.ASCII.GetBytes(updatedFileContent));
            await CommandContext.RespondAsync($"Edited **{file.Name}**");
        }