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> => {
|
export const getAccountBalance = async (playerId: string): Promise<number> => {
|
||||||
console.log("getAccountBalance")
|
console.log("getAccountBalance");
|
||||||
const accounts: Record<string, number> = await Accounts.json();
|
const accounts: Record<string, number> = await Accounts.json();
|
||||||
console.log("getAccountBalance :: next")
|
console.log("getAccountBalance :: next");
|
||||||
if (accounts[playerId]) return accounts[playerId];
|
if (accounts[playerId]) return accounts[playerId];
|
||||||
|
|
||||||
accounts[playerId] = 0;
|
accounts[playerId] = 0;
|
||||||
console.log("getAccountBalance :: next")
|
console.log("getAccountBalance :: next");
|
||||||
await Accounts.write(JSON.stringify(accounts));
|
await Accounts.write(JSON.stringify(accounts));
|
||||||
console.log("getAccountBalance :: next")
|
console.log("getAccountBalance :: next");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
@@ -26,11 +26,11 @@ export const setAccountBalance = async (
|
|||||||
playerId: string,
|
playerId: string,
|
||||||
balance: number,
|
balance: number,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
console.log("setAccountBalance")
|
console.log("setAccountBalance");
|
||||||
const accounts: Record<string, number> = await Accounts.json();
|
const accounts: Record<string, number> = await Accounts.json();
|
||||||
console.log("setAccountBalance :: next")
|
console.log("setAccountBalance :: next");
|
||||||
accounts[playerId] = balance;
|
accounts[playerId] = balance;
|
||||||
|
|
||||||
await Accounts.write(JSON.stringify(accounts));
|
await Accounts.write(JSON.stringify(accounts));
|
||||||
console.log("setAccountBalance :: next")
|
console.log("setAccountBalance :: next");
|
||||||
};
|
};
|
||||||
|
|||||||
14
src/index.ts
14
src/index.ts
@@ -112,7 +112,10 @@ const askForGrinders = async (quest: QuestResult) => {
|
|||||||
.split(",")
|
.split(",")
|
||||||
.map((x) => x.trim())
|
.map((x) => x.trim())
|
||||||
.filter(Boolean);
|
.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(
|
const rewardChannel = await client.channels.fetch(
|
||||||
env.DISCORD_REWARDS_CHANNEL,
|
env.DISCORD_REWARDS_CHANNEL,
|
||||||
);
|
);
|
||||||
@@ -169,7 +172,7 @@ client.on("messageCreate", async (message) => {
|
|||||||
`'${args[0]}' n'est pas dans le clan (la honte). **Attention les majuscules sont importantes**`,
|
`'${args[0]}' n'est pas dans le clan (la honte). **Attention les majuscules sont importantes**`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(args.length === 2) {
|
if (args.length === 2) {
|
||||||
if (
|
if (
|
||||||
(args[1][0] !== "+" && args[1][0] !== "-") ||
|
(args[1][0] !== "+" && args[1][0] !== "-") ||
|
||||||
!args[1] ||
|
!args[1] ||
|
||||||
@@ -181,10 +184,13 @@ client.on("messageCreate", async (message) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mult = args[1][0] === '+' ? 1 : -1;
|
const mult = args[1][0] === "+" ? 1 : -1;
|
||||||
const delta = Number(args[1].substring(1)) * mult;
|
const delta = Number(args[1].substring(1)) * mult;
|
||||||
const balance = await getAccountBalance(clanMember.playerId);
|
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);
|
const balance = await getAccountBalance(clanMember.playerId);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export const checkForNewQuest = async (): Promise<QuestResult | null> => {
|
|||||||
await mkdir(".cache", { recursive: true });
|
await mkdir(".cache", { recursive: true });
|
||||||
if (await cacheFile.exists()) {
|
if (await cacheFile.exists()) {
|
||||||
const cachedQuestId = await cacheFile.text();
|
const cachedQuestId = await cacheFile.text();
|
||||||
if(cachedQuestId === lastId || cachedQuestId === "IGNORE") {
|
if (cachedQuestId === lastId || cachedQuestId === "IGNORE") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user