mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
show timeouts poll's 'for' voters
This commit is contained in:
47
index.js
47
index.js
@@ -810,6 +810,11 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
|
|
||||||
if (!poll || remaining === 0) {
|
if (!poll || remaining === 0) {
|
||||||
try {
|
try {
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -822,7 +827,7 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Pour',
|
name: 'Pour',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -849,6 +854,11 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -861,7 +871,7 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Pour',
|
name: 'Pour',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1559,15 +1569,15 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
return res.send({
|
return res.send({
|
||||||
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||||
data: {
|
data: {
|
||||||
content: "Tu as déjà voté !",
|
content: "Tu as déjà voté oui!",
|
||||||
flags: InteractionResponseFlags.EPHEMERAL,
|
flags: InteractionResponseFlags.EPHEMERAL,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the vote
|
// Record the vote
|
||||||
poll.voters.push(voterId);
|
|
||||||
if (isVotingFor) {
|
if (isVotingFor) {
|
||||||
|
poll.voters.push(voterId);
|
||||||
poll.for++;
|
poll.for++;
|
||||||
} else {
|
} else {
|
||||||
poll.against++;
|
poll.against++;
|
||||||
@@ -1585,6 +1595,11 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
if (poll.for >= poll.requiredMajority) {
|
if (poll.for >= poll.requiredMajority) {
|
||||||
try {
|
try {
|
||||||
// Build the updated poll message content
|
// Build the updated poll message content
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -1597,7 +1612,7 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Votes totaux',
|
name: 'Votes totaux',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -1648,7 +1663,11 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
const countdownText = `**${minutes}m ${seconds}s** restantes`;
|
const countdownText = `**${minutes}m ${seconds}s** restantes`;
|
||||||
try {
|
try {
|
||||||
// Build the updated poll message content
|
// Build the updated poll message content
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -1661,7 +1680,7 @@ app.post('/interactions', verifyKeyMiddleware(process.env.PUBLIC_KEY), async fun
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Pour',
|
name: 'Pour',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -2951,6 +2970,11 @@ app.post('/timeout/vote', async (req, res) => {
|
|||||||
if (poll.for >= poll.requiredMajority) {
|
if (poll.for >= poll.requiredMajority) {
|
||||||
try {
|
try {
|
||||||
// Build the updated poll message content
|
// Build the updated poll message content
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -2963,7 +2987,7 @@ app.post('/timeout/vote', async (req, res) => {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Votes totaux',
|
name: 'Votes totaux',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -3014,6 +3038,11 @@ app.post('/timeout/vote', async (req, res) => {
|
|||||||
const countdownText = `**${minutes}m ${seconds}s** restantes`;
|
const countdownText = `**${minutes}m ${seconds}s** restantes`;
|
||||||
try {
|
try {
|
||||||
// Build the updated poll message content
|
// Build the updated poll message content
|
||||||
|
let forText = ''
|
||||||
|
poll.voters.forEach(async (voter) => {
|
||||||
|
const user = await client.users.fetch(voter);
|
||||||
|
forText += `- ${user.globalName}\n`
|
||||||
|
})
|
||||||
await DiscordRequest(
|
await DiscordRequest(
|
||||||
poll.endpoint,
|
poll.endpoint,
|
||||||
{
|
{
|
||||||
@@ -3026,7 +3055,7 @@ app.post('/timeout/vote', async (req, res) => {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: 'Pour',
|
name: 'Pour',
|
||||||
value: '✅ ' + poll.for,
|
value: '✅ ' + poll.for + '\n' + forText,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user