Esempio n. 1
0
        public async Task RunAsync(
            [Remainder]
            [Summary("The code to paste.")]
            string code)
        {
            string url;
            string error = null;

            try
            {
                url = await _service.UploadCodeAsync(Context.Message, code);
            }
            catch (WebException ex)
            {
                url   = null;
                error = ex.Message;
            }

            if (url != null)
            {
                var embed = _service.BuildEmbed(Context.User, code, url);

                await ReplyAsync(Context.User.Mention, false, embed);

                await Context.Message.DeleteAsync();
            }
            else
            {
                await ReplyAsync(error);
            }
        }
Esempio n. 2
0
        private async Task UploadMessage(IUserMessage arg)
        {
            try
            {
                var url = await _service.UploadCodeAsync(arg);

                var embed = _service.BuildEmbed(arg.Author, arg.Content, url);

                await arg.Channel.SendMessageAsync(arg.Author.Mention, false, embed);

                await arg.DeleteAsync();
            }
            catch (WebException ex)
            {
                await arg.Channel.SendMessageAsync($"I would have reuploaded your long message, but: {ex.Message}");
            }
        }