message commands are not working

trying to update to v4 and the bot is not recognizing commands. i have enabled loadMessageCommandListeners: true and the bot does have proper intents. is there anything new i should be updating?
Solution:
Possibly related to https://discord.com/channels/737141877803057244/1062989204549816320/1062989204549816320 please use search before making a new post....
Jump to solution
25 Replies
Solution
Favna
Favna2y ago
Possibly related to https://discord.com/channels/737141877803057244/1062989204549816320/1062989204549816320 please use search before making a new post.
sairasu
sairasu2y ago
actually i tried a lot and couldnt find this thanks tho
Favna
Favna2y ago
Don't take this in a negative way but I call this into question because simply searching "message" has it show up. Maybe you're not aware you can filter/search forum posts? Video shows how on mobile, desktop is pretty much the same.
Favna
Favna2y ago
Not to mention the thread was high up still. You just had to scroll down a fractional bit. With both these factors there is just no way you put in, by your own claim, a lot of effort. @sairasu so the linked post was resolved, but commands did work there to begin with. If you still need help please provide the code of your bot as without code we can't do much
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.
sairasu
sairasu2y ago
I was using control F but yea for sure I thought I had fixed it but it did not actually work which is strange the bot responds when it’s pinged and says “My prefix is .” but doesn’t respond to commands I’ll send something in a few the only issue is that messageCreate IS being logged if i try and just make it log what im saying in a server but commands just dont run? its hard to find the bug when theres no error
sairasu
sairasu2y ago
sairasu
sairasu2y ago
heres what i have in my index
import './lib/setup';
import { BucketScope, LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits, Partials } from 'discord.js';

const client = new SapphireClient({
defaultCooldown: {
delay: 10000,
limit: 2,
scope: BucketScope.Channel
},
defaultPrefix: '.',
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel],
api: {
listenOptions: {
port: 6000,
},
},
loadMessageCommandListeners: true
});

const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info(`logged in as ${client.user?.tag}`);
} catch (error) {
client.logger.fatal(error);
client.destroy();
process.exit(1);
}
};

main();
import './lib/setup';
import { BucketScope, LogLevel, SapphireClient } from '@sapphire/framework';
import { GatewayIntentBits, Partials } from 'discord.js';

const client = new SapphireClient({
defaultCooldown: {
delay: 10000,
limit: 2,
scope: BucketScope.Channel
},
defaultPrefix: '.',
caseInsensitiveCommands: true,
logger: {
level: LogLevel.Debug
},
shards: 'auto',
intents: [
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildBans,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel],
api: {
listenOptions: {
port: 6000,
},
},
loadMessageCommandListeners: true
});

const main = async () => {
try {
client.logger.info('Logging in');
await client.login();
client.logger.info(`logged in as ${client.user?.tag}`);
} catch (error) {
client.logger.fatal(error);
client.destroy();
process.exit(1);
}
};

main();
Favna
Favna2y ago
Other than the 10 seconds cooldown after 2 commands there's nothing wrong there. Please share the full code so I or anyone else can properly debug, or attach a debugger yourself and use breakpoints to navigate the core events.
sairasu
sairasu2y ago
absolutely no reason to use the same command more than twice but ok not sure how thats relevant ill debug ig
Favna
Favna2y ago
depends on what kind of bot you're making tbh. For example for @Dragonite you may want to get the details on multiple pokemon so you query twice
sairasu
sairasu2y ago
for sure not in my case
Favna
Favna2y ago
anyway if you want my help zip up the code or put it on GH (private and give me access if you must)
Anthony
Anthony2y ago
I seem to have fallen into the same issue as well, I can't figure out why after I've updated to v4 that message commands won't run, and it worked on v3. I have tried to check and for some reason it won't run anything inside messageRun.
Favna
Favna2y ago
Same goes for you, we'll need some code if you want help. We cannot wave a magic wand and read your brain and look through your eyes.
Spinel
Spinel2y ago
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stacktraces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
❯ For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines. ❯ For an excellent video that shows how not to ask technical questions is this, watch this YouTube video by LiveOverflow. ❯ Asking technical questions (Clarkson)How to ask questions the smart way (Raymond)
Anthony
Anthony2y ago
Sorry, I thought as it said it was solved that it may have been fixed in DMs or something. Here is the repo, ignore the bit of a mess it is, ik I need to get to refactoring it 😭 https://github.com/veganhacktivists/arabot This is a command I knew that worked in v3: https://github.com/veganhacktivists/arabot/blob/main/src/commands/roles/convinced.ts In https://github.com/veganhacktivists/arabot/blob/main/src/index.ts I have also tried to see if defaultPrefix: process.env.DEFAULT_PREFIX, was the issue and replaced it with defaultPrefix: '?', in testing, but it didn't help.
Favna
Favna2y ago
You didn't provide GatewayIntentBits.MessageContent, and possibly also not enable the message content intent on https://discord.dev dashboard
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Anthony
Anthony2y ago
Yeahhh it seems like I didn't know I had to add GatewayIntentBits.MessageContent, sorry about that. Thank you though :))
Favna
Favna2y ago
An easy mistake to make (made it myself as well a few days ago) to be fair it's also not documented in the djs migration guide <_< Could you maybe make a PR to https://github.com/sapphiredev/website/blob/main/docs/Guide/getting-started/updating-from-v3-to-v4.mdx to add it? That would help a lot
Anthony
Anthony2y ago
Ahhh alright, at least that softens the blow for me haha And I'd be happy to make a PR :)
Favna
Favna2y ago
awesome, thanks
vphilip
vphilip17mo ago
Same issue here I added cooldowns and message commands stopped working
24
2417mo ago
same reply here- please include additional context or make a new post
Spinel
Spinel17mo ago
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stacktraces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
❯ For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines. ❯ For an excellent video that shows how not to ask technical questions is this, watch this YouTube video by LiveOverflow. ❯ Asking technical questions (Clarkson)How to ask questions the smart way (Raymond)