Skip to content

Commit 54afd99

Browse files
committed
biome & knip: format + lint + knip
1 parent da81a8a commit 54afd99

File tree

9 files changed

+74
-57
lines changed

9 files changed

+74
-57
lines changed

.changeset/config.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3-
"changelog": "@changesets/cli/changelog",
4-
"commit": false,
5-
"fixed": [],
6-
"linked": [],
7-
"access": "restricted",
8-
"baseBranch": "master",
9-
"updateInternalDependencies": "patch",
10-
"ignore": []
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "master",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
1111
}
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { Command } from "@djs-core/runtime";
22
export default new Command()
33
.setDescription("Ping the bot")
4-
.addStringOption(option => option.setName("type").setDescription("The type of log to export").setRequired(true).addChoices(
5-
{ name: "All", value: "all" },
6-
{ name: "User", value: "user" },
7-
{ name: "Server", value: "server" }
8-
))
4+
.addStringOption((option) =>
5+
option
6+
.setName("type")
7+
.setDescription("The type of log to export")
8+
.setRequired(true)
9+
.addChoices(
10+
{ name: "All", value: "all" },
11+
{ name: "User", value: "user" },
12+
{ name: "Server", value: "server" },
13+
),
14+
)
915
.run(async (interaction) => {
1016
await interaction.reply("Pong!");
1117
});
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import { Command } from "@djs-core/runtime";
22

33
export default new Command()
4-
.setDescription("Autocomplete command")
5-
.addStringOption(option => option.setName("type").setDescription("The type of log to export").setRequired(true).setAutocomplete(true))
6-
.run(async (interaction) => {
7-
await interaction.reply("Autocomplete command");
8-
})
9-
.runAutocomplete(async (interaction) => {
10-
return interaction.respond([{
11-
name: new Date().toISOString(),
12-
value: "now",
13-
}]);
14-
});
4+
.setDescription("Autocomplete command")
5+
.addStringOption((option) =>
6+
option
7+
.setName("type")
8+
.setDescription("The type of log to export")
9+
.setRequired(true)
10+
.setAutocomplete(true),
11+
)
12+
.run(async (interaction) => {
13+
await interaction.reply("Autocomplete command");
14+
})
15+
.runAutocomplete(async (interaction) => {
16+
return interaction.respond([
17+
{
18+
name: new Date().toISOString(),
19+
value: "now",
20+
},
21+
]);
22+
});

app/src/interactions/commands/options.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ import { MessageFlags } from "discord.js";
33

44
export default new Command()
55
.setDescription("A command with options ! 🔥")
6-
.addStringOption(option => option.setName("options").setDescription("The fabulous options").setRequired(true))
6+
.addStringOption((option) =>
7+
option
8+
.setName("options")
9+
.setDescription("The fabulous options")
10+
.setRequired(true),
11+
)
712
.run(async (interaction) => {
813
const options = interaction.options.getString("options");
9-
return interaction.reply({ content: `You chose ${options}!`, flags: [MessageFlags.Ephemeral] });
10-
});
14+
return interaction.reply({
15+
content: `You chose ${options}!`,
16+
flags: [MessageFlags.Ephemeral],
17+
});
18+
});

packages/runtime/handler/CommandHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class CommandHandler {
5656
this.assertReady();
5757

5858
this.router = this.router.filter((r) => r.route !== routeKey);
59-
59+
6060
if (!skipSync) {
6161
const root = this.getRoot(routeKey);
6262
await this.upsertRootEverywhere(root);
@@ -369,7 +369,9 @@ export default class CommandHandler {
369369
return root;
370370
}
371371

372-
private buildAutocompleteRouteKey(interaction: AutocompleteInteraction): string {
372+
private buildAutocompleteRouteKey(
373+
interaction: AutocompleteInteraction,
374+
): string {
373375
const root = interaction.commandName;
374376
const group = interaction.options.getSubcommandGroup(false);
375377
const sub = interaction.options.getSubcommand(false);

packages/runtime/interaction/Button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { randomBytes } from "crypto";
22
import { ButtonBuilder, type ButtonInteraction } from "discord.js";
3-
import { getButtonData, storeButtonData } from "../store/ButtonDataStore";
3+
import { getButtonData, storeButtonData } from "../store/DataStore";
44

55
export type ButtonRunFn<T = undefined> = (
66
interaction: ButtonInteraction,

packages/runtime/interaction/Command.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import {
22
type AutocompleteInteraction,
33
type ChatInputCommandInteraction,
4-
SlashCommandBuilder,
5-
type SlashCommandStringOption,
6-
type SlashCommandIntegerOption,
4+
type SlashCommandAttachmentOption,
75
type SlashCommandBooleanOption,
8-
type SlashCommandUserOption,
6+
SlashCommandBuilder,
97
type SlashCommandChannelOption,
10-
type SlashCommandRoleOption,
8+
type SlashCommandIntegerOption,
119
type SlashCommandMentionableOption,
1210
type SlashCommandNumberOption,
13-
type SlashCommandAttachmentOption,
11+
type SlashCommandRoleOption,
12+
type SlashCommandStringOption,
13+
type SlashCommandUserOption,
1414
} from "discord.js";
1515

1616
export type CommandRunFn = (
@@ -95,7 +95,9 @@ export default class Command extends SlashCommandBuilder {
9595
override addMentionableOption(
9696
input:
9797
| SlashCommandMentionableOption
98-
| ((option: SlashCommandMentionableOption) => SlashCommandMentionableOption),
98+
| ((
99+
option: SlashCommandMentionableOption,
100+
) => SlashCommandMentionableOption),
99101
): this {
100102
super.addMentionableOption(input);
101103
return this;
@@ -113,7 +115,9 @@ export default class Command extends SlashCommandBuilder {
113115
override addAttachmentOption(
114116
input:
115117
| SlashCommandAttachmentOption
116-
| ((option: SlashCommandAttachmentOption) => SlashCommandAttachmentOption),
118+
| ((
119+
option: SlashCommandAttachmentOption,
120+
) => SlashCommandAttachmentOption),
117121
): this {
118122
super.addAttachmentOption(input);
119123
return this;
@@ -138,7 +142,9 @@ export default class Command extends SlashCommandBuilder {
138142
await this._run(interaction);
139143
}
140144

141-
async executeAutocomplete(interaction: AutocompleteInteraction): Promise<void> {
145+
async executeAutocomplete(
146+
interaction: AutocompleteInteraction,
147+
): Promise<void> {
142148
if (!this._runAutocomplete) {
143149
return;
144150
}

packages/runtime/store/ButtonDataStore.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/runtime/store/DataStore.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function getDatabase(): Database {
7878
return db;
7979
}
8080

81-
export const dataStore = getDatabase();
81+
const dataStore = getDatabase();
8282

8383
export function storeButtonData(
8484
token: string,
@@ -120,7 +120,7 @@ export function getButtonData(token: string): unknown | undefined {
120120
}
121121
}
122122

123-
export function deleteButtonData(token: string): void {
123+
function deleteButtonData(token: string): void {
124124
const db = dataStore;
125125
db.prepare("DELETE FROM button_data WHERE token = ?").run(token);
126126
}
@@ -165,7 +165,7 @@ export function getSelectMenuData(token: string): unknown | undefined {
165165
}
166166
}
167167

168-
export function deleteSelectMenuData(token: string): void {
168+
function deleteSelectMenuData(token: string): void {
169169
const db = dataStore;
170170
db.prepare("DELETE FROM select_menu_data WHERE token = ?").run(token);
171171
}
@@ -210,7 +210,7 @@ export function getModalData(token: string): unknown | undefined {
210210
}
211211
}
212212

213-
export function deleteModalData(token: string): void {
213+
function deleteModalData(token: string): void {
214214
const db = dataStore;
215215
db.prepare("DELETE FROM modal_data WHERE token = ?").run(token);
216216
}

0 commit comments

Comments
 (0)