Skip to content

Commit a6dc113

Browse files
committed
ran linter
1 parent aa8822a commit a6dc113

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

src/commandDetails/coin/leaderboard.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const getCoinLeaderboardEmbed = async (
2525
// Initialize user's coin balance if they have not already
2626
const userBalance = await getCoinBalanceByUserId(userId);
2727
let previousBalance = -1;
28-
let position = 0;
28+
let position = 0;
2929
let rank = 0;
3030
let offset = 0;
3131
let i = 0;

src/events/messageCreate.ts

+29-28
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ const HEIC_FILE_PATH = 'tmp/img.heic';
3131
const CONVERTED_IMG_PATH = 'tmp/img.jpg';
3232

3333
// Variables and constants associated with the counting game
34-
const coinsPerMessage: number = 0.1; // Number of coins awarded = coinsPerMessage * highest counting number * messages sent by user
35-
const countingAuthorDelay: number = 1; // The minimum number of users that must count for someone to go again
34+
const coinsPerMessage = 0.1; // Number of coins awarded = coinsPerMessage * highest counting number * messages sent by user
35+
const countingAuthorDelay = 1; // The minimum number of users that must count for someone to go again
3636
const previousCountingAuthors: Array<User> = []; // Stores the most recent counters
3737
const authorMessageCounts: Map<User, number> = new Map(); // Stores how many messages each user sent
38-
const coinAwardNumberThreshold: number = 20; // The minimum number that must be reached for coins to be awarded
39-
let currentCountingNumber: number = 1;
38+
const coinAwardNumberThreshold = 20; // The minimum number that must be reached for coins to be awarded
39+
let currentCountingNumber = 1;
4040

4141
/*
4242
* If honeypot is to exist again, then add HONEYPOT_CHANNEL_ID to the config
@@ -215,16 +215,16 @@ const countingGameLogic = async (
215215
client: Client,
216216
message: Message,
217217
): Promise<Message<boolean> | undefined> => {
218-
219218
// Check to see if game should end
220219
let reasonForFailure = '';
221-
if (isNaN(Number(message.content))) { // Message was not a number
220+
if (isNaN(Number(message.content))) {
221+
// Message was not a number
222222
reasonForFailure = `"${message.content}" is not a number!`;
223-
}
224-
else if (previousCountingAuthors.find((author) => author === message.author)) { // Author is still on cooldown
223+
} else if (previousCountingAuthors.find((author) => author === message.author)) {
224+
// Author is still on cooldown
225225
reasonForFailure = `<@${message.author.id}> counted too recently!`;
226-
}
227-
else if (Number(message.content) != currentCountingNumber) { // Wrong number was sent
226+
} else if (Number(message.content) != currentCountingNumber) {
227+
// Wrong number was sent
228228
reasonForFailure = `${message.content} is not the next number! The next number was ${currentCountingNumber}.`;
229229
}
230230

@@ -243,48 +243,49 @@ const countingGameLogic = async (
243243
authorMessageCounts.set(message.author, currentAuthorCount ? currentAuthorCount + 1 : 1);
244244

245245
return;
246-
}
246+
};
247247

248248
const endCountingGame = async (
249249
client: Client,
250250
message: Message,
251-
reasonForFailure: string
251+
reasonForFailure: string,
252252
): Promise<Message<boolean> | undefined> => {
253253
// Builds game over embed
254254
const endGameEmbed = new EmbedBuilder()
255255
.setColor(DEFAULT_EMBED_COLOUR)
256256
.setTitle('Counting Game Over')
257257
.addFields([
258-
{
259-
name: 'Reason for Game Over',
260-
value: reasonForFailure,
261-
},
262-
]);
258+
{
259+
name: 'Reason for Game Over',
260+
value: reasonForFailure,
261+
},
262+
]);
263263

264264
if (currentCountingNumber < coinAwardNumberThreshold) {
265-
endGameEmbed.setDescription(`Coins will not be awarded because the threshold, ${coinAwardNumberThreshold}, was not reached.`);
266-
}
267-
else
268-
{
269-
const sortedAuthorMessageCounts: Array<[User, number]> = Array.from(authorMessageCounts).sort((a, b) => b[1] - a[1]); // Turns map into descending sorted array
270-
const coinsAwarded: Array<string> = ['**Coins awarded:**'];
271-
for (let pair of sortedAuthorMessageCounts) {
265+
endGameEmbed.setDescription(
266+
`Coins will not be awarded because the threshold, ${coinAwardNumberThreshold}, was not reached.`,
267+
);
268+
} else {
269+
const sortedAuthorMessageCounts: Array<[User, number]> = Array.from(authorMessageCounts).sort(
270+
(a, b) => b[1] - a[1],
271+
); // Turns map into descending sorted array
272+
const coinsAwarded: Array<string> = ['**Coins awarded:**'];
273+
for (const pair of sortedAuthorMessageCounts) {
272274
pair[1] *= coinsPerMessage * currentCountingNumber; // Changes number of messages sent to number of coins awarded
273275
coinsAwarded.push(`<@${pair[0].id}> - ${pair[1]} ${getCoinEmoji()}`);
274276
await adjustCoinBalanceByUserId(message.author.id, pair[1], UserCoinEvent.Counting);
275277
}
276-
278+
277279
endGameEmbed.setDescription(coinsAwarded.join('\n'));
278280
}
279281

280282
currentCountingNumber = 1;
281283
message.react('❌');
282284
previousCountingAuthors.length = 0;
283285
authorMessageCounts.clear();
284-
285-
return await message.channel?.send({embeds: [endGameEmbed]});
286-
};
287286

287+
return await message.channel?.send({ embeds: [endGameEmbed] });
288+
};
288289

289290
export const initMessageCreate = async (
290291
client: Client,

0 commit comments

Comments
 (0)