Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryan9190 authored Aug 28, 2024
1 parent 20d3ebb commit ce4fb32
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import { App } from '@slack/bolt';
import { PrismaClient } from '@prisma/client';
import dotenv from 'dotenv';
dotenv.config();
import { sendItemList } from './sendUpdate';
import './scheduler'; // Importing scheduler to ensure it runs

const prisma = new PrismaClient();
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
appToken: process.env.SLACK_APP_TOKEN
});

import { handleFarmshopCommand } from './commands/farmshop';
import { showBuyModal, handleBuyModalSubmit } from './genstoreBuy';
app.event('app_mention', async ({ event, say }) => {
await sendItemList();
});

app.action(/buy_.*/, async ({ action, ack, say }) => {
await ack();
const itemTag = action.action_id.replace('buy_', '');
await say(`You bought a ${itemTag.replace('-', '')}`);
});

app.command('/farmshop', handleFarmshopCommand(prisma));
app.view('buy_modal', handleBuyModalSubmit(prisma));
app.action(/sell_.*/, async ({ action, ack, say }) => {
await ack();
const itemTag = action.action_id.replace('sell_', '');
await say(`You sold a ${itemTag.replace('-', '')}`);
});

(async () => {
await app.start(process.env.PORT || 3000);
console.log('⚡️ Farm Shop Bot is running!');
console.log('⚡️ Farm Store Bot is running!');
})();

0 comments on commit ce4fb32

Please sign in to comment.