Bejasc
Bejasc
Explore posts from servers
SIASapphire - Imagine a framework
Created by Bejasc on 11/2/2024 in #sapphire-support
Precondition not running
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
5 replies
SIASapphire - Imagine a framework
Created by Bejasc on 11/2/2024 in #sapphire-support
Precondition not running
:Facepalm:
5 replies
SIASapphire - Imagine a framework
Created by Bejasc on 7/25/2024 in #sapphire-support
Event before precondition OR access the command via MessageCommandDenied
I know 🙂 We've spoken a few times about this in the past - I'm supporting both and pushing people towards using slash commands. They're definitely easier as a developer, but my community is built from a platform and a time that just does not get along with them.
8 replies
SIASapphire - Imagine a framework
Created by Bejasc on 7/25/2024 in #sapphire-support
Event before precondition OR access the command via MessageCommandDenied
(More snippets, for context)
const DEFAULT_COMMAND_OPTIONS: IDrpgCommandOptions = {
//others
};

export interface IDrpgCommandOptions extends CommandOptions {
//others
deleteAfterPost?: boolean;
}

export abstract class DrpgCommand extends Command {
public readonly fullCategory: readonly string[] = [];

public constructor(context: Command.LoaderContext, options: IDrpgCommandOptions) {
super(context, { ...DEFAULT_COMMAND_OPTIONS, ...options });
}
}
const DEFAULT_COMMAND_OPTIONS: IDrpgCommandOptions = {
//others
};

export interface IDrpgCommandOptions extends CommandOptions {
//others
deleteAfterPost?: boolean;
}

export abstract class DrpgCommand extends Command {
public readonly fullCategory: readonly string[] = [];

public constructor(context: Command.LoaderContext, options: IDrpgCommandOptions) {
super(context, { ...DEFAULT_COMMAND_OPTIONS, ...options });
}
}
@ApplyOptions<IDrpgCommandOptions>({
name: "test",
preconditions: ["PreconditionGoesHere"],
deleteAfterPost: true,
//others
})
export class TestCommand extends Command {
public async messageRun(message: Message, args: Args): Promise<Message> {
//Do things
}
@ApplyOptions<IDrpgCommandOptions>({
name: "test",
preconditions: ["PreconditionGoesHere"],
deleteAfterPost: true,
//others
})
export class TestCommand extends Command {
public async messageRun(message: Message, args: Args): Promise<Message> {
//Do things
}
8 replies
SIASapphire - Imagine a framework
Created by Bejasc on 7/25/2024 in #sapphire-support
Event before precondition OR access the command via MessageCommandDenied
I think I found it actually, PreMessageCommandRun - though still open to feedback about whether this is the best possible place for it
import { Events, Listener, ListenerOptions, PreMessageCommandRunPayload } from "@sapphire/framework";

import { IDrpgCommandOptions } from "../../lib/structures";

export class MessageCommandAccepted extends Listener<typeof Events.PreMessageCommandRun> {
public constructor(context: Listener.LoaderContext, options?: ListenerOptions) {
super(context, { ...options, event: Events.PreMessageCommandRun });
}

public run(payload: PreMessageCommandRunPayload): void {
const drpgOptions = payload.command?.options as IDrpgCommandOptions;
if (drpgOptions?.deleteAfterPost) payload.message.delete();
}
}
import { Events, Listener, ListenerOptions, PreMessageCommandRunPayload } from "@sapphire/framework";

import { IDrpgCommandOptions } from "../../lib/structures";

export class MessageCommandAccepted extends Listener<typeof Events.PreMessageCommandRun> {
public constructor(context: Listener.LoaderContext, options?: ListenerOptions) {
super(context, { ...options, event: Events.PreMessageCommandRun });
}

public run(payload: PreMessageCommandRunPayload): void {
const drpgOptions = payload.command?.options as IDrpgCommandOptions;
if (drpgOptions?.deleteAfterPost) payload.message.delete();
}
}
8 replies
SIASapphire - Imagine a framework
Created by Bejasc on 7/18/2024 in #sapphire-support
Hide Slash/Context menu commands
thanks 😉
7 replies
SIASapphire - Imagine a framework
Created by Bejasc on 7/18/2024 in #sapphire-support
Hide Slash/Context menu commands
It's workable, but I wonder if the re-registration of the command when it's re-deployed will knock it back out.
7 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
This is my tsconfig, I've been using experimentalDecorators for quite a while, at least 18mo, probably longer (not at pc to check exact)
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
@Boomeravna As mentioned, I already have this enabled
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
Also to add, I've also tried clearing out the dist, node modules, and package lock
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
These errors are only reported when I have the file open that has the decorator error
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
@ApplyOptions<IDrpgCommandOptions>({
name: "NPC Info",
aliases: ["!npcinfo", "!npcstats", "!npci"],
fullCategory: ["Game Master"],
shortDesc: "View NPC Stats",
description: `View the stats of an existing NPC`,
showInHelpMenu: true,
})
export class HookCommand extends DrpgCommand {
public override async registerApplicationCommands(registry: ApplicationCommandRegistry) {
@ApplyOptions<IDrpgCommandOptions>({
name: "NPC Info",
aliases: ["!npcinfo", "!npcstats", "!npci"],
fullCategory: ["Game Master"],
shortDesc: "View NPC Stats",
description: `View the stats of an existing NPC`,
showInHelpMenu: true,
})
export class HookCommand extends DrpgCommand {
public override async registerApplicationCommands(registry: ApplicationCommandRegistry) {
Works without issue, no error reported
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
@ApplyOptions<IDrpgCommandOptions>({
name: "GM Add Control Points",
aliases: ["!control", "!lcp", "!cont"],
shortDesc: "Add Control Points to a Location.",
description: `Add or remove Control Points to a Location for the provided faction .
Use either an Named Size or a number.`,
fullCategory: ["Game Master"],
showInHelpMenu: true,
examples: [
{
title: "Add a 'Medium' amount of Control Points",
description: "Add the pre-configured 'Medium' amount of Control Points, for the Galactic Empire on Bespin.",
command: "!control imperial bespin medium",
},
],
preconditions: ["GmOnly"],
})
export class GMAddControlPointsCommand extends DrpgCommand {
public async messageRun(message: Message, args: Args): Promise<Message> {
@ApplyOptions<IDrpgCommandOptions>({
name: "GM Add Control Points",
aliases: ["!control", "!lcp", "!cont"],
shortDesc: "Add Control Points to a Location.",
description: `Add or remove Control Points to a Location for the provided faction .
Use either an Named Size or a number.`,
fullCategory: ["Game Master"],
showInHelpMenu: true,
examples: [
{
title: "Add a 'Medium' amount of Control Points",
description: "Add the pre-configured 'Medium' amount of Control Points, for the Galactic Empire on Bespin.",
command: "!control imperial bespin medium",
},
],
preconditions: ["GmOnly"],
})
export class GMAddControlPointsCommand extends DrpgCommand {
public async messageRun(message: Message, args: Args): Promise<Message> {
Works without issue, reports the error
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.ts(1238)
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.ts(1238)
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
{
"compilerOptions": {
"module": "commonjs",
"target": "es2022",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"outDir": "dist",
"lib": ["ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.Intl", "ES2015.Symbol", "DOM"],
"sourceMap": true,
"inlineSources": true,
"incremental": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*", "/src/data/**/*.json"],
"exclude": ["node_modules", "GPT Helper"]
}
{
"compilerOptions": {
"module": "commonjs",
"target": "es2022",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"outDir": "dist",
"lib": ["ESNext", "ESNext.Array", "ESNext.AsyncIterable", "ESNext.Intl", "ES2015.Symbol", "DOM"],
"sourceMap": true,
"inlineSources": true,
"incremental": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": ["src/**/*", "/src/data/**/*.json"],
"exclude": ["node_modules", "GPT Helper"]
}
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
No description
14 replies
SIASapphire - Imagine a framework
Created by doqe on 4/8/2024 in #sapphire-support
create a command that has spaces as one arg
No description
14 replies
SIASapphire - Imagine a framework
Created by doqe on 4/8/2024 in #sapphire-support
create a command that has spaces as one arg
You cannot get that from the slash command - it would be returned as To format the description, I often find myself running message commands that look like this
14 replies
SIASapphire - Imagine a framework
Created by doqe on 4/8/2024 in #sapphire-support
create a command that has spaces as one arg
This is the best option, but doesn't work for every case. For example, you can't use newlines or any formatting characters in it. One of my main use cases (and the quotes work totally fine for this) is that you can create a message embed.
"**To format the description**,

I often find myself running message commands _that look like_
- this
"
"**To format the description**,

I often find myself running message commands _that look like_
- this
"
14 replies
SIASapphire - Imagine a framework
Created by Bejasc on 9/29/2023 in #discordjs-support
Authenticated Attachment URLs
Well, this has come into enforcement today and has absolutely wrecked me. URLs are only refreshed for the original message. Any messages that refers to this original image - will not work. Image will be dead.
7 replies
SIASapphire - Imagine a framework
Created by Bejasc on 2/3/2024 in #sapphire-support
Listener run() signature
I'll mark as solved, thanks for the context 👍
12 replies