not working

Hi, my bot is not working does anyone know why? index.ts:
import { SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

(async () => await (new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],

defaultPrefix: '?',

caseInsensitiveCommands: true,
loadMessageCommandListeners: true,
})).login('TOKEN'))();
import { SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits } from 'discord.js';

(async () => await (new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],

defaultPrefix: '?',

caseInsensitiveCommands: true,
loadMessageCommandListeners: true,
})).login('TOKEN'))();
commands/ping.ts:
import { Command } from '@sapphire/framework';
import type { Message } from 'discord.js';

export class UserCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, { ...options,
aliases: [
'pong',
],

name: 'ping',
});
};

public async messageRun(message: Message) {
const msg = await message.channel.send('Pong?');

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 UserCommand extends Command {
public constructor(context: Command.Context, options: Command.Options) {
super(context, { ...options,
aliases: [
'pong',
],

name: 'ping',
});
};

public async messageRun(message: Message) {
const msg = await message.channel.send('Pong?');

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);
}
};
Solution:
3. I dont have a main property
you say you following the guide but......
No description
Jump to solution
12 Replies
nodejs.org
nodejs.orgOP2y ago
Hello?
Favna
Favna2y ago
what's with the immediately invoked function expression tbh. why not just
async function start() {
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],

defaultPrefix: '?',

caseInsensitiveCommands: true,
loadMessageCommandListeners: true,
});

await client.login(TOKEN);
}

start();
async function start() {
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],

defaultPrefix: '?',

caseInsensitiveCommands: true,
loadMessageCommandListeners: true,
});

await client.login(TOKEN);
}

start();
anyway
Spinel
Spinel2y ago
- Did you use a folder of the examples repository or did you use the CLI to generate your bot? - What's your file/folder structure? - What's your "main" property in package.json - Are you using TypeScript? And if so, how are you compiling and running your code? - Are you using the version 2 or version 3 of @sapphire/framework? - In case you are using version 3 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
Favna2y ago
btw for future reference, we have the Helpers role you can ping after ~15 minutes of no response. At the end of the day we're all busy people too. Like basically any coding support anywhere we're not constantly monitoring for new posts.
nodejs.org
nodejs.orgOP2y ago
Okay 1. I did it as its described in the guide 2. bot/ source/ index.ts commands/ ping.ts 3. I dont have a main property 4. yes, yarn tsc && node dist/index.ts 5. 3 6. Yes
Solution
Favna
Favna2y ago
3. I dont have a main property
you say you following the guide but...
No description
Favna
Favna2y ago
anyway you should also use Sapphire v4. Sapphire v3 is ... i mean.. still supported ofc but not latest
nodejs.org
nodejs.orgOP2y ago
Oh 😂 Okay i will use it Thank you so much
Favna
Favna2y ago
np you can use the CLI if you want to generate a template that's pretty much ready to go
Spinel
Spinel2y ago
@sapphire/cli
CLI for Sapphire Framework ❯ Author: sapphiredev ❯ Maintainers: favna, vladfrangu, and kyranet ❯ Latest version: 1.3.1 ❯ License: MIT ❯ Date Created: <t:1632429711:d> ❯ Date Modified: <t:1674969820:d> Dependencies: @favware/colorette-spinner, @sapphire/result, colorette, commander, execa, find-up, js-yaml, prompts, and tslib
nodejs.org
nodejs.orgOP2y ago
can i change the name of my listeners folder or does it not work then?
Favna
Favna2y ago
not by default no, but you can manually register it yourself if you really want to not sure why you'd want to rename it though, they are event listeners after all
Want results from more Discord servers?
Add your server