/create

Endpoint Headers:

  • bot-token - Token of the Bot [String] (Required)

  • apikey - Your Api Auth Key [String] (Required)

  • guild-id - ID of the guild to be fetched [Snowflake] (Required)

  • channel-id - ID of the channel to send the poll in [Snowflake] (Required)

Endpoint Body Parameters

  • question - The question to ask [String] (Required)

  • answers - Array of answer objects to choose from [Array] (Required) (See below)

  • duration - How long, in hours, the poll runs for, default 24 [Integer] (Optional)

  • multiselect - Allow users to select multiple answers, default false [Boolean] (Optional)

  • content - Message content outside the poll to send [String] (Optional)

Answer Objects

The answers array will consist of an object for each choice

  • text - The actual content of the answer choice [String] (Required)

  • emoji - An emoji object to display on the answer choice [Object] (Optional)

Emoji Objects

Within the answer objects, is also an emoji object

  • name - Name of emoji, only use for default discord emojis [Unicode Emoji] (Optional)*

  • id - Id of emoji, only use for custom emojis [Snowflake] (Optional)*

Examples:

Data API version required. Must replace <version> with either release or beta.

Bot Designer for Discord

Example usage of /poll/create endpoint using BDFD

$httpAddHeader[apikey;<YOUR-API-KEY>]
$httpAddHeader[bot-token;<YOUR-BOT-TOKEN>]
$httpAddHeader[guild-id;1064100501764968492] 
$httpAddHeader[channel-id;106410057927968435] 
$httpPost[https://bdfddata.rickyjs.xyz/<version>/poll/create;{
"question": "How are you today",
 "answers": [
   {
     "text": "I'm doing alright",
   	"emoji": {"name": "👍"}
   },
   {
   "text": "I'm not okay.",
    "emoji": {"name": "👎"}
   }
 ],
  "duration": 24, $c[24 hours]
}]


$httpResult OR $httpResult[details]
Discord.js

Example usage of /poll/create endpoint using Discord.js

const axios = require('axios');
(async () => {
return await axios.get('https://bdfddata.rickyjs.xyz/<version>/poll/create', {
"question": "How are you today",
 "answers": [
   {
     "text": "I'm doing alright",
   	"emoji": {"name": "👍"}
   },
   {
   "text": "I'm not okay.",
    "emoji": {"name": "👎"}
   }
 ],
  "duration": 24, //24 hours
},{
headers: {
"apikey": "<YOUR-API-KEY>",
"bot-token": "<YOUR-BOT-TOKEN>",
"guild-id": "16938230564996837",
"channel-id": "95727989795685839" 
}
}).then(res=>res.data)
})()

Possible Responses (Codes)

Code 200

API succeeded and details were fetched.

{
  status: 200,
    details:  {
    // will return full message object, but here is how the poll looks
        "poll": {
            "question": {
                "text": "?"
            },
            "answers": [{
                "answer_id": 1,
                "poll_media": {
                    "text": "Do it!",
                    "emoji": {
                        "id": null,
                        "name": "👍"
                    }
                }
            }, {
                "answer_id": 2,
                "poll_media": {
                    "text": "It's not necessary",
                    "emoji": {
                        "id": null,
                        "name": "👎"
                    }
                }
            }],
            "expiry": "2025-06-18T13:38:36.734927+00:00",
            "allow_multiselect": true,
            "layout_type": 1,
            "results": {
                "answer_counts": [],
                "is_finalized": false
            }
        }
    }
    
    // Read more on Message Object: https://discord.com/developers/docs/resources/message#messages-resource
}
Code 400

An error occurred that stopped execution.

{
    status: 400
    error: 'Cannot read ...  (This can vary)'
}
Code 401

Invalid bot token was provided.

{
  status: 401,
  details: { message: '401: Unauthorized', code: 0 }
}

Last updated