Ping command in the Guide does not work

I tried following the Getting started Guide for Sapphire but it seems like the bot wont register me sending @bot ping in a channel it has access to. I am using Typescript, with the source being in src/ and being built to dist/. My Main property in the package.json is dist/index.js Code should be the exact same. Is there a paste service i can use for samples?
No description
10 Replies
börki
börkiOP7d ago
I had added a info log after the super method to check if the command is being loaded and it seems like the framework can find the file.
import { Command, container } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class PingCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'ping',
aliases: ['pong'],
description: 'ping pong'
});
}

public async messageRun(message: Message) {
if (!message.channel.isSendable()) return;

const msg = await message.channel.send('Ping?');

const content = `Pong from JavaScript! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
msg.createdTimestamp - message.createdTimestamp
}ms.`;

container.logger.info(`Running ping command for ${message.author.tag}`);
return msg.edit(content);


}
}
import { Command, container } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class PingCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'ping',
aliases: ['pong'],
description: 'ping pong'
});
}

public async messageRun(message: Message) {
if (!message.channel.isSendable()) return;

const msg = await message.channel.send('Ping?');

const content = `Pong from JavaScript! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
msg.createdTimestamp - message.createdTimestamp
}ms.`;

container.logger.info(`Running ping command for ${message.author.tag}`);
return msg.edit(content);


}
}
beetle
beetle6d ago
so you're saying that the container.logger.info(...) line is executed but the rest isn't?
börki
börkiOP6d ago
No, messageRun is not ran at all. I meant something like this
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'ping',
aliases: ['pong'],
description: 'ping pong'
});
container.logger.info(`Module ${this.name} loaded`)
}
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'ping',
aliases: ['pong'],
description: 'ping pong'
});
container.logger.info(`Module ${this.name} loaded`)
}
I just had removed it So the constructor is being called -> the file is found and registered by the framework
beetle
beetle6d ago
can you try putting that above everything else inside your messageRun and see if it executes? keep it inside that method but still above all the other code in it
börki
börkiOP6d ago
I had the logger infront of the if statement, nothing I had a debugger breakpoint on the if statement and even that did not trigger
beetle
beetle6d ago
can i see where you define your SapphireClient?
börki
börkiOP6d ago
Sure, give me a second
börki
börkiOP6d ago
This is the folder structure the client is defined in index.ts
No description
börki
börkiOP6d ago
No description
börki
börkiOP6d ago
this is my tsconfig so you know the compilationmapping
No description

Did you find this page helpful?