Argument of type '"Staff"' is not assignable to parameter of type 'SimplePreconditionKeys | Simpl...

Error
Error when loading 'C:\Users\User\Desktop\Bots and stuff\Gir-Unit V2\src\preconditions\ServerOwner.ts': src/lib/structures/commands/GirCommand.ts:95:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Trainee"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

95 container.append('Trainee');
~~~~~~~~~

src/lib/structures/commands/GirCommand.ts:98:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Staff"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

98 container.append('Staff');

Error when loading 'C:\Users\User\Desktop\Bots and stuff\Gir-Unit V2\src\preconditions\Staff.ts': src/lib/structures/commands/GirCommand.ts:95:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Trainee"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

95 container.append('Trainee');
Error when loading 'C:\Users\User\Desktop\Bots and stuff\Gir-Unit V2\src\preconditions\ServerOwner.ts': src/lib/structures/commands/GirCommand.ts:95:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Trainee"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

95 container.append('Trainee');
~~~~~~~~~

src/lib/structures/commands/GirCommand.ts:98:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Staff"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

98 container.append('Staff');

Error when loading 'C:\Users\User\Desktop\Bots and stuff\Gir-Unit V2\src\preconditions\Staff.ts': src/lib/structures/commands/GirCommand.ts:95:26 - error TS2769: No overload matches this call.
Overload 1 of 2, '(keyOrEntries: SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray): PreconditionContainerArray', gave the following error.
Argument of type '"Trainee"' is not assignable to parameter of type 'SimplePreconditionKeys | SimplePreconditionSingleResolvableDetails | PreconditionContainerArray'.
Overload 2 of 2, '(entry: PreconditionSingleResolvableDetails<keyof Preconditions>): PreconditionContainerArray', gave the following error.
Argument of type 'string' is not assignable to parameter of type 'PreconditionSingleResolvableDetails<keyof Preconditions>'.

95 container.append('Trainee');
14 Replies
Oreo ™
Oreo ™15mo ago
preconditions/Staff.ts
import { PermissionsPrecondition } from '#lib/structures';
import type { GuildMessage } from '#lib/types';
import { isAdmin, isModerator, isStaff } from '#lib/utility';

export class UserPermissionsPrecondition extends PermissionsPrecondition {
public override async handle(
message: GuildMessage
): PermissionsPrecondition.AsyncResult {
const staffRoles = (await message.guild.settings?.staffroles.staffs) ?? [];
const modRoles = (await message.guild.settings?.staffroles.mods) ?? [];
const adminRoles = (await message.guild.settings?.staffroles.admins) ?? [];
const allowed =
isAdmin(message.member) ||
isModerator(message.member) ||
isStaff(message.member) ||
message.member.roles.cache.some((r) =>
adminRoles.concat(modRoles).concat(staffRoles).includes(r.id)
);

return allowed
? this.ok()
: this.error({
identifier: `Not a staff`,
message: `This command is only for staffs`,
});
}
}

declare module '@sapphire/framework' {
interface Preconditions {
Staff: never;
}
}
import { PermissionsPrecondition } from '#lib/structures';
import type { GuildMessage } from '#lib/types';
import { isAdmin, isModerator, isStaff } from '#lib/utility';

export class UserPermissionsPrecondition extends PermissionsPrecondition {
public override async handle(
message: GuildMessage
): PermissionsPrecondition.AsyncResult {
const staffRoles = (await message.guild.settings?.staffroles.staffs) ?? [];
const modRoles = (await message.guild.settings?.staffroles.mods) ?? [];
const adminRoles = (await message.guild.settings?.staffroles.admins) ?? [];
const allowed =
isAdmin(message.member) ||
isModerator(message.member) ||
isStaff(message.member) ||
message.member.roles.cache.some((r) =>
adminRoles.concat(modRoles).concat(staffRoles).includes(r.id)
);

return allowed
? this.ok()
: this.error({
identifier: `Not a staff`,
message: `This command is only for staffs`,
});
}
}

declare module '@sapphire/framework' {
interface Preconditions {
Staff: never;
}
}
Trainee is pretty much the same I have no idea why the error is popping up I think its the same error as https://discord.com/channels/737141877803057244/737142503043498015/897088844275544104
Favna
Favna15mo ago
do you happen to be using pnpm or yarn v2/3 with PnP mode by any chance?
Oreo ™
Oreo ™15mo ago
nope im using npm v8.5.1
Favna
Favna15mo ago
hold on where is this container.append stuff? because that's not how you define preconditions for a command
Favna
Favna15mo ago
Sapphire Framework
Creating your own preconditions | Sapphire
Just as we did in Creating Commands, we will start by creating a preconditions subdirectory in
Favna
Favna15mo ago
I have a hunch that you're copying @Skyra's design here and I can already tell you that just because @Skyra does it, doesn't mean it's good design. You're far better off just sticking to what Sapphire would normally ask you to do in structure. that said, if you do insist on copying the design then copy better. You cannot try to copy only half of the things and expect it to work. For example you have to consider what Skyra actually exactly does Yes there are appends here: https://github.com/skyra-project/skyra/blob/main/src/lib/structures/commands/SkyraCommand.ts#L44-L76 But also consider how it creates the container And consider how augments are done: https://github.com/skyra-project/skyra/blob/main/src/lib/types/Augments.d.ts#L83-L89 And many more alike ---- Also as a side note, think about whether you really need yet another moderation bot. There are already thousands out there and you're not adding anything unique to the bot pool by creating yet another one. You're far better off trying to find some kind of unique niche to fill.
Oreo ™
Oreo ™15mo ago
I had no idea that @Skyra does that, i was copying https://github.com/EvolutionX-10/Radon
Favna
Favna15mo ago
ah well Radon copied it from Skyra
Oreo ™
Oreo ™15mo ago
I realise that now, but i dont see anywhere where augments are done in radon im just curios how radon does it
Favna
Favna15mo ago
no idea
Spinel
Spinel15mo ago
Discord bots that use @sapphire/framework v4 - Official Bot Examples ᴱ ᴰ ᴶˢ - Gemboard ᴱ ᴰ - Dragonite ᴱ ᴰ - Radon ᴱ ᴬ - Sapphire Application Commands Examples ᴱ - Archangel ᴱ ᴰ Discord bots that use @sapphire/framework v3 - Arima ᴱ - Nino ᴱ ᴰ - Operator ᴱ ᴬ ᴰ - Spectera ᴬ Discord bots that use @sapphire/framework v2 - Materia ᴱ - RTByte ᴱ ᴬ - Skyra ᴬ ᴰ - YliasDiscordBot ᴬ : Uses ESM (if not specified then uses CJS) : Advanced bot (if not specified it is a simple bot, or not graded) : Uses Docker in production ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
Favna
Favna15mo ago
@Evo rewrite Radon to have a better precondition system when™️ aaanyyywaaayyy
Oreo ™
Oreo ™15mo ago
anyways, thanks for the support. i think i found out how radon does it. im just tryna see how some bots are made with sapphire so that i can rewrite my old bot in sapphire later. i have no intent to fully copy radon or make yet another moderation bot, my old bot was a stats bot
Favna
Favna15mo ago
I assume it works for @Evo so there, mentioned twice, you can ask him