Skip to content

Commit 03ec297

Browse files
committed
chore: use curly braces instead of one line functions
1 parent 4939517 commit 03ec297

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

src/commands/guides/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const guidesCommand = createCommand({
4444
],
4545
},
4646
execute: async (interaction) => {
47-
if (!interaction.isChatInputCommand()) return;
47+
if (!interaction.isChatInputCommand()) {
48+
return;
49+
}
4850
const subject = interaction.options.getString('subject', true);
4951
const user = interaction.options.getUser('user');
5052
if (!subjectChoices.has(subject)) {

src/commands/tips/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ const slashCommand = createCommand({
4242
],
4343
},
4444
execute: async (interaction) => {
45-
if (!interaction.isChatInputCommand()) return;
45+
if (!interaction.isChatInputCommand()) {
46+
return;
47+
}
4648

4749
const subject = interaction.options.getString('subject', true);
4850
const user = interaction.options.getUser('user');
@@ -77,7 +79,9 @@ const contextMenuCommands = Array.from(subjectChoices).map(([key, value]) =>
7779
name: `Tip: ${key}`,
7880
},
7981
execute: async (interaction) => {
80-
if (!interaction.isMessageContextMenuCommand()) return;
82+
if (!interaction.isMessageContextMenuCommand()) {
83+
return;
84+
}
8185
const message = interaction.targetMessage;
8286

8387
await interaction.reply({ content: 'Fetching tip...', flags: MessageFlags.Ephemeral });

src/events/has-var.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export const hasVarEvent = createEvent(
4343
once: false,
4444
},
4545
async (message) => {
46-
if (message.author.bot) return;
47-
48-
if (!canRun()) return;
46+
if (message.author.bot || !canRun()) {
47+
return;
48+
}
4949

5050
const codeBlocks = Array.from(message.content.match(codeBlockRegex) || []);
5151

src/events/just-ask.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ export const justAskEvent = createEvent(
3838
name: Events.MessageCreate,
3939
},
4040
async (message) => {
41-
if (!canRun()) return;
42-
if (message.author.bot) return;
41+
if (!canRun() || message.author.bot) {
42+
return;
43+
}
4344

44-
if (message.content.split(' ').length > 10) return;
45+
// Ignore long messages, likely user provided more context
46+
if (message.content.split(' ').length > 10) {
47+
return;
48+
}
4549

4650
if (isAskingToAsk(message.content)) {
4751
await message.reply({

src/util/fuzzy-search.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
export const levenshtein = (a: string, b: string) => {
22
const dp = Array.from({ length: a.length + 1 }, () => Array(b.length + 1).fill(0));
33

4-
for (let i = 0; i <= a.length; i++) dp[i][0] = i;
5-
for (let j = 0; j <= b.length; j++) dp[0][j] = j;
4+
for (let i = 0; i <= a.length; i++) {
5+
dp[i][0] = i;
6+
}
7+
for (let j = 0; j <= b.length; j++) {
8+
dp[0][j] = j;
9+
}
610

711
for (let i = 1; i <= a.length; i++) {
812
for (let j = 1; j <= b.length; j++) {

src/util/text.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export const clampText = (text: string, maxLength: number): string => {
2-
if (text.length <= maxLength) return text;
2+
if (text.length <= maxLength) {
3+
return text;
4+
}
35
return `${text.slice(0, maxLength - 3)}...`;
46
};

0 commit comments

Comments
 (0)