Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"license": "MIT",
"scripts": {
"clean": "docker-compose down && rimraf postgres-db",
"start": "node_modules/.bin/tsc && nodemon",
"start": "tsc && nodemon",
"format": "prettier-eslint --write \"src/**/*.ts\"",
"build": "node_modules/.bin/tsc --skipLibCheck",
"build": "tsc --skipLibCheck",
"predev": "docker-compose up -d --wait",
"dev": "nodemon",
"test": "jest --watch",
Expand Down
27 changes: 27 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const {
castleDkp2TokenRW,
castleDkpAuctionRaidId,
castleDkpBonusesCharId,
openDkpUsername,
openDkpPassword,
openDkpDomain,
openDkpSiteClientId,
openDkpAuthClientId,
sharedCharactersGoogleSheetId,
publicCharactersGoogleSheetId,
commandSuffix,
Expand Down Expand Up @@ -95,6 +100,28 @@ export const {
* castledkp.vercel.app read/write token
*/
castleDkp2TokenRW?: string;
/*
* castle.opendkp.com username
*/
openDkpUsername?: string;
/*
* castle.opendkp.com password
*/
openDkpPassword?: string;
/*
* castle.opendkp.com subdomain
*/
openDkpDomain?: string;

/*
* castle.opendkp.com site client id
*/
openDkpSiteClientId?: string;

/*
* castle.opendkp.com auth client id
*/
openDkpAuthClientId?: string;

/**
* CastleDKP.com Raid ID for DKP auctions.
Expand Down
9 changes: 9 additions & 0 deletions src/features/auctions/auction-finished-reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "../../shared/action/reaction-action";
import { castledkp } from "../../services/castledkp";
import { some } from "lodash";
import { openDkpService } from "../../services/openDkpService";

const code = "```";
const emojis = ["✅", "🏦"];
Expand Down Expand Up @@ -97,6 +98,14 @@ class AuctionFinishedReactionAction extends ReactionAction {
}

// add item to raid
await openDkpService.addItem(
character.name,
item,
`Auction - ${
this.message.thread?.name || item
} - ${this.message.createdAt.toDateString()}`,
price
);
await castledkp.addItem(Number(castleDkpAuctionRaidId), {
item,
buyer: character.name,
Expand Down
3 changes: 3 additions & 0 deletions src/features/dkp-records/raid-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { CreateRaidResponse, RaidEventData } from "../../services/castledkp";
import { DAYS } from "../../shared/time";
import { code } from "../../shared/util";
import { AdjustmentData, EVERYONE, RaidTick, RaidTickData } from "./raid-tick";
import { openDkpService } from "../../services/openDkpService";

export interface LootData {
item: string;
Expand Down Expand Up @@ -282,6 +283,8 @@ ${p}${code}`,
}
});

openDkpService.createRaid(this.ticks);

return { created, failed };
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { capitalize } from "lodash";
import { castledkp } from "../../../services/castledkp";
import { RaidBonusRequest } from "./raid-bonus-request";
import { openDkpService } from "../../../services/openDkpService";
import moment from "moment";

export class AddAdjustmentBonus extends RaidBonusRequest {
protected async execute(raidId: number) {
const adjustment = await this.validateArgs();
await openDkpService.addAdjustment(adjustment);
await castledkp.addAdjustment(raidId, adjustment);
}

Expand Down
25 changes: 23 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ChannelType, Client, GatewayIntentBits, Partials } from "discord.js";
import { interactionCreateListener } from "./listeners/interaction-create-listener";
import { guildId, token } from "./config";
import {
guildId,
openDkpAuthClientId,
openDkpPassword,
openDkpUsername,
token,
} from "./config";
import { readyListener } from "./listeners/ready-listener";
import { messageReactionAddListener } from "./listeners/message-reaction-add-listener";
import { registerSlashCommands } from "./listeners/register-commands";
Expand All @@ -17,7 +23,9 @@ import { updateRaidReport } from "./features/dkp-records/update/update-raid-repo
import { guildMemberUpdateListener } from "./listeners/guild-member-update-listener";
import "reflect-metadata";
import { PrismaClient } from "@prisma/client";
import { log } from "./shared/logger"
import { log } from "./shared/logger";
import { openDkpService } from "./services/openDkpService";
import { existsSync } from "fs";

// Global
https.globalAgent.maxSockets = 5;
Expand Down Expand Up @@ -96,4 +104,17 @@ redisListener.pSubscribe(redisChannels.raidReportChange(), updateRaidReport);
export const prismaClient = new PrismaClient();
prismaClient.$connect();

if (openDkpUsername && openDkpPassword && openDkpAuthClientId) {
openDkpService
.doUserPasswordAuth(openDkpUsername, openDkpPassword, openDkpAuthClientId)
.then(async () => {
console.log("Authenticated with OpenDKP");
if (existsSync("./players.csv")) {
await openDkpService.importData("./players.csv");
}
})
.catch((reason) => {
console.log("Failed to authenticate with OpenDKP: " + reason);
});
}
log("Listening...");
Loading