1

i'm looking to create a discord bot to retrieve nfts from my solana collection.

Irwing Tello

2 Answers 2

3

This question is a bit too much to handle if you want ALL the details. It's also not really clear what you want to achieve. I assume you want live updates on NFTs which your wallet holds. For example, if you bought an NFT A or sent away NFT B, you want those changes propagated on the discord server.


If you're only looking for a high level overview:

  • you need to create a tiny node.js script
  • this script would be rather simple and do only 3 things
  1. listen to on-chain changes via service like Helius
  2. convert those Helius events to discord-digestible formats
  3. push those changes to the discord server
  • you would then need to deploy the script on some server and have it run 24/7

The way that Helius notifies your backend service, and your backend service notifies discord, is called "webhooks". Webhooks are used for server-to-server communication and in their core, they're just unidirectional API calls from one service to another.

If you want to create a discord bot with minimum coding knowledge: Follow this article from Helius - Discord Sales Bot


If you want a full no-code solution, those often come with a price:

  1. untrustworthy
  2. paid services
  3. unmaintained bot services
  4. no support

I would suggest following the instructions from the article above and if you stumble upon any issues, contact Helius support on their official discord (link can be found on their website)

As an alternative you can try Shyft API

0

Creating a Discord bot to retrieve NFTs from your wallet without coding experience requires a few steps. To accomplish this, you will need a QuickNode account,a Render account, and a Discord account. Let's break down the process:

  1. Get Your Bot Token and Public Key:
  • Go to the Discord Developer Portal: https://discord.com/developers/applications and log in with your Discord account.
  • Create a new application for your bot and give it a name.
  • Under the "Bot" settings, you'll find your BOT_TOKEN. Click on "Reset Token" to generate a new one if needed.
  • To obtain the CLIENT_PUBLIC_KEY, go to the "General Information" setting and find the "Public Key" value. Copy it.
  • After that, you need to invite your bot to your discord, to get the invitation, go to the "OAuth2" section and search for the "URL Generator" sub-section.
  • In this section, you need to check the "bot" and "applications.commands" options. After that, you can see the Bot Permissions, and check the "Administrator" option.
  • At the bottom, you need to copy this invitation URL.
  • In consequence, you need to copy the generated URL and paste it into your browser, and press enter
  • Finally, you can see your bot on your community (but in the next steps we willl active this bot)
  1. Create the Commands:
  • You need to create two commands, "/info" and "/retrieve," that your bot will respond to.
  • Use the site24x7 REST API tester to create the commands.
  • For each command follow this instructions: nd use the provided JSON templates in the tutorial to define the commands.
  • Set the "method" to "POST".
  • Set the "Rest API Endpoint" to https://discord.com/api/v8/applications/[APPLICATION_ID]/commands.
  • In "Post Data" you need to check the "JSON" parameter and verify if the "raw" option is selected.
    • For the command "info" use this code:
    {
        "name": "info",
        "description": "Get information about the items from your address",
        "options": [
            {
                "name": "address",
                "description": "Address",
                "type": 3,
                "required": true
            }
        ]
    }
    
    • For the command "retrieve" use this code:
        {
        "name": "retrieve",
        "description": "Retrieve your nfts from Solana",
        "options": [
            {
                "name": "address",
                "description": "Address",
                "type": 3,
                "required": true
            },
                    {
                "name": "page",
                "description": "Set the number of page",
                "type": 3,
                "required": true
            }
        ]
    }
    
  • In "Custom Headers" you need to check the "Yes" parameter. You will see two fields "Name" and "Value". In Name, write "Authorization". In Value, Bot [Token].
  • You need to change it with the parameter returned in the steps mentioned above.
  • Click on the "Test again" button.
  • To view the response to this petition, you can scroll down.
  1. Deploy the Bot Service on Render:

    • Go to Render and click "New" to create a new web service.
    • Use the provided GitHub repository: https://github.com/irwingtello/NFTDiscordSolanaBot as the source.
    • Configure the environment variables with the values:
      • QUICKNODE_RPC_URL (obtained from QuickNode)
      • CLIENT_PUBLIC_KEY (your Discord bot's public key)
      • BOT_TOKEN (your Discord bot's token)
    • Click "Create Web Service" to deploy the bot on Render.
  2. Setting up the Service on Discord:

    • Go to the Discord Developer Portal, select your bot, and go to "General Information."
    • Change the "Interactions Endpoint URL" to your Render service URL with the path "/interactions".
    • Click "Save changes" to set up the bot service on Discord.

Now your bot is ready to use! You can use the "/info" command to see how many NFTs you have and the "/retrieve" command to fetch your NFTs. Follow the instructions in the tutorial to customize and explore more possibilities with your NFT Discord bot.

Remember to be careful with your bot token and public key and avoid sharing them publicly, as they give access to your bot's functionality and data.

Disclosure: I'm a QuickNode fan.

1
  • 1
    Hello. I removed your post for a few reasons - As part of the code of conduct you must state your affiliation with Quicknode in your answer. Secondly this is not a place to drive traffic to another tutorial but to put the actual answer in the text here. Feel free to update your answer and I will reinstate it.
    – Jacob Creech
    Jul 26, 2023 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.