Getting poll results.

Hi there, I am trying to make a bot that makes a poll and then responds with the winning answer to the poll, How do i do this? Thanks
2 Replies
d.js toolkit
d.js toolkit4w ago
- What are your intents? GuildVoiceStates is required to receive voice data! - Show what dependencies you are using -- generateDependencyReport() is exported from @discordjs/voice. - Try looking at common examples: https://github.com/discordjs/voice-examples. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Muz_
Muz_OP4w ago
const { SlashCommandBuilder } = require('discord.js');

const data = {
name: "create-poll",
description: "Create a poll",
};

// Get the current date
let now = new Date();

// Set the time to 17:00 (5:00 PM) today
now.setHours(17, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds

// Get the Unix timestamp (in seconds)
let timestamp = Math.floor(now.getTime() / 1000);

var addweek = 604800;
var addhour = 3600

var nw17 = timestamp + addweek;
var nw18 = timestamp + addweek + addhour;
var nw19 = timestamp + addweek + addhour * 2;
var nw20 = timestamp + addweek + addhour * 3;
var nw21 = timestamp + addweek + addhour * 4;


module.exports = {
data: new SlashCommandBuilder()
.setName('create_poll')
.setDescription('Creates a poll'),
async execute(interaction) {
await interaction.reply(`Time 1 = <t:${nw17}> \n Time 2 = <t:${nw18}> \n Time 3 = <t:${nw19}> \n Time 4 = <t:${nw20}> \n Time 5 = <t:${nw21}> `
)
await interaction.channel.send({
poll: {
question: { text: "Pick a time for Hide and seek next week!" },
answers: [
{ text: 'Time 1' },
{ text: 'Time 2' },
{ text: 'Time 3' },
{ text: 'Time 4' },
{ text: 'Time 5' }

]
}

})
await interaction.reply("Pick a Gamemode to play")
await interaction.channel.send({
poll: {
question: { text: "Pick the Gamemode to play!"},
answers: [
{ text: "Hide and Seek" },
{ text: "Sardines" },
{ text: "Freeze Tag" },
{ text: "Hide and Seek, Teams!"}
]
}
})


}
}
const { SlashCommandBuilder } = require('discord.js');

const data = {
name: "create-poll",
description: "Create a poll",
};

// Get the current date
let now = new Date();

// Set the time to 17:00 (5:00 PM) today
now.setHours(17, 0, 0, 0); // Set hours, minutes, seconds, and milliseconds

// Get the Unix timestamp (in seconds)
let timestamp = Math.floor(now.getTime() / 1000);

var addweek = 604800;
var addhour = 3600

var nw17 = timestamp + addweek;
var nw18 = timestamp + addweek + addhour;
var nw19 = timestamp + addweek + addhour * 2;
var nw20 = timestamp + addweek + addhour * 3;
var nw21 = timestamp + addweek + addhour * 4;


module.exports = {
data: new SlashCommandBuilder()
.setName('create_poll')
.setDescription('Creates a poll'),
async execute(interaction) {
await interaction.reply(`Time 1 = <t:${nw17}> \n Time 2 = <t:${nw18}> \n Time 3 = <t:${nw19}> \n Time 4 = <t:${nw20}> \n Time 5 = <t:${nw21}> `
)
await interaction.channel.send({
poll: {
question: { text: "Pick a time for Hide and seek next week!" },
answers: [
{ text: 'Time 1' },
{ text: 'Time 2' },
{ text: 'Time 3' },
{ text: 'Time 4' },
{ text: 'Time 5' }

]
}

})
await interaction.reply("Pick a Gamemode to play")
await interaction.channel.send({
poll: {
question: { text: "Pick the Gamemode to play!"},
answers: [
{ text: "Hide and Seek" },
{ text: "Sardines" },
{ text: "Freeze Tag" },
{ text: "Hide and Seek, Teams!"}
]
}
})


}
}
this is my code oh wait sry miss read the titles should i re post it?

Did you find this page helpful?