Mateleo
Mateleo
SIASapphire - Imagine a framework
Created by Mateleo on 12/15/2023 in #sapphire-support
Global precondition error
No description
7 replies
SIASapphire - Imagine a framework
Created by Mateleo on 11/9/2023 in #sapphire-support
props to button
Is it possible to pass props to button ? Like a variable for example
13 replies
SIASapphire - Imagine a framework
Created by Mateleo on 10/29/2023 in #sapphire-support
Global precondition
I'm not able to answer a custom message with global precondition (global.ts) in preconditions folder
//@ts-ignore
import { AllFlowsPrecondition, Piece, Result } from "@sapphire/framework";
import {
GuildMemberRoleManager,
type CacheType,
type ChatInputCommandInteraction,
type ContextMenuCommandInteraction,
} from "discord.js";

export class UserPrecondition extends AllFlowsPrecondition {
public constructor(context: Piece.Context, options: AllFlowsPrecondition.Options) {
super(context, {
...options,
position: 20,
});
}

public override chatInputRun(interaction: ChatInputCommandInteraction) {
return this.chackUserRole(interaction);
}

public override contextMenuRun(interaction: ContextMenuCommandInteraction) {
return this.chackUserRole(interaction);
}

public override messageRun() {
return this.ok();
}

private async checkUserRole(
interaction: ChatInputCommandInteraction<CacheType> | ContextMenuCommandInteraction<CacheType>
) {
const roles = (interaction.member?.roles as GuildMemberRoleManager).cache;
// Role "Member"
if (roles.some((role: { id: string }) => role.id === "1165714233938427944")) {
return this.ok();
} else {
return this.error({ message: 'You must register on the website first!' });
}
}
}
//@ts-ignore
import { AllFlowsPrecondition, Piece, Result } from "@sapphire/framework";
import {
GuildMemberRoleManager,
type CacheType,
type ChatInputCommandInteraction,
type ContextMenuCommandInteraction,
} from "discord.js";

export class UserPrecondition extends AllFlowsPrecondition {
public constructor(context: Piece.Context, options: AllFlowsPrecondition.Options) {
super(context, {
...options,
position: 20,
});
}

public override chatInputRun(interaction: ChatInputCommandInteraction) {
return this.chackUserRole(interaction);
}

public override contextMenuRun(interaction: ContextMenuCommandInteraction) {
return this.chackUserRole(interaction);
}

public override messageRun() {
return this.ok();
}

private async checkUserRole(
interaction: ChatInputCommandInteraction<CacheType> | ContextMenuCommandInteraction<CacheType>
) {
const roles = (interaction.member?.roles as GuildMemberRoleManager).cache;
// Role "Member"
if (roles.some((role: { id: string }) => role.id === "1165714233938427944")) {
return this.ok();
} else {
return this.error({ message: 'You must register on the website first!' });
}
}
}
14 replies
SIASapphire - Imagine a framework
Created by Mateleo on 9/27/2023 in #sapphire-support
Is it possible to dev Offline ?
I will be on a plane for a while, and I would love to know if it's possible to use discord.js API localy
4 replies
SIASapphire - Imagine a framework
Created by Mateleo on 9/6/2023 in #sapphire-support
Issue with pnpm (A type annotation is necessary)
No description
8 replies