The Husqy premium subscription is now live! Please head over to our Discord store page to get started!
We are verified! Husqy is a verified bot in Discord making us visible in the app discovery and enabling bigger trust to users!
Want to help us translate the Husqy responses? We can't do it without you! Please visit our translations repo!
Skip to main content

Husqy API Polls module

General

Endpoints related to general Husqy Modules polls.

GET - /modules/polls/

Home endpoint for the Modules Polls Husqy API. Returns only success message displaying that it is the Modules Polls API route.

GET - /modules/polls/settings

Get the settings of the polls module for the specified guild.

Query string parameters:

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to get the settings of

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
PUT - /modules/polls/settings

Endpoint to change the settings of the polls module for the specified guild.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to change the polls module settings for
save_duration_timeoutyesintegerThe amount of seconds to wait after ending a poll to delete it
delete_ended_discord_pollsyesbooleanIf ended Discord polls should be deleted from discord channels
delete_ended_husqy_pollsyesbooleanIf ended Husqy polls should be deleted from discord channels

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • DatabaseError
DELETE - /modules/polls/settings/delete

Delete all settings of the polls module for a specified guild.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to delete the settings from

Possible errors:

  • BadRequestError

Status

Endpoints related to the status of the module.

GET - /modules/polls/status

Get the status of the polls module for the specified guild.

Query string parameters:

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to check the status of

Possible errors:

  • BadRequestError
  • SettingsError
POST - /modules/polls/enable

Endpoint to enable the polls module for the specified guild.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to enable the polls module for

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleEnabledError
  • DatabaseError
POST - /modules/polls/disable

Endpoint to disable the polls module for the specified guild.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to disable the polls module for

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • DatabaseError

Polls

Endpoint related to polls.

GET - /modules/polls/entries

Endpoint to get the known polls.

Query string parameters:

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to get the known polls from
pagenointegerThe page number to get (default = 1)
page_sizenointegerThe amount of polls to return in one page (default = 10)

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
POST - /modules/polls/entries

Endpoint to create a new poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to create the poll in
channel_idyesintegerThe ID of the channel to create the poll in
poll_typeyesintegerThe type of the poll. 1 for Discord and 2 for Husqy
message_idyesintegerThe ID of the message that is a created Discord poll. Must be None when creating a poll of any type. Discord polls will be automatically registered
poll_durationyesstringThe duration of the poll. Must be in format {delay}s/m/h/d. F.e. 20m or 1h
poll_answer_typeyesintegerThe answer type of the poll. 1 for emoji, 2 for buttons or 3 for dropdown. Ignored when poll type is 1
questionyesstringThe question of the poll
descriptionyesstringAn optional description for the poll. Can be None. Ignore when poll type is 1
answersyeslistA list of answer objects containing the keys: "answer_text", "label", "description", "emoji_id", "emoji_name" and optionally "votes" (has to be an empty list of votes)
is_multi_selectyesbooleanIf the poll allows more answers per user
is_anonymousyesbooleanIf the poll is anonymous. Ignore when poll type is 1
max_votes_per_answeryesintegerThe amount of votes a member can add to an answer. Ignore when poll type is 1
poll_owner_idyesintegerThe ID of the owner of the poll
application_idyesintegerThe ID of the application interaction. Can be None
tokenyesstringThe token of the interaction. Can be None

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
  • DiscordApiInteractionError
  • Unprocessable Entity
{
"success": False,
"data": {},
"error": {
"code": 422,
"message": "Unprocessable Entity! {reason}",
},
},
GET - /modules/polls/entry/{poll_id}

Endpoint to get the specified poll.

Query string parameters:

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to get the poll from

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
DELETE - /modules/polls/entry/{poll_id}

Endpoint to delete an existing poll in the Discord server. This can only be done on Husqy polls and Discord polls send by Husqy.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to remove the poll in
application_idyesintegerThe ID of the application interaction. Can be None
tokenyesstringThe token of the interaction. Can be None

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
  • Unprocessable Entity
{
"success": False,
"data": {},
"error": {
"code": 422,
"message": "Unprocessable Entity! {reason}",
},
},
PUT - /modules/polls/entry/{poll_id}

Endpoint to edit an existing poll in the Discord server. This can only be done on Husqy polls.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to edit the poll in
questionyesstringThe new question of the poll
descriptionyesstringThe new description of the poll. Can be None to remove the description
max_votes_per_answeryesintegerThe new amount of votes a user can add to an answer
is_multi_selectyesbooleanThe new multi select setting
is_anonymousyesbooleanThe new anonymous setting
application_idyesintegerThe ID of the application interaction. Can be None
tokenyesstringThe token of the interaction. Can be None

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
  • Unprocessable Entity
{
"success": False,
"data": {},
"error": {
"code": 422,
"message": "Unprocessable Entity! {reason}",
},
},
POST - /modules/polls/entry/{poll_id}/close

Endpoint to close an poll in the Discord server. Can only be done on Husqy polls and Discord polls sent by Husqy.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to close the poll in
application_idyesintegerThe ID of the application interaction. Can be None
tokenyesstringThe token of the interaction. Can be None

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
  • Unprocessable Entity
{
"success": False,
"data": {},
"error": {
"code": 422,
"message": "Unprocessable Entity! {reason}",
},
},
POST - /modules/polls/entry/vote
danger

Do not use this endpoint yourself! To vote for an answer please interact with the poll message. Husqy will register the votes automatically!

Endpoint to vote for an answer of a poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild where the poll is located
poll_idyesstringThe ID of the poll that is voted for. Can be None to check based on channel_id and interacted_message_id
answer_idyesintegerThe ID the answer to vote for. Can be None to check based on emoji_id and emoji_name
actionyesstringThe action to use. "add" for adding a vote and "remove" to remove votes
message_idyesintegerThe ID of the message that is created by Husqy when interacting with the poll. Can be None.
emoji_idyesintegerThe ID of the custom emoji. Can be None.
emoji_nameyesstringThe name or literal emoji that is reacted with. Can be None.
channel_idyesintegerThe ID of the channel where the poll is located.
interacted_message_idyesintegerThe ID of the message that is interacted with. Can be None.
application_idyesintegerThe ID of the application interaction. Can be None
tokenyesstringThe token of the interaction. Can be None

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError
  • InternalServerError
  • Unprocessable Entity
{
"success": False,
"data": {},
"error": {
"code": 422,
"message": "Unprocessable Entity! {reason}",
},
},
DELETE - /modules/polls/entry/delete-poll-on-message-delete
danger

Do not use this endpoint yourself! Husqy will automatically check deleted messages for polls.

Endpoint to delete an poll in the Discord server when a deleted message was a poll.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to delete the poll from
channel_idyesintegerThe ID of the channel where the deleted message was located
interacted_message_idyesintegerThe ID of the deleted message

Possible errors:

  • BadRequestError
  • SettingsError
  • ModuleDisabledError

Handler

GET - /modules/polls/handler

Home endpoint for the Modules Polls Entries Husqy API. Returns only success message displaying that it is the Modules Polls Entries API route.

POST - /modules/polls/handler/create
danger

Do not use this endpoint yourself! To create a poll use the POST - /modules/polls/entries endpoint.

Endpoint to create a new poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to create the poll in
poll_idyesstringThe ID of the poll to create
channel_idyesintegerThe ID of the channel to create the poll in
poll_typeyesintegerThe type of the poll. 1 for Discord and 2 for Husqy
message_idyesintegerThe ID of the message that is a created Discord poll. Must be None when creating a poll of any type. Discord polls will be automatically registered
edited_with_resultsyesbooleanIndicator if the poll is already edited because it is finished.
poll_answer_typeyesintegerThe answer type of the poll. 1 for emoji, 2 for buttons or 3 for dropdown. Ignored when poll type is 1
questionyesstringThe question of the poll
descriptionyesstringAn optional description for the poll. Can be None. Ignore when poll type is 1
end_timeyesintegerThe end time of the poll
delete_atyesintegerThe time at which the poll will be deleted
languageyesstringThe language of the server
auto_deleteyesintegerThe auto delete of the server
answersyeslistA list of answer objects containing the keys: "answer_text", "label", "description", "emoji_id", "emoji_name" and optionally "votes" (has to be an empty list of votes)
is_multi_selectyesbooleanIf the poll allows more answers per user
is_anonymousyesbooleanIf the poll is anonymous. Ignore when poll type is 1
max_votes_per_answeryesintegerThe amount of votes a member can add to an answer. Ignore when poll type is 1
sent_by_husqyyesbooleanIndicator if the poll message is sent by Husqy
poll_owner_idyesintegerThe ID of the owner of the poll

Possible errors:

  • BadRequestError
DELETE - /modules/polls/handler/delete
danger

Do not use this endpoint yourself! To delete a poll use the POST - /modules/polls/entry/{poll_id} endpoint.

Endpoint to delete a poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to delete the poll in
poll_idyesstringThe ID of the poll to delete

Possible errors:

  • BadRequestError
POST - /modules/polls/handler/edit
danger

Do not use this endpoint yourself! To edit a poll use the PUT - /modules/polls/entry/{poll_id} endpoint.

Endpoint to edit a poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to edit the poll in
poll_idyesstringThe ID of the poll to edit
questionyesstringThe new question of the poll
descriptionyesstringThe new description of the poll. Can be None to remove the description
max_votes_per_answeryesintegerThe new amount of votes a user can add to an answer
is_multi_selectyesbooleanThe new multi select setting
is_anonymousyesbooleanThe new anonymous setting

Possible errors:

  • BadRequestError
POST - /modules/polls/handler/close
danger

Do not use this endpoint yourself! To close a poll use the POST - /modules/polls/entry/{poll_id}/close endpoint.

Endpoint to close a poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to close the poll in
poll_idyesstringThe ID of the poll to close

Possible errors:

  • BadRequestError
POST - /modules/polls/handler/vote
danger

Do not use this endpoint yourself! To vote for a poll interact with the poll in Discord.

Endpoint to vote for a poll in the Discord server.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to close the poll in
poll_idyesstringThe ID of the poll to close
actionyesstringThe vote action. "add" or "remove"
answer_idyesintegerThe ID of the answer to add the vote to or remove the vote from

Possible errors:

  • BadRequestError

Privacy

Endpoints related to privacy and the polls module

GET - /modules/polls/privacy/get-user-entries
danger

Do not use this endpoint yourself! This endpoint will be used by Husqy's Privacy configurator (/privacy) command.

Endpoint to get the amount of references in the polls module to your user.

Query string parameters:

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to get the specified references in
privacy_member_idyesintegerThe ID of the member who wants to check their references

Possible errors:

  • BadRequestError
  • ForbiddenError
  • InternalServerError
DELETE - /modules/polls/privacy/delete-user-entries
danger

Do not use this endpoint yourself! This endpoint will be used by Husqy's Privacy configurator (/privacy) command.

Endpoint to delete the references in polls module to your user.

Body data (JSON):

fieldrequiredtypedescription
guild_idyesintegerThe ID of the guild to delete the specified references in
privacy_member_idyesintegerThe ID of the member who wants to remove their references

Possible errors:

  • BadRequestError
  • ForbiddenError
  • InternalServerError