Add approval rating command
This commit is contained in:
parent
c3c543cf7e
commit
f073c48cc7
4 changed files with 275 additions and 108 deletions
225
data/approval_rating.json
Normal file
225
data/approval_rating.json
Normal file
|
@ -0,0 +1,225 @@
|
||||||
|
{
|
||||||
|
"rcp": {
|
||||||
|
"description": "President Biden Job Approval (source: RealClearPolling)",
|
||||||
|
"polls": [
|
||||||
|
{
|
||||||
|
"pollster": "RCP Average",
|
||||||
|
"date": "5/1 - 6/4",
|
||||||
|
"sample": "None",
|
||||||
|
"approve": "40.4",
|
||||||
|
"disapprove": "56.0",
|
||||||
|
"spread": "-15.6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Economist/YouGov](https://d3nkl3psvxxpe9.cloudfront.net/documents/econTabReport_nL3J3e1.pdf)",
|
||||||
|
"date": "6/2 - 6/4",
|
||||||
|
"sample": "1566 RV",
|
||||||
|
"approve": "40",
|
||||||
|
"disapprove": "58",
|
||||||
|
"spread": "-18"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Rasmussen Reports](https://www.rasmussenreports.com/public_content/politics/biden_administration/biden_approval_index_history)",
|
||||||
|
"date": "5/29 - 6/4",
|
||||||
|
"sample": "1500 LV",
|
||||||
|
"approve": "44",
|
||||||
|
"disapprove": "54",
|
||||||
|
"spread": "-10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Data for Progress (D)](https://www.filesforprogress.org/datasets/2024/6/dfp_trump_verdict.pdf)",
|
||||||
|
"date": "5/31 - 6/1",
|
||||||
|
"sample": "1216 LV",
|
||||||
|
"approve": "42",
|
||||||
|
"disapprove": "57",
|
||||||
|
"spread": "-15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[TIPP](https://tippinsights.com/confidence-deficit-will-it-derail-the-presidents-reelection-bid/)",
|
||||||
|
"date": "5/29 - 5/31",
|
||||||
|
"sample": "1910 A",
|
||||||
|
"approve": "36",
|
||||||
|
"disapprove": "52",
|
||||||
|
"spread": "-16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Newsnation](https://www.newsnationnow.com/polls/poll-debates-rfk-economy/)",
|
||||||
|
"date": "5/28 - 5/29",
|
||||||
|
"sample": "1000 RV",
|
||||||
|
"approve": "42",
|
||||||
|
"disapprove": "58",
|
||||||
|
"spread": "-16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Emerson](https://emersoncollegepolling.com/may-2024-national-poll-trump-46-biden-44/)",
|
||||||
|
"date": "5/21 - 5/23",
|
||||||
|
"sample": "1000 RV",
|
||||||
|
"approve": "37",
|
||||||
|
"disapprove": "52",
|
||||||
|
"spread": "-15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[NPR/PBS/Marist](https://maristpoll.marist.edu/wp-content/uploads/2024/05/NPR_PBS-NewsHour_Marist-Poll_USA-NOS-and-Tables_202405241406.pdf)",
|
||||||
|
"date": "5/21 - 5/23",
|
||||||
|
"sample": "1122 RV",
|
||||||
|
"approve": "41",
|
||||||
|
"disapprove": "55",
|
||||||
|
"spread": "-14"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"thehill": {
|
||||||
|
"description": "Biden approval rating polls (source: The Hill/DDHQ)",
|
||||||
|
"polls": [
|
||||||
|
{
|
||||||
|
"pollster": "Average",
|
||||||
|
"date": "May 1 - Jun 4",
|
||||||
|
"sample": "None",
|
||||||
|
"approve": "42.0",
|
||||||
|
"disapprove": "55.0",
|
||||||
|
"spread": "+13.5 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Economist/YouGov](https://d3nkl3psvxxpe9.cloudfront.net/documents/econTabReport_nL3J3e1.pdf)",
|
||||||
|
"date": "Jun 2 - 4",
|
||||||
|
"sample": "1,566 RV",
|
||||||
|
"approve": "40",
|
||||||
|
"disapprove": "58",
|
||||||
|
"spread": "+18 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Rasmussen Reports](https://www.rasmussenreports.com/public_content/politics/biden_administration/prez_track_june05)",
|
||||||
|
"date": "May 31 - Jun 4",
|
||||||
|
"sample": "1,500 LV",
|
||||||
|
"approve": "44",
|
||||||
|
"disapprove": "54",
|
||||||
|
"spread": "+10 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Rasmussen Reports](https://www.rasmussenreports.com/public_content/politics/biden_administration/prez_track_june04)",
|
||||||
|
"date": "May 30 - Jun 3",
|
||||||
|
"sample": "1,500 LV",
|
||||||
|
"approve": "44",
|
||||||
|
"disapprove": "55",
|
||||||
|
"spread": "+11 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Rasmussen Reports](https://www.rasmussenreports.com/public_content/politics/biden_administration/prez_track_june04)",
|
||||||
|
"date": "May 29 - Jun 2",
|
||||||
|
"sample": "1,500 LV",
|
||||||
|
"approve": "44",
|
||||||
|
"disapprove": "55",
|
||||||
|
"spread": "+11 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Data for Progress](https://www.dataforprogress.org/blog/2024/6/3/majority-of-voters-approve-of-trumps-guilty-verdict)",
|
||||||
|
"date": "May 31 - Jun 1",
|
||||||
|
"sample": "1,500 LV",
|
||||||
|
"approve": "42",
|
||||||
|
"disapprove": "57",
|
||||||
|
"spread": "+15 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[TIPP](https://drive.google.com/file/d/1l4Qb930ytyI5lsa67UNTOv030pw5qAAE/view?usp=drive_link)",
|
||||||
|
"date": "May 31 - Jun 1",
|
||||||
|
"sample": "1,910 Adults",
|
||||||
|
"approve": "52",
|
||||||
|
"disapprove": "36",
|
||||||
|
"spread": "+16 Disapprove"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[ActiVote](https://www.activote.net/activote_polling/)",
|
||||||
|
"date": "May 1 - 31",
|
||||||
|
"sample": "1,501 RV",
|
||||||
|
"approve": "55.6",
|
||||||
|
"disapprove": "38.6",
|
||||||
|
"spread": "+17 Disapprove"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"fivethirtyeight": {
|
||||||
|
"description": "How popular/unpopular is Joe Biden? (source: FiveThirtyEight)",
|
||||||
|
"polls": [
|
||||||
|
{
|
||||||
|
"pollster": "Average",
|
||||||
|
"date": "N/A",
|
||||||
|
"sample": "None",
|
||||||
|
"approve": "37.8",
|
||||||
|
"disapprove": "56.5",
|
||||||
|
"approve_adjusted": "37.8",
|
||||||
|
"disapprove_adjusted": "56.5",
|
||||||
|
"spread": "Disapprove +18.7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[YouGov](https://d3nkl3psvxxpe9.cloudfront.net/documents/econtoplines_x5cabBL.pdf)",
|
||||||
|
"date": "Jun. 2 - 4",
|
||||||
|
"sample": "1,784 A",
|
||||||
|
"approve": "37",
|
||||||
|
"disapprove": "57",
|
||||||
|
"approve_adjusted": "37",
|
||||||
|
"disapprove_adjusted": "58",
|
||||||
|
"spread": "Disapprove +18"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[Data for Progress](https://www.dataforprogress.org/blog/2024/6/3/majority-of-voters-approve-of-trumps-guilty-verdict)",
|
||||||
|
"date": "May 31-Jun. 1",
|
||||||
|
"sample": "1,216 LV",
|
||||||
|
"approve": "42",
|
||||||
|
"disapprove": "57",
|
||||||
|
"approve_adjusted": "39",
|
||||||
|
"disapprove_adjusted": "56",
|
||||||
|
"spread": "Disapprove +17"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[SurveyMonkey](https://www.surveymonkey.com/curiosity/19th-hush-money-trial-poll/)",
|
||||||
|
"date": "May 30-31",
|
||||||
|
"sample": "5,893 A",
|
||||||
|
"approve": "37",
|
||||||
|
"disapprove": "60",
|
||||||
|
"approve_adjusted": "36",
|
||||||
|
"disapprove_adjusted": "58",
|
||||||
|
"spread": "Disapprove +22"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[TIPP Insights](https://tippinsights.com/confidence-deficit-will-it-derail-the-presidents-reelection-bid/)",
|
||||||
|
"date": "May 29-31",
|
||||||
|
"sample": "1,910 A",
|
||||||
|
"approve": "36",
|
||||||
|
"disapprove": "52",
|
||||||
|
"approve_adjusted": "36",
|
||||||
|
"disapprove_adjusted": "57",
|
||||||
|
"spread": "Disapprove +20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[ActiVote](https://www.activote.net/bidens-approval-drops-back-down/)",
|
||||||
|
"date": "May 1-May 31",
|
||||||
|
"sample": "1,501 RV",
|
||||||
|
"approve": "39",
|
||||||
|
"disapprove": "56",
|
||||||
|
"approve_adjusted": "39",
|
||||||
|
"disapprove_adjusted": "55",
|
||||||
|
"spread": "Disapprove +16"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[RMG Research](https://x.com/RMG_Research/status/1796652518576934994)",
|
||||||
|
"date": "May 28-29",
|
||||||
|
"sample": "2,000 RV",
|
||||||
|
"approve": "44",
|
||||||
|
"disapprove": "55",
|
||||||
|
"approve_adjusted": "43",
|
||||||
|
"disapprove_adjusted": "54",
|
||||||
|
"spread": "Disapprove +12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pollster": "[NewsNation](https://www.newsnationnow.com/polls/poll-debates-rfk-economy/)",
|
||||||
|
"date": "May 28-29",
|
||||||
|
"sample": "1,000 RV",
|
||||||
|
"approve": "42",
|
||||||
|
"disapprove": "58",
|
||||||
|
"approve_adjusted": "38",
|
||||||
|
"disapprove_adjusted": "57",
|
||||||
|
"spread": "Disapprove +19"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,100 +0,0 @@
|
||||||
{
|
|
||||||
"approval": {
|
|
||||||
"polls": [{
|
|
||||||
"pollster": "RCP Average",
|
|
||||||
"date": "5/1 - 5/30",
|
|
||||||
"sample": "None",
|
|
||||||
"approve": "40.5",
|
|
||||||
"disapprove": "56.2",
|
|
||||||
"spread": "-15.7"
|
|
||||||
}, {
|
|
||||||
"pollster": "Rasmussen Reports",
|
|
||||||
"date": "5/26 - 5/30",
|
|
||||||
"sample": "1500 LV",
|
|
||||||
"approve": "44",
|
|
||||||
"disapprove": "55",
|
|
||||||
"spread": "-11"
|
|
||||||
}, {
|
|
||||||
"pollster": "Economist/YouGov",
|
|
||||||
"date": "5/25 - 5/28",
|
|
||||||
"sample": "1547 RV",
|
|
||||||
"approve": "40",
|
|
||||||
"disapprove": "58",
|
|
||||||
"spread": "-18"
|
|
||||||
}, {
|
|
||||||
"pollster": "Emerson",
|
|
||||||
"date": "5/21 - 5/23",
|
|
||||||
"sample": "1000 RV",
|
|
||||||
"approve": "37",
|
|
||||||
"disapprove": "52",
|
|
||||||
"spread": "-15"
|
|
||||||
}, {
|
|
||||||
"pollster": "NPR/PBS/Marist",
|
|
||||||
"date": "5/21 - 5/23",
|
|
||||||
"sample": "1122 RV",
|
|
||||||
"approve": "41",
|
|
||||||
"disapprove": "55",
|
|
||||||
"spread": "-14"
|
|
||||||
}, {
|
|
||||||
"pollster": "Reuters/Ipsos",
|
|
||||||
"date": "5/17 - 5/20",
|
|
||||||
"sample": "1017 A",
|
|
||||||
"approve": "36",
|
|
||||||
"disapprove": "59",
|
|
||||||
"spread": "-23"
|
|
||||||
}, {
|
|
||||||
"pollster": "Quinnipiac",
|
|
||||||
"date": "5/16 - 5/20",
|
|
||||||
"sample": "1374 RV",
|
|
||||||
"approve": "39",
|
|
||||||
"disapprove": "56",
|
|
||||||
"spread": "-17"
|
|
||||||
}, {
|
|
||||||
"pollster": "Harvard-Harris",
|
|
||||||
"date": "5/15 - 5/16",
|
|
||||||
"sample": "1660 RV",
|
|
||||||
"approve": "44",
|
|
||||||
"disapprove": "55",
|
|
||||||
"spread": "-11"
|
|
||||||
}, {
|
|
||||||
"pollster": "Gallup",
|
|
||||||
"date": "5/1 - 5/23",
|
|
||||||
"sample": "1024 A",
|
|
||||||
"approve": "39",
|
|
||||||
"disapprove": "56",
|
|
||||||
"spread": "-17"
|
|
||||||
}, {
|
|
||||||
"pollster": "FOX News",
|
|
||||||
"date": "5/10 - 5/13",
|
|
||||||
"sample": "1126 RV",
|
|
||||||
"approve": "45",
|
|
||||||
"disapprove": "55",
|
|
||||||
"spread": "-10"
|
|
||||||
}, {
|
|
||||||
"pollster": "Yahoo News",
|
|
||||||
"date": "5/10 - 5/13",
|
|
||||||
"sample": "1200 RV",
|
|
||||||
"approve": "41",
|
|
||||||
"disapprove": "57",
|
|
||||||
"spread": "-16"
|
|
||||||
}, {
|
|
||||||
"pollster": "Marquette",
|
|
||||||
"date": "5/6 - 5/15",
|
|
||||||
"sample": "811 RV",
|
|
||||||
"approve": "40",
|
|
||||||
"disapprove": "60",
|
|
||||||
"spread": "-20"
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
"general": {
|
|
||||||
"polls": [{
|
|
||||||
"pollster": "RCP Average",
|
|
||||||
"date": "5/10 - 5/31",
|
|
||||||
"sample": "",
|
|
||||||
"moe": "",
|
|
||||||
"r_margin": "46.9",
|
|
||||||
"d_margin": "46.3",
|
|
||||||
"spread": "Trump +0.6"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,8 +2,29 @@ import {ApplicationCommandOptionType} from "discord.js";
|
||||||
import Elections from "./elections/elections.js";
|
import Elections from "./elections/elections.js";
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'poll',
|
name: 'approval',
|
||||||
description: "Displays the latest poll numbers from a source (defaults to RealClearPolitics)"
|
description: "Displays the latest approval rating for Biden based on poll numbers",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'source',
|
||||||
|
description: 'The source to use for the polling data',
|
||||||
|
type: ApplicationCommandOptionType.String,
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: 'RealClearPolling',
|
||||||
|
value: 'rcp',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'The Hill',
|
||||||
|
value: 'thehill',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'FiveThirtyEight',
|
||||||
|
value: 'fivethirtyeight',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'simulate',
|
name: 'simulate',
|
||||||
|
|
31
src/index.ts
31
src/index.ts
|
@ -26,13 +26,34 @@ if (!config.token) {
|
||||||
if (i instanceof CommandInteraction) {
|
if (i instanceof CommandInteraction) {
|
||||||
await i.deferReply();
|
await i.deferReply();
|
||||||
switch (i.commandName) {
|
switch (i.commandName) {
|
||||||
case "poll":
|
case "approval":
|
||||||
const rcp_polls = JSON.parse(fs.readFileSync('data/rcp_polls.json', "utf-8"));
|
let poll_data = JSON.parse(fs.readFileSync('data/approval_rating.json', "utf-8"));
|
||||||
let polls = "";
|
let polls = "";
|
||||||
Object.keys(rcp_polls.approval.polls).forEach(poll => {
|
var source = i.options.get('source')?.value as string
|
||||||
polls += `:red_circle: **${rcp_polls.approval.polls[poll].pollster}** - (**${rcp_polls.approval.polls[poll].date}**), ${rcp_polls.approval.polls[poll].sample}, **${rcp_polls.approval.polls[poll].approve}**% approve, **${rcp_polls.approval.polls[poll].disapprove}**% disapprove (spread: **${rcp_polls.approval.polls[poll].spread}**)\n`;
|
switch (source) {
|
||||||
|
case "thehill":
|
||||||
|
// source: https://elections2024.thehill.com/national/biden-approval-rating/
|
||||||
|
polls = `${poll_data.thehill.description}:\n\n`;
|
||||||
|
Object.keys(poll_data.thehill.polls).forEach(poll => {
|
||||||
|
polls += `:red_circle: **${poll_data.thehill.polls[poll].pollster}** - (**${poll_data.thehill.polls[poll].date}**), ${poll_data.thehill.polls[poll].sample}, **${poll_data.thehill.polls[poll].approve}**% approve, **${poll_data.thehill.polls[poll].disapprove}**% disapprove (**${poll_data.thehill.polls[poll].spread}**)\n`;
|
||||||
});
|
});
|
||||||
await i.editReply(`Biden Approval Rating\n\n${polls}`);
|
break;
|
||||||
|
case "fivethirtyeight":
|
||||||
|
// source: https://projects.fivethirtyeight.com/biden-approval-rating/
|
||||||
|
polls = `${poll_data.fivethirtyeight.description}:\n\n`;
|
||||||
|
Object.keys(poll_data.fivethirtyeight.polls).forEach(poll => {
|
||||||
|
polls += `:red_circle: **${poll_data.fivethirtyeight.polls[poll].pollster}** - (**${poll_data.fivethirtyeight.polls[poll].date}**), ${poll_data.fivethirtyeight.polls[poll].sample}, **${poll_data.fivethirtyeight.polls[poll].approve}**% approve, **${poll_data.fivethirtyeight.polls[poll].disapprove}**% disapprove (adjusted: **${poll_data.fivethirtyeight.polls[poll].approve_adjusted}**% approve, **${poll_data.fivethirtyeight.polls[poll].disapprove_adjusted}**% disapprove) (**${poll_data.fivethirtyeight.polls[poll].spread}**)\n`;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// source: https://www.realclearpolling.com/polls/approval/joe-biden/approval-rating
|
||||||
|
polls = `${poll_data.rcp.description}:\n\n`;
|
||||||
|
Object.keys(poll_data.rcp.polls).forEach(poll => {
|
||||||
|
polls += `:red_circle: **${poll_data.rcp.polls[poll].pollster}** - (**${poll_data.rcp.polls[poll].date}**), ${poll_data.rcp.polls[poll].sample}, **${poll_data.rcp.polls[poll].approve}**% approve, **${poll_data.rcp.polls[poll].disapprove}**% disapprove (spread: **${poll_data.rcp.polls[poll].spread}**)\n`;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await i.editReply(`${polls}`);
|
||||||
break;
|
break;
|
||||||
case "simulate":
|
case "simulate":
|
||||||
var electionname = (i.options as CommandInteractionOptionResolver).getSubcommand();
|
var electionname = (i.options as CommandInteractionOptionResolver).getSubcommand();
|
||||||
|
|
Loading…
Reference in a new issue