Skip to content

Commit

Permalink
fix: lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <noreply@github.com>
  • Loading branch information
virtual-designer authored Dec 20, 2024
1 parent 4e67e7e commit b70f8fc
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 43 deletions.
4 changes: 1 addition & 3 deletions src/framework/typescript/arguments/Argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export default abstract class Argument<T = unknown> implements ArgumentInterface
return this;
}


public validate(): Awaitable<boolean> {
return true;
}
Expand Down Expand Up @@ -126,7 +125,6 @@ export default abstract class Argument<T = unknown> implements ArgumentInterface
return this;
}


public postTransformValidation(): Awaitable<boolean> {
return true;
}
Expand All @@ -142,7 +140,7 @@ export default abstract class Argument<T = unknown> implements ArgumentInterface
protected error(
message: string,
type: ErrorType,
ruleLike?: string | { message?: string } | undefined
ruleLike?: string | { message?: string }
): never {
throw new InvalidArgumentError(
(typeof ruleLike === "string" ? ruleLike : ruleLike?.message) ?? message,
Expand Down
4 changes: 0 additions & 4 deletions src/framework/typescript/cache/CacheUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ export const cache = <F extends AnyFunction, I extends boolean = false>(
}) as unknown as F;

if (options?.invoke) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return callback() as ReturnValue<I, F>;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return callback as ReturnValue<I, F>;
};

Expand All @@ -80,11 +78,9 @@ export const memoize = <F extends AnyFunction>(fn: F) => {
return (...args: Parameters<F>): ReturnType<F> => {
const key = args.join("_");
if (cache.has(key)) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return cache.get(key)!;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return fn(...(args as unknown[]));
};
};
1 change: 1 addition & 0 deletions src/framework/typescript/cache/GlobalStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { isDeepStrictEqual } from "util";
import Application from "../app/Application";

declare global {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface FrameworkCacheStore extends Record<string, unknown> {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/framework/typescript/cluster/FeatureFlagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FeatureFlagManager extends HasApplication implements Bootable {
for (const key in flags) {
this.flags.set(key, flags[key].treatment);
}
} catch (error) {
} catch {
this.application.logger.error("Failed to fetch feature flags from the central API");
return;
}
Expand Down
1 change: 0 additions & 1 deletion src/framework/typescript/env/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Environment {
}

public static parseVariables<T extends ZodSchema>(schema: T): z.infer<T> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return schema.parse(this.variables());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Service } from "../services/Service";
import { Permission } from "./Permission";

declare global {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface SystemPermissionStrings {}
}

Expand Down
1 change: 1 addition & 0 deletions src/framework/typescript/services/ServiceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type DiscordKernelClass = {
};

declare global {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ServiceRecord extends Record<string, object> {}
}

Expand Down
1 change: 0 additions & 1 deletion src/framework/typescript/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export function isDevelopmentMode() {
);
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function noOperation(..._args: any[]): void {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/fun/HttpCatCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class HttpCatCommand extends Command {

try {
await axios.get(url);
} catch (error) {
} catch {
await context.error("No cat found for that status code.");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/fun/HttpDogCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class HttpDogCommand extends Command {

try {
await axios.get(url);
} catch (error) {
} catch {
await context.error("No dog found for that status code.");
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/typescript/commands/information/AvatarCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class AvatarCommand extends Command {
member = user
? (context.guild.members.cache.get(user.id) ??
(await context.guild.members.fetch(user.id)))
: (context.member!);
} catch (e) {
: context.member!;
} catch {
return void (await context.error("Failed to fetch member."));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EncourageCommand extends Command {

const [quote] = response.data;
await context.reply(`> ${quote.q.replace(/\n/gi, "\n> ")}\n\n — *${quote.a}*`);
} catch (e) {
} catch {
await context.error(
"The API did not return a valid status code. This is a possible error in the API or you got rate limited."
);
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/moderation/EchoCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class EchoCommand extends Command {

try {
await finalChannel.send(options);
} catch (error) {
} catch {
return void context.error(
"An error occurred while sending the message. Make sure I have the necessary permissions."
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class EditMessageCommand extends Command implements HasEventListe

try {
await message.edit(options);
} catch (error) {
} catch {
await interaction.editReply({
content: "An error has occurred while trying to update the message."
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ class InfractionDurationCommand extends Command {
if (typeof duration === "string" && duration.toLowerCase() !== "none") {
throw new Error();
}
} catch (error) {
} catch {
await context.error("Invalid duration provided.");
return;
}

const { error, infraction, success } = await this.infractionManager.updateDurationById(
context.guildId,
id,
typeof duration === "string" ? null : (duration),
typeof duration === "string" ? null : duration,
!context.isChatInput() || context.options.getBoolean("notify") !== false
);

Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/moderation/SendCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SendCommand extends Command {

try {
await member.send(options);
} catch (error) {
} catch {
return void context.error(
"An error occurred while sending the message to the user. Maybe they have DMs turned off or blocked me?"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class SendReplyCommand
}
});
await interaction.editReply("The reply has been sent.");
} catch (error) {
} catch {
await interaction.editReply("An error has occurred while sending the reply.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/settings/EvalCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class EvalCommand extends Command {
try {
this._prettier = await import("prettier".toString());
this._prettierEstree = await import("prettier/plugins/estree".toString());
} catch (error) {
} catch {
this._prettier = false;
this._prettierEstree = undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/system/BroadcastCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class BroadcastCommand extends Command {
}

success++;
} catch (error) {
} catch {
failed++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/commands/system/ReloadCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ReloadCommand extends Command {

try {
await this.commandManager.reloadCommand(command);
} catch (error) {
} catch {
await context.error(`Failed to reload command \`${name}\`.`);
return;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/typescript/commands/tools/EmbedSendCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
*/

import { Command } from "@framework/commands/Command";
import { PermissionFlags } from "@framework/permissions/PermissionFlag";
import type LegacyContext from "@framework/commands/LegacyContext";
import type InteractionContext from "@framework/commands/InteractionContext";
import type { ChatInputCommandInteraction, GuildBasedChannel } from "discord.js";
import type LegacyContext from "@framework/commands/LegacyContext";
import { PermissionFlags } from "@framework/permissions/PermissionFlag";
import { generateEmbed } from "@main/utils/embed";
import type { ChatInputCommandInteraction, GuildBasedChannel } from "discord.js";

class EmbedSendCommand extends Command {
public override readonly name: string = "embed::send";
Expand Down Expand Up @@ -67,10 +67,10 @@ class EmbedSendCommand extends Command {
});

await context.reply({ content: "Message sent." });
} catch (e) {
} catch {
await context.error({ content: "Invalid options given." });
}
}
}

export default EmbedSendCommand;
export default EmbedSendCommand;
19 changes: 15 additions & 4 deletions src/main/typescript/services/CommandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ class CommandManager extends Service implements CommandManagerServiceInterface {
this.configManager.config[message.guildId]?.commands.respond_on_precondition_fail;

if (command.isDisabled(message.guildId)) {
respondOnFail && (await context.error("This command is disabled."));
if (respondOnFail) {
await context.error("This command is disabled.");
}

return;
}

Expand All @@ -346,7 +349,10 @@ class CommandManager extends Service implements CommandManagerServiceInterface {
const subcommand = this.getCommand(key);

if (subcommand && subcommand.isDisabled(message.guildId)) {
respondOnFail && (await context.error("This command is disabled."));
if (respondOnFail) {
await context.error("This command is disabled.");
}

return;
}

Expand Down Expand Up @@ -449,8 +455,13 @@ class CommandManager extends Service implements CommandManagerServiceInterface {
);

if (command.isDisabled(interaction.guildId!)) {
this.configManager.config[interaction.guildId!]?.commands
.respond_on_precondition_fail && (await context.error("This command is disabled."));
if (
this.configManager.config[interaction.guildId!]?.commands
.respond_on_precondition_fail
) {
await context.error("This command is disabled.");
}

return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/typescript/services/GuildSetupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1807,8 +1807,8 @@ class GuildSetupService extends Service implements HasEventListeners {
!timeframe ||
isNaN(+threshold) ||
isNaN(+timeframe) ||
-(-threshold) <= 0 ||
-(-timeframe) <= 0
-(-threshold) <= 0 || // eslint-disable-line @typescript-eslint/no-unsafe-unary-minus
-(-timeframe) <= 0 // eslint-disable-line @typescript-eslint/no-unsafe-unary-minus
) {
await this.pushState(guildId, id, messageId, {
embeds: [
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/services/InfractionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ class InfractionManager extends Service {
? this.createOverviewEmbed(infraction, member.user, moderator)
: undefined) as E extends true ? APIEmbed : undefined
};
} catch (error) {
} catch {
return {
status: "failed",
infraction: null,
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/services/MessageReportingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class MessageReportingService extends Service {
parsedDuration = duration
? Duration.fromDurationStringExpression(duration)
: undefined;
} catch (error) {
} catch {
await interaction.editReply({ content: "Invalid duration provided." });
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/typescript/services/WelcomerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class WelcomerService extends Service implements HasEventListeners {
).components[0].components[0].customId!;

this.logger.debug("Refetched custom ID: ", interaction.customId);
} catch (e) {
} catch {
semaphore.release();
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/typescript/shell/core/ShellClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ class ShellClient {
}

this.ws.addEventListener("open", () => resolve());
this.ws.addEventListener("error", () => reject());
this.ws.addEventListener("error", error =>
reject(new Error("Failed to connect to shell service", { cause: error }))
);
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/typescript/types/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ export interface ServiceRecord {
guildSetupService: GuildSetupService;
}

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ServiceRecordLocal extends ServiceRecord {}

declare global {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ServiceRecord extends ServiceRecordLocal {}
}
1 change: 1 addition & 0 deletions src/main/typescript/types/global/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { EnvironmentVariableRecord } from "@main/schemas/EnvironmentVariabl

declare global {
namespace NodeJS {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface ProcessEnv extends EnvironmentVariableRecord {}
}
}
11 changes: 9 additions & 2 deletions src/main/typescript/utils/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
* along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
*/

import type { Channel, ChatInputCommandInteraction, ColorResolvable, Guild, Message, User } from "discord.js";
import type {
Channel,
ChatInputCommandInteraction,
ColorResolvable,
Guild,
Message,
User
} from "discord.js";
import { ChannelType, EmbedBuilder, resolveColor } from "discord.js";

export function generateEmbed(options: ChatInputCommandInteraction["options"]) {
Expand All @@ -43,7 +50,7 @@ export function generateEmbed(options: ChatInputCommandInteraction["options"]) {
) {
throw new Error();
}
} catch (e) {
} catch {
return { error: "Invalid color given." };
}

Expand Down
1 change: 0 additions & 1 deletion src/main/typescript/utils/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function emoji(application: Application, name: string) {
export function findEmoji(
application: Application,
name: string
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
): GuildEmoji | ApplicationEmoji | undefined {
const strategy =
env.EMOJI_RESOLVE_STRATEGY ??
Expand Down
1 change: 0 additions & 1 deletion src/main/typescript/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export function safeMessageContent(
);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function assertUnreachable(_value: never): never {
throw new Error("This statement should be unreachable");
}
Expand Down

0 comments on commit b70f8fc

Please sign in to comment.