Precondition not running

I've taken this from a working template project of mine, but I can't for the life of me figure out where this message is coming from.. it works in the template project, and checking the docs I can't see what I'm missing... I'm missing something stupid right? It's sitting in a preconditions folder, just the same The log message is not my own. 2024-11-02 22:59:01 - [WARN] preconditionUnavailable - The precondition "OwnerOnly" is not available.
import { Command, Precondition, PreconditionResult } from "@sapphire/framework";
import { Message } from "discord.js";
import { DrpgCommandRequest } from "../lib/structures/DrpgCommandRequest";
export class OwnerOnly extends Precondition {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction, command: Command) {
const request = new DrpgCommandRequest(interaction, command);
return this.checkOwner(request);
}

public override async messageRun(message: Message, command: Command) {
const request = new DrpgCommandRequest(message, command);
return this.checkOwner(request);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
return this.ok();
}

private async checkOwner(request: DrpgCommandRequest): Promise<PreconditionResult> {
const isOwner = request.author.user.id == process.env.OWNER;
if (isOwner) return this.ok();
else return this.error({ message: `${request.author} - This command can only be used by <@${process.env.OWNER}>`, identifier: "Invalid Permission" });
}
}

declare module "@sapphire/framework" {
interface Preconditions {
OwnerOnly: never;
}
}
import { Command, Precondition, PreconditionResult } from "@sapphire/framework";
import { Message } from "discord.js";
import { DrpgCommandRequest } from "../lib/structures/DrpgCommandRequest";
export class OwnerOnly extends Precondition {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction, command: Command) {
const request = new DrpgCommandRequest(interaction, command);
return this.checkOwner(request);
}

public override async messageRun(message: Message, command: Command) {
const request = new DrpgCommandRequest(message, command);
return this.checkOwner(request);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public override async contextMenuRun(interaction: Command.ContextMenuCommandInteraction) {
return this.ok();
}

private async checkOwner(request: DrpgCommandRequest): Promise<PreconditionResult> {
const isOwner = request.author.user.id == process.env.OWNER;
if (isOwner) return this.ok();
else return this.error({ message: `${request.author} - This command can only be used by <@${process.env.OWNER}>`, identifier: "Invalid Permission" });
}
}

declare module "@sapphire/framework" {
interface Preconditions {
OwnerOnly: never;
}
}
@ApplyOptions<IDrpgCommandOptions>({
name: "forcelink",
shortDesc: "Link your RSI account for verrification",
preconditions: ["OwnerOnly"],
})
export class VerifyCommand extends DrpgCommand {
public override async registerApplicationCommands(registry: ApplicationCommandRegistry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName("forcelink")

...
@ApplyOptions<IDrpgCommandOptions>({
name: "forcelink",
shortDesc: "Link your RSI account for verrification",
preconditions: ["OwnerOnly"],
})
export class VerifyCommand extends DrpgCommand {
public override async registerApplicationCommands(registry: ApplicationCommandRegistry) {
registry.registerChatInputCommand((builder) =>
builder //
.setName("forcelink")

...
Solution:
```ts declare module "@sapphire/framework" { interface Preconditions { OwnerOnly: never; }...
Jump to solution
2 Replies
Bejasc
BejascOP2mo ago
:Facepalm:
Solution
Bejasc
Bejasc2mo ago
declare module "@sapphire/framework" {
interface Preconditions {
OwnerOnly: never;
}
}
declare module "@sapphire/framework" {
interface Preconditions {
OwnerOnly: never;
}
}
File name has to match this The file the precondition was stored in was not named OwnerOnly it was named OwnerPrecondition. Rename to file OwnerOnly or vice versa - will resolve the issue. Sometimes it's the little things
Want results from more Discord servers?
Add your server