Exemplo n.º 1
0
        public async Task randomPastebin()
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.GoogleShortener);
            if (!(Context.Channel as ITextChannel).IsNsfw)
            {
                await ReplyAsync(Sentences.chanIsNotNsfw(Context.Guild.Id));
            }
            else
            {
                Tuple <string, string> result = null;
                try
                {
                    result = await getUrl();
                }
                catch (GoogleApiException ex)
                {
                    if (ex.HttpStatusCode == HttpStatusCode.Forbidden)
                    {
                        await ReplyAsync(Sentences.tooManyRequests(Context.Guild.Id, "goo.gl"));

                        return;
                    }
                }
                if (result == null)
                {
                    await ReplyAsync(Sentences.nothingAfterXIterations(Context.Guild.Id, 500));
                }
                else
                {
                    await ReplyAsync("I found something, here is the short URL: " + result.Item1 + Environment.NewLine
                                     + ((result != null) ? ("It'll lead you here: " + result.Item2) : ("It will lead you nowhere since the URL was disabled...")));
                }
            }
        }