Skip to content

Commit ddb39d3

Browse files
Add more comments
1 parent f484081 commit ddb39d3

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/bot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { loadCommands, commandHandler } from "./handlers/CommandHandler";
1111
activities: [{ type: "WATCHING", name: "Discord.JS channel" }],
1212
status: "online",
1313
},
14-
// For DMs, now on dms a partial channel is received
14+
// For DMs, a partial channel object is received, in order to receive dms, CHANNEL partials must be activated
1515
partials: ["CHANNEL"],
1616
}),
1717
commands: new Collection(),

src/commands/docs/djs.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const command: Command = {
2525
option
2626
.setName("source")
2727
.setDescription(
28-
"Select which branch/repository to get documentation off of"
28+
"Select which branch/repository to get documentation off of (Default: stable)"
2929
)
3030
.addChoices(supportedBranches)
3131
.setRequired( false )
@@ -43,9 +43,11 @@ const command: Command = {
4343

4444
const notFoundEmbed = doc.baseEmbed();
4545
notFoundEmbed.description = "Didn't find any results for that query";
46+
// If a result wasn't found
4647
if ( !resultEmbed || resultEmbed.description === "" ) {
4748

4849
const timeStampDate = new Date(notFoundEmbed.timestamp);
50+
// Satisfies the method's MessageEmbedOption type
4951
const embedObj = { ...notFoundEmbed, timestamp: timeStampDate };
5052

5153
interaction.editReply({ embeds: [embedObj] }).catch(console.error);
@@ -54,9 +56,11 @@ const command: Command = {
5456

5557
const timeStampDate = new Date(resultEmbed.timestamp);
5658
const embedObj = { ...resultEmbed, timestamp: timeStampDate };
57-
59+
60+
//! "checkEmbedLimits" does not support MessageEmbed objects due to the properties being null by default, use a raw embed object for this method
61+
// Check if the embed exceeds any of the limits
5862
if (!checkEmbedLimits([resultEmbed])) {
59-
// The final fields should be the View Source button
63+
// The final field should be the View Source button
6064
embedObj.fields = [embedObj.fields?.at( -1 )];
6165
}
6266
interaction.editReply({ embeds: [embedObj] }).catch(console.error);

src/handlers/CommandHandler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ export function loadCommands(context: MyContext) {
5656
* @param command
5757
* @returns Whether to cancel the command
5858
*/
59+
// * Note that as of writing, slash commands can override permissions
5960
function commandPermissionCheck(
6061
interaction: CommandInteraction,
6162
command: Command
6263
): boolean {
6364
const { client, user, channel } = interaction;
64-
// If the channel is a dm, if it's a partial, channel.type wouldn't exist
65+
// If the channel is a dm
66+
// if it's a partial, channel.type wouldn't exist
6567
if (channel.type === "DM" || !channel) {
6668
if (command.guildOnly) {
6769
interaction
@@ -128,8 +130,9 @@ function commandCooldownCheck(
128130
}
129131
interaction
130132
.editReply(
133+
//TODO revert to using custom logic to send remaining time as the discord timestamp formatting isn't very descriptive
131134
`Please wait ${Formatters.time(
132-
Date.now() + existingCooldown,
135+
existingCooldown,
133136
"R"
134137
)} before using the command again`
135138
)

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface Command {
2222
| SlashCommandSubcommandsOnlyBuilder
2323
| SlashCommandOptionsType;
2424
cooldown?: number;
25+
// * Note that as of writing, slash commands can override permissions
2526
botPermissions?: PermissionString[];
2627
authorPermissions?: PermissionString[];
2728
guildOnly?: boolean;

0 commit comments

Comments
 (0)