ElectionsBot/src/commands.ts
2024-06-05 15:58:23 -07:00

83 lines
No EOL
2.2 KiB
TypeScript

import {ApplicationCommandOptionType} from "discord.js";
import Elections from "./elections/elections.js";
const commands = [
{
name: 'approval',
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',
description: "Simulate an election",
options: [
{
name: 'election',
description: 'The election to simulate',
type: ApplicationCommandOptionType.SubcommandGroup,
options: Object.keys(Elections).map(e => {
return {
name: e,
description: Elections[e].title,
type: ApplicationCommandOptionType.Subcommand,
options: [
{
name: 'add_candidate',
description: 'Add a candidate to the election',
type: ApplicationCommandOptionType.String,
},
{
name: 'with_party',
description: 'The party of the candidate to add',
type: ApplicationCommandOptionType.String,
},
{
name: 'with_color',
description: 'Hex color of the candidate to add',
type: ApplicationCommandOptionType.String
},
{
name: 'with_odds',
description: 'The odds of the candidate to win in any state',
type: ApplicationCommandOptionType.Number
},
...Elections[e].candidates.flatMap(c => [
{
name: c.party.toLowerCase().replace(/ /g, "_") + "_candidate",
description: `The candidate to simulate for the ${c.party} party (Default: ${c.name})`,
type: ApplicationCommandOptionType.String
},
{
name: c.party.toLowerCase().replace(/ /g, "_") + "_bias",
description: `The bias toward the ${c.party} party (Default: 0)`,
type: ApplicationCommandOptionType.Number
}
])
],
};
})
},
],
}
];
export default commands;