Skip to content

Commit

Permalink
Generalize to any kind of polls (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
luishfonseca authored Sep 22, 2021
1 parent 79d2c0c commit cf8d9bc
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 84 deletions.
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

0 comments on commit cf8d9bc

Please sign in to comment.