chore: format
This commit is contained in:
@@ -9,15 +9,15 @@ export const initAccounts = async (): Promise<void> => {
|
||||
};
|
||||
|
||||
export const getAccountBalance = async (playerId: string): Promise<number> => {
|
||||
console.log("getAccountBalance")
|
||||
console.log("getAccountBalance");
|
||||
const accounts: Record<string, number> = await Accounts.json();
|
||||
console.log("getAccountBalance :: next")
|
||||
console.log("getAccountBalance :: next");
|
||||
if (accounts[playerId]) return accounts[playerId];
|
||||
|
||||
accounts[playerId] = 0;
|
||||
console.log("getAccountBalance :: next")
|
||||
console.log("getAccountBalance :: next");
|
||||
await Accounts.write(JSON.stringify(accounts));
|
||||
console.log("getAccountBalance :: next")
|
||||
console.log("getAccountBalance :: next");
|
||||
|
||||
return 0;
|
||||
};
|
||||
@@ -26,11 +26,11 @@ export const setAccountBalance = async (
|
||||
playerId: string,
|
||||
balance: number,
|
||||
): Promise<void> => {
|
||||
console.log("setAccountBalance")
|
||||
console.log("setAccountBalance");
|
||||
const accounts: Record<string, number> = await Accounts.json();
|
||||
console.log("setAccountBalance :: next")
|
||||
console.log("setAccountBalance :: next");
|
||||
accounts[playerId] = balance;
|
||||
|
||||
await Accounts.write(JSON.stringify(accounts));
|
||||
console.log("setAccountBalance :: next")
|
||||
console.log("setAccountBalance :: next");
|
||||
};
|
||||
|
||||
12
src/index.ts
12
src/index.ts
@@ -112,7 +112,10 @@ const askForGrinders = async (quest: QuestResult) => {
|
||||
.split(",")
|
||||
.map((x) => x.trim())
|
||||
.filter(Boolean);
|
||||
const embed = await makeResultEmbed(quest, [...env.QUEST_EXCLUDE, ...exclude]);
|
||||
const embed = await makeResultEmbed(quest, [
|
||||
...env.QUEST_EXCLUDE,
|
||||
...exclude,
|
||||
]);
|
||||
const rewardChannel = await client.channels.fetch(
|
||||
env.DISCORD_REWARDS_CHANNEL,
|
||||
);
|
||||
@@ -181,10 +184,13 @@ client.on("messageCreate", async (message) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const mult = args[1][0] === '+' ? 1 : -1;
|
||||
const mult = args[1][0] === "+" ? 1 : -1;
|
||||
const delta = Number(args[1].substring(1)) * mult;
|
||||
const balance = await getAccountBalance(clanMember.playerId);
|
||||
await setAccountBalance(clanMember.playerId, Math.max(0, balance + delta));
|
||||
await setAccountBalance(
|
||||
clanMember.playerId,
|
||||
Math.max(0, balance + delta),
|
||||
);
|
||||
}
|
||||
|
||||
const balance = await getAccountBalance(clanMember.playerId);
|
||||
|
||||
Reference in New Issue
Block a user