Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 805b3e9

Browse files
committed
fix: fix some antipatterns
1 parent cdc7707 commit 805b3e9

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

scripts/syncEmojis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async function updateEmojiJson(emojis) {
132132

133133
await Bun.write(jsonFile, JSON.stringify(updatedEmojiSet, null, 2));
134134
newSpinner.stop(
135-
orangeText('ⓘ ') + `Added ${emojis.length} emojis with new emoji IDs to emojis.json file.`,
135+
`${orangeText('ⓘ')} Added ${emojis.length} emoji(s) with new emoji ID(s) to emojis.json file.`,
136136
);
137137
}
138138

scripts/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Spinner {
6060
const text = `${greyText(frame)} ${this.message}`.slice(0, maxTextLength);
6161

6262
// Clear the current line
63-
process.stdout.write('\r\x1B[K' + text);
63+
process.stdout.write(`\r\x1B[K${text}`);
6464

6565
this.lastLineLength = text.length;
6666
this.frameIndex = (this.frameIndex + 1) % this.frames.length;
@@ -73,10 +73,10 @@ export class Spinner {
7373
this.isSpinning = false;
7474

7575
// Clear the spinner line
76-
process.stdout.write('\r' + ' '.repeat(this.lastLineLength) + '\r');
76+
process.stdout.write(`\r${' '.repeat(this.lastLineLength)}\r`);
7777

7878
if (message) {
79-
process.stdout.write(message + '\n');
79+
process.stdout.write(`${message}\n`);
8080
}
8181

8282
process.stdout.write('\x1B[?25h'); // Show cursor

src/commands/Main/connection/edit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export default class ConnectionEditSubcommand extends BaseCommand {
136136

137137
if (fetchedInvite?.guild?.id !== interaction.guildId) {
138138
await interaction.followUp({
139-
content: t('connection.inviteInvalid', locale, {
139+
// FIXME: remove ts
140+
content: t('connection.setInviteError', locale, {
140141
emoji: getEmoji('x_icon', interaction.client),
141142
}),
142143
flags: ['Ephemeral'],

src/events/interactionCreate.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default class InteractionCreate extends BaseEventListener<'interactionCre
111111
const { command } = resolveCommand(interaction);
112112
if (!command) return;
113113

114-
if (!this.validateCommandAccess(command, interaction)) return;
114+
if (command.staffOnly && !checkIfStaff(interaction.user.id)) return;
115115

116116
if (interaction.isAutocomplete()) {
117117
await this.handleAutocomplete(command, interaction);
@@ -121,16 +121,6 @@ export default class InteractionCreate extends BaseEventListener<'interactionCre
121121
await executeCommand(interaction, command);
122122
}
123123

124-
private validateCommandAccess(
125-
command: BaseCommand | undefined,
126-
interaction: Interaction | ContextMenuCommandInteraction,
127-
) {
128-
if (command?.staffOnly && !checkIfStaff(interaction.user.id)) {
129-
return false;
130-
}
131-
return true;
132-
}
133-
134124
private async handleAutocomplete(
135125
command: BaseCommand | undefined,
136126
interaction: AutocompleteInteraction,

src/managers/ConnectionManager.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class ConnectionManager {
5656

5757
// Public methods
5858
async fetchHub() {
59-
return this.hubService.fetchHub(this.hubId);
59+
return await this.hubService.fetchHub(this.hubId);
6060
}
6161

6262
async pause(): Promise<void> {
@@ -117,11 +117,7 @@ export default class ConnectionManager {
117117
where: { id: this.connection.id },
118118
data,
119119
});
120-
await this.updateCache();
121-
}
122-
123-
private async updateCache(): Promise<void> {
124-
cacheHubConnection(this.connection);
120+
await cacheHubConnection(this.connection);
125121
}
126122

127123
private async clearCache(): Promise<void> {

src/managers/HubConnectionsManager.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default class HubConnectionsManager {
7070
}
7171

7272
const connection = await db.connection.create({ data });
73-
await this.cacheConnection(connection);
73+
await cacheHubConnection(connection);
7474
return new ConnectionManager(connection);
7575
}
7676

@@ -85,7 +85,7 @@ export default class HubConnectionsManager {
8585
}
8686

8787
async setConnection(connection: Connection): Promise<ConnectionManager> {
88-
await this.cacheConnection(connection);
88+
await cacheHubConnection(connection);
8989
return new ConnectionManager(connection);
9090
}
9191

@@ -148,10 +148,6 @@ export default class HubConnectionsManager {
148148
Logger.debug(`Cached ${connections.length} connections for hub ${this.hub.id}`);
149149
}
150150

151-
private async cacheConnection(connection: Connection): Promise<void> {
152-
cacheHubConnection(connection);
153-
}
154-
155151
private createManagersFromConnections(connections: Connection[]): ConnectionManager[] {
156152
return connections.map((conn) => new ConnectionManager(conn));
157153
}

0 commit comments

Comments
 (0)