Hack Forums
[C#] Making discord bot - random imgur? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Making discord bot - random imgur? (/showthread.php?tid=5854007)



Making discord bot - random imgur? - Tunabish - Jun 25, 2018

Hey guys, I've never worked with API's/requests and all that stuff.
I'm trying to make a command in my discord bot that would grab a random image from imgur gallery.
Though I do not understand how this works at all even after reading the documentation.
ap i. imgur . com /endpoints/gallery#gallery-random


Right now I tried to do
Code
       [Command("aww")]
       public async Task getRandomAww()
       {
           using (WebClient puppyClient = new WebClient())
           {
               string puppyLink = puppyClient.DownloadString("htt ps : // ap i. imgu r .c om/3/gallery/random/random/aww");
               //pull image from imgur or the link?
           }
       }

But that doesn't work because it just returns
Code
{"data":{"error":"Authentication required","request":"\/3\/gallery\/random\/random\/aww","method":"GET"},"success":false,"status":401}



RE: Making discord bot - random imgur? - .kr. - Jun 25, 2018

this is a error-message
Code
"error":"Authentication required"

you need a imgur api key. register at developer on imgur and get your apikey


RE: Making discord bot - random imgur? - int - Jun 26, 2018

https://apidocs.imgur.com/
You need an access token


RE: Making discord bot - random imgur? - Tunabish - Jun 26, 2018

I figured out how to get a set of images from imgur gallery, but I haven't figured out how I get like the link of these images....
I know there's a .Link function but ehh D:
I'm using an imgur wrapper, which I would link if I could post links.
edit : http :// imgurapi.readthedocs . io/en/latest/endpoints/gallery-endpoint/#getsubredditgalleryasync


Code
       public async Task GetImage()
       {
           try
           {
               var client = new ImgurClient("APP-ID");
               var endpoint = new GalleryEndpoint(client);
               var images = await endpoint.GetSubredditGalleryAsync("aww");
               Console.WriteLine();// here I wanted to print the link
           }
           catch (ImgurException imgurEx)
           {
               Debug.Write("An error occurred getting an image from Imgur.");
               Debug.Write(imgurEx.Message);
           }
       }
It doesn't work if I just do images[1].Link
Anyone knows how I do this? x_x


RE: Making discord bot - random imgur? - Terry A. Davis - Jun 27, 2018

What's the return type of GetSubredditGalleryAsync() I can't find it on their docs.


RE: Making discord bot - random imgur? - Infirmary - Jun 27, 2018

(Jun 25, 2018 12:29 PM).kr. Wrote:  this is a error-message
Code
"error":"Authentication required"

you need a imgur api key. register at developer on imgur and get your apikey

You don't need an API key, just go to the home page ( or category page ) and download every image by <img>/<image> tag, then scroll down

this is a webbrowser method i used to scrape 2.77M Images


RE: Making discord bot - random imgur? - int - Jun 27, 2018

(Jun 27, 2018 05:50 AM)Infirmary Wrote:  You don't need an API key, just go to the home page ( or category page ) and download every image by <img>/<image> tag, then scroll down

this is a webbrowser method i used to scrape 2.77M Images

this is a retarded way, do not use the way this retard said to do it.


RE: Making discord bot - random imgur? - Infirmary - Jun 27, 2018

(Jun 27, 2018 06:26 AM)Jukeboxhook Wrote:  this is a retarded way, do not use the way this retard said to do it.

Why??

WebBrowser could suck but as long as you use proxies for scraping tons of images, Could Violate TOS..


RE: Making discord bot - random imgur? - int - Jun 27, 2018

(Jun 27, 2018 06:29 AM)Infirmary Wrote:  Why??

WebBrowser could suck but as long as you use proxies for scraping tons of images, Could Violate TOS..

webbrowser is for retards and scraping images, downloading, and sending to discord is for retards.


RE: Making discord bot - random imgur? - Infirmary - Jun 27, 2018

Who would wanna use Imgur's API, it sucks..

Use a Webbrowser without the window ( not giving code ) and ignore this guy..


RE: Making discord bot - random imgur? - int - Jun 27, 2018

(Jun 27, 2018 06:34 AM)Infirmary Wrote:  Who would wanna use Imgur's API, it sucks..

Use a Webbrowser without the window ( not giving code ) and ignore this guy..

so ur telling me instead of sending a link to an image on discord,
you want to download the image, upload to discord, and send the uploaded link?
iq 10


RE: Making discord bot - random imgur? - Infirmary - Jun 27, 2018

(Jun 27, 2018 07:18 AM)Jukeboxhook Wrote:  so ur telling me instead of sending a link to an image on discord,
you want to download the image, upload to discord, and send the uploaded link?
iq 10

Did I say a link.. Do i have to explain everything ??

Plus, You can Download then upload image & delete a Downloaded image

iq 10 means idiots like you need to ask self-explanatory questions..

P.S. It's pretty obvious.. IF you arent "iq 10" that someone shouldn't have to explain everything to you at once


RE: Making discord bot - random imgur? - int - Jun 27, 2018

yeah ok retard, let me know when u get a brain to use an api


RE: Making discord bot - random imgur? - Infirmary - Jun 27, 2018

(Jun 27, 2018 07:28 AM)Jukeboxhook Wrote:  yeah ok retard, let me know when u get a brain to use an api

Whatever. API's cost performance & Money 🤭 😎


RE: Making discord bot - random imgur? - gigajew - Jun 27, 2018

Here's a sample project. You need to implement your own way to see if a picture redirects to removed.png though https://files.catbox.moe/rtryeq.zip

[Image: EUTrXql.gif]