Skip to content

Commit e4ebaa9

Browse files
committed
Merge
1 parent 389fea5 commit e4ebaa9

File tree

13 files changed

+5310
-4990
lines changed

13 files changed

+5310
-4990
lines changed

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,37 @@
2323
"author": "",
2424
"license": "ISC",
2525
"dependencies": {
26-
"@mdn/browser-compat-data": "4.1.2",
26+
"@mdn/browser-compat-data": "4.1.3",
2727
"@sentry/node": "6.16.1",
2828
"compare-versions": "4.1.2",
29-
"date-fns": "2.27.0",
3029
"discord.js": "13.4.0",
30+
"date-fns": "2.28.0",
3131
"dom-parser": "0.1.6",
3232
"domyno": "1.0.1",
3333
"fuse.js": "6.5.0",
3434
"html-entities": "2.3.2",
3535
"lodash-es": "4.17.21",
36-
"mongoose": "6.1.3",
36+
"mongoose": "6.1.5",
3737
"node-cache": "5.1.2",
3838
"node-fetch": "3.1.0",
39-
"node-html-parser": "5.1.0",
39+
"node-html-parser": "5.2.0",
4040
"ts-node": "10.4.0",
4141
"typescript": "4.5.4"
4242
},
4343
"devDependencies": {
4444
"@sentry/types": "6.16.1",
4545
"@types/dom-parser": "0.1.1",
4646
"@types/html-entities": "1.3.4",
47-
"@types/jest": "27.0.3",
47+
"@types/jest": "27.4.0",
4848
"@types/mongoose": "5.11.97",
49-
"@types/node": "16.11.17",
49+
"@types/node": "16.11.19",
5050
"@types/node-fetch": "3.0.3",
5151
"dotenv": "10.0.0",
52-
"eslint": "8.5.0",
53-
"eslint-config-galex": "3.5.2",
52+
"eslint": "8.6.0",
53+
"eslint-config-galex": "3.5.5",
5454
"husky": "7.0.4",
5555
"jest": "27.4.5",
56-
"lint-staged": "12.1.3",
56+
"lint-staged": "12.1.6",
5757
"nodemon": "2.0.15",
5858
"prettier": "2.5.1",
5959
"ts-jest": "27.1.2"

src/v2/autorespond/thanks/createResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export function createResponse(thankedUsers: Collection<string, User>, authorId:
2424
const output = createEmbed({
2525
description,
2626
fields,
27-
footerText: 'Point Handler',
28-
provider: 'spam',
27+
footerText: 'Thank a helpful member by replying "thanks @username" or saying "thanks" in a reply or thread.',
28+
provider: 'helper',
2929
title,
3030
}).embed;
3131

src/v2/cache/cacheFns.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
12
import { GenericCache } from './model.js';
23

34
export type CacheUpsertOptions = {
45
guild: string;
56
type: string;
6-
expiresIn: number;
77
user: string;
88
meta?: unknown;
9-
};
9+
} & (
10+
| {
11+
expiresIn: number;
12+
}
13+
| { expiresAt: number }
14+
);
1015

1116
export type CacheFindOptions = {
1217
type: string;
@@ -24,14 +29,13 @@ export async function get({ type, user, guild }: CacheFindOptions) {
2429
});
2530
}
2631

27-
export async function upsert({
28-
expiresIn,
29-
guild,
30-
type,
31-
user,
32-
meta,
33-
}: CacheUpsertOptions) {
34-
const expireTime = Date.now() + expiresIn;
32+
export async function upsert(options: CacheUpsertOptions) {
33+
const { guild, type, user, meta } = options;
34+
35+
// Cannot use destructuring due to the properties being optional and TS not liking it
36+
// eslint-disable-next-line unicorn/consistent-destructuring
37+
const expireTime = "expiresAt" in options ? options.expiresAt : Date.now() + options.expiresIn;
38+
3539
const result = await GenericCache.findOneAndUpdate(
3640
{
3741
guild,

src/v2/cache/model.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const schema = new Schema({
2626
},
2727
});
2828

29-
export const GenericCache = model('GenericCache', schema) as unknown as Model<
30-
Document & {
31-
guild: string;
32-
type: string;
33-
timestamp: number;
34-
usre: string;
35-
meta?: unknown;
36-
}
37-
>;
29+
export const GenericCache = model<GenericCacheType>('GenericCache', schema)
30+
31+
type GenericCacheType = {
32+
guild: string;
33+
type: string;
34+
timestamp: number;
35+
user: string;
36+
meta?: unknown;
37+
}

src/v2/commands/points/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function handlePoints(
130130
}
131131

132132
const handleDecayRequest = async (interaction: CommandInteraction) => {
133-
const { diff } = getTimeDiffToDecay();
133+
const { diff } = await getTimeDiffToDecay();
134134
const timer = Number.parseInt(POINT_DECAY_TIMER);
135135

136136
let [hours, minutes]: (string | number)[] = (timer - diff)

src/v2/commands/post/index.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
import type {
33
Message,
44
CollectorFilter,
@@ -211,6 +211,7 @@ const createJobPost = async (
211211
// const url = generateURL(guild.id, channelID, msgID);
212212
try {
213213
const msg = await targetChannel.send({
214+
content: `Job Poster: <@${userID}>`,
214215
embeds: [
215216
createEmbed({
216217
author: {
@@ -219,11 +220,6 @@ const createJobPost = async (
219220
description: `A user has created a new job post!`,
220221
// Using the spam provider because we only need the color/icon, which it provides anyway
221222
fields: [
222-
{
223-
inline: true,
224-
name: 'User',
225-
value: `<@!${userID}>`,
226-
},
227223
{
228224
inline: true,
229225
name: 'Created On',
@@ -245,7 +241,7 @@ const createJobPost = async (
245241
new MessageButton()
246242
.setCustomId(`job🤔${userID}🤔response`)
247243
.setStyle('PRIMARY')
248-
.setLabel('DM me the username')
244+
.setLabel('DM me the posting')
249245
.setEmoji('✉️'),
250246
new MessageButton()
251247
.setCustomId(`job🤔${userID}🤔delete`)
@@ -286,10 +282,10 @@ const handleJobPostingRequest = async (
286282

287283
const filter: CollectorFilter<[Message]> = m => m.author.id === id;
288284
const send = (str: string) => author.send(str);
285+
// Generate cache entry
286+
const entry = generateCacheEntry(id);
289287

290288
try {
291-
// Generate cache entry
292-
const entry = generateCacheEntry(id);
293289
// Check if the user has been cached
294290
const isCached = cache.get(entry.key);
295291

@@ -317,8 +313,6 @@ const handleJobPostingRequest = async (
317313
// Notify the user regarding the rules, and get the channel
318314
const channel = await author.createDM();
319315

320-
const { id: channelID } = channel;
321-
322316
const form = new MultistepForm(questions, channel, author);
323317

324318
const answers = (await form.getResult('guidelines')) as unknown as Answers;
@@ -342,9 +336,13 @@ const handleJobPostingRequest = async (
342336
// Store the job post in the cache
343337
cache.set(entry.key, entry.value, POST_LIMITER);
344338
} catch (error) {
339+
cache.del(entry.key)
340+
345341
interaction.reply(
346342
'Please temporarily enable direct messages as the bot cares about your privacy.'
347343
);
344+
345+
348346
// eslint-disable-next-line no-console
349347
console.error('post.handleJobPostingRequest', error);
350348
}

0 commit comments

Comments
 (0)