LogoLogo
Github
  • Overview
    • 📄Litepaper
  • GraphLinq Chain
    • Networks
      • Specs
        • Geth Client
        • Clique Consensus
      • GraphLinq Chain (Mainnet)
        • Wallet
          • Add GraphLinq Chain to Metamask
          • Add GraphLinq Chain To Ledger
        • RPC Public Nodes
        • Json-RPC API
        • Libraries
        • Execution Clients
        • Explorer
        • Status
    • GLQ
      • Allocation
      • Bridge
      • Rewards
  • 🎶Run a node
    • Installation
  • Dev tooling
    • Introduction
      • Vision
    • Graphs
      • What are Graphs and how do they work?
      • Creating a graph
      • File compression
      • Graph Cycle Costs
      • Node & Fees
    • Engine
      • Setting up the environment
      • Running an Engine locally
    • Dashboard Interface
      • Importing Graph/Template
      • Deploying a Graph
      • Managing Graph State
    • Blocks
      • Base Variable
        • Boolean
        • Decimal
        • Integer
        • KeyValue
        • Long
        • String
        • Get variable
        • Is Variable Exist
        • Set variable
        • Variable Portal
        • Secret String
      • Common
        • Entry Point
        • On Graph Start
        • Stop Graph
      • Time
        • Get Milliseconds Timestamp
        • Get Milliseconds Timestamp Offset
        • Get Timestamp
        • Get Timestamp Offset
        • Timer
        • Format Date
        • Millisecond Timestamp to Date
        • Timestamp to Date
        • Execution Time Interval
      • JSON
        • Last Node to JSON
        • Convert To JSON
        • Add JSON Property
        • Create JSON Object
        • JSON Deserialize To Array
        • JSON to JSON Object
        • Merge JSON
        • Serialize JSON Object
        • Serialize to JSON
      • Log
        • Print
      • WebSocket
        • WebSocket Client Close
        • WebSocket Client Connector
        • On WebSocket Client Disconnect
        • WebSock Receive Data Event
        • WebSocket Send Data
      • String
        • String Contains
        • Concat String
        • Replace String in String
      • Math
        • Subtract A - B
        • Add A + B
        • Ceiling
        • Divide A / B
        • Floor
        • Modulo A % B
        • Multiply A * B
        • Percentage Difference
        • Round
      • HTTP
        • Array To Body Values
        • Array To JSON Body
        • Put HTTP Request
        • Post HTTP Request
        • Get HTTP Request
        • Delete HTTP Request
      • Function
        • Function Block
        • Add Function Parameter
        • Set Function Result
        • Call Function
        • Get Function Result Parameter
        • Get Function Parameter
      • Transformers
        • String to Base64
      • Data
      • CSV
      • Base Condition
        • Decimal Branch
        • Integer Branch
        • String Branch
        • Boolean Branch
      • Range Condition
        • Decimal Range Branch
      • Array
        • Add Array Element
        • Clear Array
        • Create Array
        • Each Element In Array
        • Get Array Element At Index
        • Get Array Size
        • Keep Last X Elements In Array
      • Dictionary
      • Hosted API
    • Blocks (Messaging)
      • Twitter
      • Twitch
      • Telegram
      • SMTP
      • ShortenURL
      • PushOver
      • PushBullet
      • OpenAI
      • Discord
        • Add Emoji On Message
        • Send Discord Channel File
        • Add Role User
        • On Discord Channel Message
        • On Reaction Added Message
        • On Reaction Removed Message
        • Remove Role User
        • Reply Private Discord Message
        • Send Discord Channel Message
        • Discord Connector
        • On Discord Private Message
    • Blocks (Exchange)
      • Binance
      • Bitfinex
      • Bittrex
      • CoinEx
      • CoinGecko
        • Get CoinGecko Coin
      • Huobi
      • Kraken
      • KuCoin
      • LiveCoinWatch
      • MXC
    • Blocks (Blockchains)
      • Avalanche
        • Network Blocks
          • Avalanche Connector
          • Get Block Parameters
          • Get Transaction Parameters
          • On Avalanche Block
          • On Avalanche Transaction
        • Avascan
          • Get Avascan Supply
          • Get Avascan Global Stats
          • Get Avascan Staking Stats
          • Get Avascan Burned Fees
        • SnowTrace
          • SnowTrace Connector
          • Get ERC-20 Balance For Contract
          • Get ERC-20 Token Supply
          • Get Total AVAX on C-Chain
          • Get AVAX Balance Single Address
      • Binance Smart Chain
        • Network Blocks
          • Binance Smart Chain Connector
          • On Binance Smart Chain Block
          • On Binance Smart Chain Transaction
          • On Binance Smart Chain Wallet Transaction
        • BEP20 Blocks
          • Create BEP20 Token
          • Deploy BEP20 Token
      • Elrond
        • Elrond Connector
        • Get Elrond HyperBlock By Hash
        • Get Elrond Transaction
        • Get Elrond Wallet Balance
      • Ethereum
        • Ethereum Connector
        • On Ethereum Block
        • On Ethereum Transaction
        • On Ethereum Wallet Transaction
        • Estimate Gas Price
        • Get Ether Balance
        • Get Block Parameters
        • Get Transaction Parameters
        • Etherscan
          • Etherscan Connector
          • Etherscan Get Gas Price
        • Ethereum Managed Wallet
          • Get Personal Managed Wallet
        • Ethereum ERC20
          • Get ERC20 Holders
          • Get ERC20 Balance
          • Get ERC20 Information
          • Create ERC20 Token
          • Deploy ERC20 Token
        • Ethereum NFT
          • Create NFT Contract
          • Deploy NFT Contact
          • Create New Mintable NFT Token
          • Deploy New Mintable NFT Token
      • Polygon
        • Polygon Connector
      • Quickswap
        • Get Quickswap Pair Price
        • Get Quickswap Token Price
        • Get Quickswap LP Token
        • Get Quickswap LP Token Price
        • On Quickswap Swap
        • On Quickswap Sync
      • Unicrypt
        • Get Unicrypt Locked Token Parameters
        • Get Unicrypt Locked Tokens
        • Get Unicrypt Total Locked Liquidity
        • Get Unicrypt All LP Locked Tokens Address
        • On Unicrypt Deposit
      • Uniswap
        • Get Uniswap LP Token
        • Get Uniswap LP Token Price
        • Uniswap Get Pair Price
        • Get Uniswap Token Price
        • On Uniswap Swap
        • On Uniswap Sync
      • Solana
    • Blocks (Charting)
      • Generate Time Series One Line Chart
      • Generate Time Series Two Line Chart
    • Blocks (Machine Learning)
      • Spam Detection
      • Sentiment Analysis
    • Node Connector Colors
      • Strings & Variables
      • Execution Logic (Yellow)
      • Integers (orange)
      • Booleans (pink)
    • Block Execution Order
      • Additional Block Execution
    • Block Color
      • Colors & Meaning
    • Block Type Overview
      • Function Type
      • Entry Point Type
      • Event Trigger Type
      • Variable Type
      • Condition Type
      • Connector Type
  • Nocode Users
    • Instant Deploy Wizard
    • GraphLinq Marketplace
  • Twitter
  • Medium
  • Github
  • GraphLinq Explorer
  • Audit Report
Powered by GitBook
On this page
  1. Dev tooling
  2. Blocks (Messaging)
  3. Discord

Discord Connector

PreviousSend Discord Channel MessageNextOn Discord Private Message

Last updated 2 years ago

Discord Connector blocks are used to establish a connection to Discord's API through an access token that represents either a Discord account or a Discord bot.

These blocks are essential for everything related to Discord that we want to do with our graph. The other blocks in this category all require an input parameter called "Discord"; this piece of data is an API connection that allows our graph to interact with Discord, and this essential connection is what is generated by Discord Connector blocks.

Discord Connector blocks have two input parameters: "Token" and "Type".

For "Type", we must pass either the string "bot" or the string "account", depending upon whether we would like to interact with Discord using a Discord bot that we control or a Discord user account that we control.

For "Token", we must pass the Discord token for the bot or the user account with which we want to interact with Discord.

If you are trying to find the token of a Discord bot that you have made, you can navigate to the Discord Developer Portal, click on your bot in the Applications tab, then click on the Bot tab of the Settings Menu, and click the "Reveal Token" link. If you got the bot from a third party (like a MEE6 bot for example), you will have to go through their interface to find your bot's token.

If you are instead trying to find the token of your Discord user account, you can navigate to the and then open Developer Tools (Ctrl + Shift + I in Chrome). Once that is open, go to the Network tab, refresh the page, and then search for "/api" in the filter bar. One of the results should be named "applications" (or similar); after clicking on this, go to the Headers tab and scroll down into the Request Headers section until you see "authorization: ". The string that follows is your Discord account token.

Once we have filled in the "Type" and "Token" input parameters using blocks, our Discord Connector's output (the white "Discord" link) is ready to be connected to any block that requires a Discord API connection as input.

If our graph contains several blocks that require a Discord API connection, a natural technique is to use a block one time to initialize a variable with the connection output by the Discord Connector block. Then, we can retrieve the connection using blocks whenever we need to use it.

We can see an example of this kind of initialization in the following image:

In the example above, we have established a Discord API connection through some Discord bot that we know the token for, and then we have saved this connection as a variable named "discord" using a Set variable block. The implication in this example is that, elsewhere in the same graph, we would be using Get variable blocks to retrieve this connection whenever we need to use it as input for some Discord-related block.

Note that, as with all connector blocks, Discord Connector blocks execute immediately and automatically when a graph begins, so the initialization process above would occur before any other part of the graph could possibly run.

In the following example, we have opted to link our Discord Connector block directly to the two blocks that require it, rather than storing its output as a variable:

In the example above, we are listening in a specific Discord channel for anyone to say the string "/btcvolume". When that string is detected, the linked Discord account will reply with a short message containing the 24-hour volume of Bitcoin, obtained from CoinGecko.

In this case, we have specified that our Discord connection will be through an account rather than a bot, and we have supplied the Discord account token for an account we control to the Discord Connector block.

The Send Discord Channel Message the block is also passed the same Discord connection from our Discord Connector block that we used for our On Discord Channel Message block earlier, which means that the same account that was used to listen to messages will also be used to post the reply. We also link the "GuildId" (ID of the Discord server), and "Channel" (ID of the Discord channel) outputs of the On Discord Channel Message block to the Send Discord Channel Message block, so that the response will be made in the same server and channel as the "/btcvolume" message was detected in.

The Discord connection that is produced (the output labeled "Discord") is then passed to a block. This block has been supplied with the channel ID for the Discord channel we want to be listening to (you can obtain the ID of your Discord channel by right-clicking on the channel in the Discord app and clicking "Copy ID").

Any time any message is sent to that Discord channel, our On Discord Channel Message the block will fire, and pass along the message to a block to see if the message is "/btcvolume". If it is, then we grab the 24-hour volume of Bitcoin using a block, pack it into a short message using a block, and then output it into the Discord channel using a block.

On Discord Channel Message
String Branch
Get CoinGecko Coin
Replace String In String
Send Discord Channel Message
Discord Developer Portal
String
Set variable
Get variable