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
4 Replies
d.js toolkit
d.js toolkit3w ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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!
Muz_
Muz_OP3w 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!"}
]
}
})


}
}
can i use await interaction.MessageUpdate?
d.js docs
d.js docs3w ago
:event: (event) Client#messageUpdate @14.16.3 Emitted whenever a message is updated - e.g. embed or content change.
Muz_
Muz_OP3w ago
so how do i?
Want results from more Discord servers?
Add your server