Here is the dev.to blogpost
first create a .env file and add your bot token, you can follow with the .env.example file
then run the following commands
go mod download
go run main.gothen you can do a call to the /sendFile endpoint, passing the file as form-data with the name of file, you can check the example in the example folder
when you send the file, the server will answer with the url of the file like this:
{
"url": "link"
}
It's a free service to store your photos dynamically, instead of hosting on your server and spending more money.
As said one of my friends(NicolasLopes7) and owner of the repo that I took inspiration from.
First you need to add your bot to your server:
- Go to Discord Developer Portal
- Create a new application
- get the client id and add it to the url below and open it in your browser.
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot
this will redirect you to a page where you can select the server you want to add the bot to.
- Go to Discord Developer Portal.
- Select your application or create a new one following the steps to add the bot to your server.
- Go to the bot tab
- Create a new bot
- Copy the token
- Paste it in the .env file as the value of the DISCORD_TOKEN variable
- Make sure you have the developer mode enabled in your discord settings.
- Right-click on the channel you want to use and click on copy id. you can check the image below.
- Paste it in the .env file as the value of the DISCORD_CHANNEL_ID variable
copy id:
Make a generic endpoint so that you can send in a post request other informations so that this can be used inside more easily by indie developers, would go something like this:
{
"file": "...",
"botToken": "...",
"channelID": "..."
}
