Absolutely nothing happens with basic text command

I followed the Getting Started and setting up a basic command steps to no avail, I simply see 'took 0ms to initialize' and running '@<the bot> ping' does nothing. main is set to dist/index.js and I'm using TS if that affects anything.
Solution:
- Which version of @sapphire/framework are you using? - What's your file/folder structure? - Did you use the CLI to generate your bot? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts?...
Jump to solution
24 Replies
log(n)
log(n)14mo ago
src/index.ts:
import { SapphireClient } from "@sapphire/framework";
import { GatewayIntentBits } from "discord.js";
import * as dotenv from "dotenv";

dotenv.config();

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});

client.login(process.env.TOKEN);
import { SapphireClient } from "@sapphire/framework";
import { GatewayIntentBits } from "discord.js";
import * as dotenv from "dotenv";

dotenv.config();

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});

client.login(process.env.TOKEN);
src/commands/ping.ts:
import { Command } from "@sapphire/framework";
import type { Message } from "discord.js";

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

public async messageRun(message: Message) {
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.`;

return msg.edit(content);
}
}
import { Command } from "@sapphire/framework";
import type { Message } from "discord.js";

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

public async messageRun(message: Message) {
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.`;

return msg.edit(content);
}
}
log output:
[logn@spelling-is-fun no]$ npm run start

> no@2.0.0 start
> npm run build && node -r source-map-support/register .


> no@2.0.0 build
> tsc

[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 0ms to initialize.
[logn@spelling-is-fun no]$ npm run start

> no@2.0.0 start
> npm run build && node -r source-map-support/register .


> no@2.0.0 build
> tsc

[INFO] ApplicationCommandRegistries: Initializing...
[INFO] ApplicationCommandRegistries: Took 0ms to initialize.
The bot does come online on Discord package.json
{
"name": "no",
"version": "2.0.0",
"description": "no",
"main": "dist/index.js",
"type": "module",
// --snip--
"scripts": {
"build": "tsc",
"start": "npm run build && node -r source-map-support/register ."
},
"dependencies": {
// --snip: old dependencies that aren't in use--
"@sapphire/framework": "^4.4.0",
"discord.js": "^14.9.0",
"dotenv": "^16.0.3",
"source-map-support": "^0.5.21"
},
// --snip--
"devDependencies": {
"typescript": "^5.0.4"
}
}
{
"name": "no",
"version": "2.0.0",
"description": "no",
"main": "dist/index.js",
"type": "module",
// --snip--
"scripts": {
"build": "tsc",
"start": "npm run build && node -r source-map-support/register ."
},
"dependencies": {
// --snip: old dependencies that aren't in use--
"@sapphire/framework": "^4.4.0",
"discord.js": "^14.9.0",
"dotenv": "^16.0.3",
"source-map-support": "^0.5.21"
},
// --snip--
"devDependencies": {
"typescript": "^5.0.4"
}
}
Added a ready listener -- it does in fact log in as I expected File structure as well:
[logn@spelling-is-fun no]$ tree src
src
├── commands
│   └── ping.ts
├── index.ts
└── listeners
└── ready.ts
[logn@spelling-is-fun no]$ tree src
src
├── commands
│   └── ping.ts
├── index.ts
└── listeners
└── ready.ts
A console.log in the ping command constructor fires, but not in the messageRun when ran Slash command works
Solution
Spinel
Spinel14mo ago
- Which version of @sapphire/framework are you using? - What's your file/folder structure? - Did you use the CLI to generate your bot? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts? - In case you are using version 3.0.0 or higher of @sapphire/framework, and your problem related to message commands, did you add loadMessageCommandListeners to your SapphireClient options Remember that if you are new to @sapphire/framework it is important that you read the user guide.
Favna
Favna14mo ago
^ last point
log(n)
log(n)14mo ago
Should that not be pointed out in the guide?
Favna
Favna14mo ago
it should yes, blame @const name = args.pick('sean'); whose been promising to make a PR for weeks angeryomegalul
Sean
Sean14mo ago
I was working on it last night... a first draft is almost done but conventional commits really annoyed me last night
Favna
Favna14mo ago
chore: do work not like it really matters, it gets squashed anyway and the PR title is used
Sean
Sean14mo ago
It wont let me commit even to my own fork without it following the standard lol.
Favna
Favna14mo ago
well yeah that's what git hooks are for commitlint runs on your machine, not GH
Sean
Sean14mo ago
I know
log(n)
log(n)14mo ago
--no-verify
Favna
Favna14mo ago
^ or that yeah
log(n)
log(n)14mo ago
i always have to repeat to myself git commit --no-verify --no-gpg-sign (my gpg key is expired and i don't wanna fix that rn)
Favna
Favna14mo ago
-n is short for --no-verify fyi
log(n)
log(n)14mo ago
IT IS?
Favna
Favna14mo ago
yes
log(n)
log(n)14mo ago
is there one for --no-gpg-sign? man page should answer that anyways thank you @Favna
Favna
Favna14mo ago
https://git-scm.com/docs/git-commit#:~:text=By%20default%2C%20the%20pre%2Dcommit%20and I mean no but you could just disable it in git config and next time generate a gpg key that doesnt expire
log(n)
log(n)14mo ago
bad no my master key has a while on it
Favna
Favna14mo ago
expiring gpg keys arent worth it for git commits. It's not that important for them to expire. It's not like you're sending encrypted files.
log(n)
log(n)14mo ago
i just need to re-generate my new subkeys
Favna
Favna14mo ago
I dont even bother with separate subkeys
log(n)
log(n)14mo ago
i use pgp for stuff other than git, so i care about it
Favna
Favna14mo ago
fair