Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize to any kind of polls #76

Merged
merged 5 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PrismaClient } from "@prisma/client";
import { InteractionHandlers, CommandProvider, Chore } from "./bot.d";

import * as utils from "./modules/utils";
import * as attendance from "./modules/attendance";
import * as polls from "./modules/polls";
import * as roleSelection from "./modules/roleSelection";
import * as sudo from "./modules/sudo";
import * as misc from "./modules/misc";
Expand Down Expand Up @@ -48,7 +48,7 @@ const client = new Discord.Client({
});

const commandProviders: CommandProvider[] = [
attendance.provideCommands,
polls.provideCommands,
roleSelection.provideCommands,
sudo.provideCommands,
misc.provideCommands,
Expand All @@ -62,7 +62,7 @@ const commandHandlers: InteractionHandlers<Discord.CommandInteraction> = {};
// two above will be dynamically loaded

const buttonHandlers: InteractionHandlers<Discord.ButtonInteraction> = {
attendance: attendance.handleAttendanceButton,
polls: polls.handlePollButton,
roleSelection: roleSelection.handleRoleSelectionButton,
};

Expand All @@ -72,18 +72,11 @@ const menuHandlers: InteractionHandlers<Discord.SelectMenuInteraction> = {

const startupChores: Chore[] = [
{
summary: "Schedule attendance polls",
fn: async () =>
await attendance.scheduleAttendancePolls(
client,
prisma,
await prisma.attendancePoll.findMany({
where: {
type: "scheduled",
},
})
),
complete: "All attendance polls scheduled",
summary: "Schedule polls",
fn: async () => {
await polls.scheduleAllScheduledPolls(client, prisma);
},
complete: "All polls scheduled",
},
{
summary: "Send role selection messages",
Expand Down
Loading