Beispiel #1
0
        public static async Task <string> UploadFileAsync(IMessageChannel channel, string filePath, FileUploadOptions options = FileUploadOptions.None)
        {
            IUserMessage result = await channel.SendFileAsync(filePath);

            string url = result.Attachments.FirstOrDefault()?.Url;

            if (!string.IsNullOrEmpty(url) && options.HasFlag(FileUploadOptions.DeleteFileAfterUpload))
            {
                IOUtilities.TryDeleteFile(filePath);
            }

            return(url);
        }