Skip to content

Commit 848a877

Browse files
committed
put interfaces into types.d.ts
1 parent 41dd1cc commit 848a877

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+421
-501
lines changed

.prettierrc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
"bracketSpacing": true,
88
"arrowParens": "always",
99
"quoteProps": "as-needed",
10-
"trailingComma": "none",
11-
"insertPragma": true
10+
"trailingComma": "none"
1211
}

src/commands/banana/banana-donate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { createUser, getUser, setUser } from "../../functions/banana";
55

66
export default {
@@ -58,4 +58,4 @@ export default {
5858
`✅ Successfully donated ${amount} banana(s) to ${targetUser.tag}.`
5959
);
6060
}
61-
} as Command;
61+
} as MonkeyTypes.Command;

src/commands/banana/banana-flip.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
setCoinFlips,
88
setUser
99
} from "../../functions/banana";
10-
import type { Command } from "../../interfaces/command";
10+
import type { MonkeyTypes } from "../../types/types";
1111

1212
export default {
1313
name: "banana-flip",
@@ -184,4 +184,4 @@ export default {
184184
setUser(interaction.user.id, authorBananaEntry);
185185
setUser(client.user.id, botBananaEntry);
186186
}
187-
} as Command;
187+
} as MonkeyTypes.Command;

src/commands/banana/banana-jack.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { createUser, getUser, setUser } from "../../functions/banana";
55
import { MessageActionRow, MessageButton } from "discord.js";
66

@@ -210,7 +210,7 @@ export default {
210210

211211
currentlyPlaying.delete(interaction.user.id);
212212
}
213-
} as Command;
213+
} as MonkeyTypes.Command;
214214

215215
function createDeck(): Card[] {
216216
const deck: Card[] = [];

src/commands/banana/banana-rps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { MessageActionRow, MessageButton } from "discord.js";
44
import { getUser, createUser, setUser } from "../../functions/banana";
5-
import type { Command } from "../../interfaces/command";
5+
import type { MonkeyTypes } from "../../types/types";
66

77
const currentlyPlaying = new Set<string>();
88

@@ -255,4 +255,4 @@ export default {
255255

256256
game(1);
257257
}
258-
} as Command;
258+
} as MonkeyTypes.Command;

src/commands/banana/banana-top.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { getData, getUser } from "../../functions/banana";
55

66
export default {
@@ -61,4 +61,4 @@ export default {
6161
embeds: [embed]
6262
});
6363
}
64-
} as Command;
64+
} as MonkeyTypes.Command;

src/commands/banana/banana.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { mongoDB } from "../../functions/mongodb";
55
import { createUser, getUser, setUser } from "../../functions/banana";
6-
import { User } from "../../types";
76
import { getNextDay, isSameDay } from "../../functions/date";
87
import formatDistanceStrict from "date-fns/formatDistanceStrict";
98

@@ -20,7 +19,7 @@ export default {
2019

2120
const bananaEntry = getUser(discordID) ?? createUser(discordID);
2221

23-
const snapshot = <User | null>(
22+
const snapshot = <MonkeyTypes.User | null>(
2423
await db.collection("users").findOne({ discordId: discordID })
2524
);
2625

@@ -93,4 +92,4 @@ export default {
9392

9493
interaction.followUp({ embeds: [embed] });
9594
}
96-
} as Command;
95+
} as MonkeyTypes.Command;

src/commands/dev/challenge-requests-stats.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { getStats } from "../../dal/challenge-request-stats";
55
import { MessageEmbedOptions } from "discord.js";
66
import formatDistanceToNow from "date-fns/formatDistanceToNow";
@@ -76,4 +76,4 @@ export default {
7676
ephemeral: true
7777
});
7878
}
79-
} as Command;
79+
} as MonkeyTypes.Command;

src/commands/dev/fix-wpm-role.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { mongoDB } from "../../functions/mongodb";
5-
import { User } from "../../types";
65

76
export default {
87
name: "fix-wpm-role",
@@ -32,7 +31,7 @@ export default {
3231

3332
const db = mongoDB();
3433

35-
const dbUser = <User | null>(
34+
const dbUser = <MonkeyTypes.User | null>(
3635
await db.collection("users").findOne({ discordId: user.id })
3736
);
3837

@@ -88,4 +87,4 @@ export default {
8887

8988
return;
9089
}
91-
} as Command;
90+
} as MonkeyTypes.Command;

src/commands/dev/reset-config.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { mongoDB } from "../../functions/mongodb";
55
import { DefaultConfig } from "../../constants/default-config";
6-
import { User } from "../../types";
76

87
export default {
98
name: "reset-config",
@@ -28,7 +27,7 @@ export default {
2827

2928
const db = mongoDB();
3029

31-
const user = <User | null>(
30+
const user = <MonkeyTypes.User | null>(
3231
await db.collection("users").findOne({ discordId: discordUser.id })
3332
);
3433

@@ -64,4 +63,4 @@ export default {
6463
content: "✅ Done!"
6564
});
6665
}
67-
} as Command;
66+
} as MonkeyTypes.Command;

src/commands/dev/restart-db.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { exec } from "child_process";
55
import { MessageActionRow, MessageButton } from "discord.js";
66

@@ -62,4 +62,4 @@ export default {
6262
buttonInteraction.reply("❌ Cancelled");
6363
}
6464
}
65-
} as Command;
65+
} as MonkeyTypes.Command;

src/commands/dev/unlock-commands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @format */
22

33
import { MessageActionRow, MessageButton } from "discord.js";
4-
import type { Command } from "../../interfaces/command";
4+
import type { MonkeyTypes } from "../../types/types";
55
import { Client } from "../../structures/client";
66

77
export default {
@@ -82,4 +82,4 @@ export default {
8282
content: "Commands have been unlocked."
8383
});
8484
}
85-
} as Command;
85+
} as MonkeyTypes.Command;

src/commands/dev/upgrade.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { spawn } from "child_process";
55

66
export default {
@@ -18,4 +18,4 @@ export default {
1818

1919
interaction.reply("🤔 Upgrading...");
2020
}
21-
} as Command;
21+
} as MonkeyTypes.Command;

src/commands/github/issue.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import fetch from "node-fetch-commonjs";
55
import { parseJSON, readFileOrCreate } from "../../functions/file";
66
import { ApplicationCommandOption } from "discord.js";
77

8-
const labels: string[] = parseJSON(readFileOrCreate("labels.json", "[]"));
8+
const labels = parseJSON<string[]>(readFileOrCreate("labels.json", "[]"));
99

1010
const labelOption: ApplicationCommandOption = {
1111
name: "label",
@@ -110,4 +110,4 @@ export default {
110110
interaction.followUp("❌ Could not create issue");
111111
}
112112
}
113-
} as Command;
113+
} as MonkeyTypes.Command;

src/commands/github/quote-pr.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import SimpleGit from "simple-git";
55
import fetch from "node-fetch";
66

@@ -55,4 +55,4 @@ export default {
5555
});
5656
}
5757
}
58-
} as Command;
58+
} as MonkeyTypes.Command;

src/commands/github/quote-push.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44

55
import SimpleGit from "simple-git";
66

@@ -30,4 +30,4 @@ export default {
3030
content: "✅ Successfully pushed quotes to GitHub"
3131
});
3232
}
33-
} as Command;
33+
} as MonkeyTypes.Command;

src/commands/github/quote-sync.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import SimpleGit from "simple-git";
55

66
export default {
@@ -29,4 +29,4 @@ export default {
2929
content: "✅ Successfully synced quotes from GitHub"
3030
});
3131
}
32-
} as Command;
32+
} as MonkeyTypes.Command;

src/commands/stats/leaderboard.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
4-
import { User, LeaderboardEntry } from "../../types";
3+
import type { MonkeyTypes } from "../../types/types";
54
import { mongoDB } from "../../functions/mongodb";
65

76
export default {
@@ -53,20 +52,20 @@ export default {
5352
const mode = "time"; // interaction.options.getString("mode", true);
5453
const mode2 = interaction.options.getString("mode2", true);
5554

56-
const user = <User | null>(
55+
const user = <MonkeyTypes.User | null>(
5756
await db.collection("users").findOne({ discordId: interaction.user.id })
5857
);
5958

6059
const leaderboardUser =
6160
user !== null
62-
? <LeaderboardEntry>(
61+
? <MonkeyTypes.LeaderboardEntry>(
6362
await db
6463
.collection(`leaderboards.${language}.${mode}.${mode2}`)
6564
.findOne({ uid: user.uid })
6665
)
6766
: null;
6867

69-
const leaderboardArray = <LeaderboardEntry[]>(
68+
const leaderboardArray = <MonkeyTypes.LeaderboardEntry[]>(
7069
await db
7170
.collection(`leaderboards.${language}.${mode}.${mode2}`)
7271
.find()
@@ -148,4 +147,4 @@ export default {
148147

149148
return;
150149
}
151-
} as Command;
150+
} as MonkeyTypes.Command;

src/commands/stats/personal-bests.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { mongoDB } from "../../functions/mongodb";
5-
import { PersonalBest, User } from "../../types";
65
import { EmbedFieldData, MessageEmbed } from "discord.js";
76

87
export default {
@@ -22,7 +21,7 @@ export default {
2221

2322
const discordUser = interaction.options.getUser("user") ?? interaction.user;
2423

25-
const user = <Partial<User> | null>(
24+
const user = <Partial<MonkeyTypes.User> | null>(
2625
await db.collection("users").findOne({ discordId: discordUser.id })
2726
);
2827

@@ -50,8 +49,8 @@ export default {
5049
const sortedTime = pbs.time;
5150
const sortedWords = pbs.words;
5251

53-
const timePB: { [key: number]: PersonalBest } = {};
54-
const wordsPB: { [key: number]: PersonalBest } = {};
52+
const timePB: { [key: number]: MonkeyTypes.PersonalBest } = {};
53+
const wordsPB: { [key: number]: MonkeyTypes.PersonalBest } = {};
5554

5655
Object.entries(sortedTime).forEach(([key, timePBs]) => {
5756
const maxValue = timePBs?.sort((a, b) => b.wpm - a.wpm)[0];
@@ -163,4 +162,4 @@ export default {
163162
) as MessageEmbed[]
164163
});
165164
}
166-
} as Command;
165+
} as MonkeyTypes.Command;

src/commands/stats/result.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/** @format */
22

3-
import type { Command } from "../../interfaces/command";
3+
import type { MonkeyTypes } from "../../types/types";
44
import { mongoDB } from "../../functions/mongodb";
5-
import { User, Result, Mode, QuoteCollection } from "../../types";
65
import { toPascalCase } from "../../functions/to-pascal-case";
76
import fetch from "node-fetch-commonjs";
87

@@ -30,7 +29,7 @@ export default {
3029

3130
const db = mongoDB();
3231

33-
const user = <User | null>(
32+
const user = <MonkeyTypes.User | null>(
3433
await db.collection("users").findOne({ discordId: discordUser.id })
3534
);
3635

@@ -47,7 +46,7 @@ export default {
4746
fetchReply: false
4847
});
4948

50-
const result = <Result<Mode> | undefined>(
49+
const result = <MonkeyTypes.Result<MonkeyTypes.Mode> | undefined>(
5150
(
5251
await db
5352
.collection("results")
@@ -104,7 +103,7 @@ export default {
104103
`https://raw.githubusercontent.com/${client.clientOptions.repo}/master/frontend/static/quotes/${language}.json`
105104
);
106105

107-
const quoteColl = <QuoteCollection>await res.json();
106+
const quoteColl = <MonkeyTypes.QuoteCollection>await res.json();
108107

109108
const quote = quoteColl.quotes.find(
110109
(quote) => +quote.id === +result.mode2
@@ -154,4 +153,4 @@ export default {
154153
embeds: [embed]
155154
});
156155
}
157-
} as Command;
156+
} as MonkeyTypes.Command;

0 commit comments

Comments
 (0)