Skip to content

Commit 1895003

Browse files
committed
chore: format
1 parent 8bfaab1 commit 1895003

File tree

12 files changed

+27
-82
lines changed

12 files changed

+27
-82
lines changed

packages/jellycommands/src/JellyCommands.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,13 @@ export class JellyCommands extends Client {
2727
if (potentialToken) this.token = cleanToken(potentialToken);
2828

2929
if (this.joptions.commands) {
30-
const commands = await resolveCommands(
31-
this,
32-
this.joptions.commands,
33-
);
30+
const commands = await resolveCommands(this, this.joptions.commands);
3431

3532
const commandIdMap = await getCommandIdMap(this, commands);
3633

3734
// Whenever there is a interactionCreate event respond to it
3835
this.on('interactionCreate', (interaction) => {
39-
this.debug(
40-
`Interaction received: ${interaction.id} | ${interaction.type}`,
41-
);
36+
this.debug(`Interaction received: ${interaction.id} | ${interaction.type}`);
4237

4338
respond({
4439
interaction,
@@ -56,7 +51,6 @@ export class JellyCommands extends Client {
5651
}
5752

5853
debug(message: string) {
59-
if (this.joptions.debug)
60-
console.debug(`\x1b[1m\x1b[35m[DEBUG]\x1b[22m\x1b[39m ${message}`);
54+
if (this.joptions.debug) console.debug(`\x1b[1m\x1b[35m[DEBUG]\x1b[22m\x1b[39m ${message}`);
6155
}
6256
}

packages/jellycommands/src/commands/cache.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ export class CommandIdResolver {
8888
set(commands: CommandIDMap) {
8989
const data: Record<string, string> = {};
9090

91-
for (const [commandId, command] of commands)
92-
data[command.hashId] = commandId;
91+
for (const [commandId, command] of commands) data[command.hashId] = commandId;
9392

9493
this.cache.set<Record<string, string>>(data);
9594
}

packages/jellycommands/src/commands/register.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export const registerCommands = async (
3737
commandsArray.map((c) => c.applicationCommandData),
3838
);
3939

40-
res.forEach((command, i) =>
41-
commandIdMap.set(command.id, commandsArray[i]),
42-
);
40+
res.forEach((command, i) => commandIdMap.set(command.id, commandsArray[i]));
4341
}
4442

4543
return commandIdMap;

packages/jellycommands/src/commands/respond.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export async function respond(data: CommandReponseData): Promise<void> {
1313
const { client, interaction, commandIdMap } = data;
1414

1515
const isCommandOrAutocomplete =
16-
interaction.isCommand() ||
17-
interaction.isContextMenu() ||
18-
interaction.isAutocomplete();
16+
interaction.isCommand() || interaction.isContextMenu() || interaction.isAutocomplete();
1917

2018
if (!isCommandOrAutocomplete) return;
2119

@@ -41,9 +39,7 @@ export async function respond(data: CommandReponseData): Promise<void> {
4139

4240
// If defer, defer
4341
if (options.defer)
44-
await interaction.deferReply(
45-
typeof options.defer == 'object' ? options.defer : {},
46-
);
42+
await interaction.deferReply(typeof options.defer == 'object' ? options.defer : {});
4743

4844
// Run the command
4945
try {

packages/jellycommands/src/events/Event.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ export class Event<T extends keyof ClientEvents> {
1919
options: EventOptions<T>,
2020
) {
2121
if (!name || typeof name != 'string')
22-
throw new TypeError(
23-
`Expected type string for name, received ${typeof name}`,
24-
);
22+
throw new TypeError(`Expected type string for name, received ${typeof name}`);
2523

2624
if (!run || typeof run != 'function')
27-
throw new TypeError(
28-
`Expected type function for run, received ${typeof run}`,
29-
);
25+
throw new TypeError(`Expected type function for run, received ${typeof run}`);
3026

3127
const { error, value } = schema.validate(options);
3228

@@ -40,9 +36,5 @@ export const event = <K extends keyof ClientEvents>(
4036
run: EventCallback<K>;
4137
},
4238
) => {
43-
return new Event<K>(
44-
options.name,
45-
options.run,
46-
removeKeys(options, 'run') as EventOptions<K>,
47-
);
39+
return new Event<K>(options.name, options.run, removeKeys(options, 'run') as EventOptions<K>);
4840
};

packages/jellycommands/src/events/register.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ export const registerEvents = async (
1515
try {
1616
await event.run({ client }, ...ctx);
1717
} catch (error) {
18-
console.error(
19-
`There was an error running event ${event.name}`,
20-
error,
21-
);
18+
console.error(`There was an error running event ${event.name}`, error);
2219
}
2320
};
2421

2522
// Register Event
26-
event.options.once
27-
? client.once(event.name, cb)
28-
: client.on(event.name, cb);
23+
event.options.once ? client.once(event.name, cb) : client.on(event.name, cb);
2924
}
3025
};

packages/jellycommands/src/options.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
import type {
2-
ClientOptions,
3-
InteractionReplyOptions,
4-
MessagePayload,
5-
} from 'discord.js';
1+
import type { ClientOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
62
import { BaseCommand } from './commands/types/BaseCommand.js';
73
import { snowflakeArray } from './utils/joi';
84
import { Event } from './events/Event';
95
import Joi from 'joi';
106

117
export const schema = Joi.object({
12-
commands: [
13-
Joi.string(),
14-
Joi.array().items(Joi.object().instance(BaseCommand), Joi.string()),
15-
],
16-
17-
events: [
18-
Joi.string(),
19-
Joi.array().items(Joi.object().instance(Event), Joi.string()),
20-
],
8+
commands: [Joi.string(), Joi.array().items(Joi.object().instance(BaseCommand), Joi.string())],
9+
10+
events: [Joi.string(), Joi.array().items(Joi.object().instance(Event), Joi.string())],
2111

2212
clientOptions: Joi.object().required(),
2313

packages/jellycommands/src/structures/Cache.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export class Cache {
1717
if (!existsSync(this.cacheDirectory)) mkdirSync(this.cacheDirectory);
1818

1919
// If the cache file doesn't exist, create it
20-
if (!existsSync(this.cacheFile))
21-
writeFileSync(this.cacheFile, '{}', 'utf-8');
20+
if (!existsSync(this.cacheFile)) writeFileSync(this.cacheFile, '{}', 'utf-8');
2221
}
2322

2423
set<T extends Record<any, any>>(object: T) {

packages/jellycommands/src/structures/Props.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,32 @@ export class Props {
22
#props = new Map<string, any>();
33

44
constructor(init?: Record<string, any>) {
5-
for (const [key, value] of Object.entries(init || {}))
6-
this.set(key, value);
5+
for (const [key, value] of Object.entries(init || {})) this.set(key, value);
76
}
87

98
has(key: string): boolean {
109
if (!key || typeof key != 'string')
11-
throw new TypeError(
12-
`Expected key of type string, received ${typeof key}`,
13-
);
10+
throw new TypeError(`Expected key of type string, received ${typeof key}`);
1411

1512
return this.#props.has(key);
1613
}
1714

1815
set<T>(key: string, value: T): void {
1916
if (!key || typeof key != 'string')
20-
throw new TypeError(
21-
`Expected key of type string, received ${typeof key}`,
22-
);
17+
throw new TypeError(`Expected key of type string, received ${typeof key}`);
2318

24-
if (!value)
25-
throw new TypeError(
26-
`Expected to receive a value, received ${typeof value}`,
27-
);
19+
if (!value) throw new TypeError(`Expected to receive a value, received ${typeof value}`);
2820

29-
if (this.has(key))
30-
throw new Error(`Unable to overwrite the readonly prop: ${key}`);
21+
if (this.has(key)) throw new Error(`Unable to overwrite the readonly prop: ${key}`);
3122

3223
this.#props.set(key, value);
3324
}
3425

3526
get<T>(key: string): T {
3627
if (!key || typeof key != 'string')
37-
throw new TypeError(
38-
`Expected key of type string, received ${typeof key}`,
39-
);
28+
throw new TypeError(`Expected key of type string, received ${typeof key}`);
4029

41-
if (!this.#props.has(key))
42-
throw new Error(`Unable to find prop: ${key}`);
30+
if (!this.#props.has(key)) throw new Error(`Unable to find prop: ${key}`);
4331

4432
return this.#props.get(key);
4533
}

packages/jellycommands/src/utils/joi.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ import Joi from 'joi';
33
export const snowflake = () => Joi.string().length(18);
44
export const snowflakeArray = () => Joi.array().items(snowflake());
55

6-
export const pathsSchema = () => [
7-
Joi.string(),
8-
Joi.array().items(Joi.string()),
9-
];
6+
export const pathsSchema = () => [Joi.string(), Joi.array().items(Joi.string())];

0 commit comments

Comments
 (0)