help bot doesn't respond to messageCreate

so I have all intents turned on inside dev portal I dm it !ticket and the bot remains silent and the console remains empty any ideas why??? code:
import express from 'express'
const app = express();
const port = 3000
import path from "path"
const file = "main.html"
import { REST, Routes } from 'discord.js';
import bodyParser from 'body-parser'
import { readFileSync } from "fs"
import Discord from "discord.js"
import { GatewayIntentBits, Client, Collection } from 'discord.js';
import Database from "@replit/database"
const db = new Database()
//await db.set("verification codes",JSON.stringify({}))
const client = new Client({

intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.DirectMessages
],
});


app.get('/', (req, res) => {
res.sendFile(path.resolve(file))
})

app.listen(port, () =>
console.log(`connected to port:${port}`)
);




import { readdirSync } from "fs"
const commands = []
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
client.slashcommands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFiles = readdirSync(foldersPath).filter(file => file.endsWith('.mjs'));



for (const file of commandFiles) {
const filePath = path.join(foldersPath, file);
const { command } = await import(`${filePath}`);
if ('data' in command && 'run' in command) {
commands.push(command.data.toJSON())
client.slashcommands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "run" property.`);
}
}


const rest = new REST().setToken(process.env.TOKEN);
import express from 'express'
const app = express();
const port = 3000
import path from "path"
const file = "main.html"
import { REST, Routes } from 'discord.js';
import bodyParser from 'body-parser'
import { readFileSync } from "fs"
import Discord from "discord.js"
import { GatewayIntentBits, Client, Collection } from 'discord.js';
import Database from "@replit/database"
const db = new Database()
//await db.set("verification codes",JSON.stringify({}))
const client = new Client({

intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.DirectMessages
],
});


app.get('/', (req, res) => {
res.sendFile(path.resolve(file))
})

app.listen(port, () =>
console.log(`connected to port:${port}`)
);




import { readdirSync } from "fs"
const commands = []
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
client.slashcommands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
const commandFiles = readdirSync(foldersPath).filter(file => file.endsWith('.mjs'));



for (const file of commandFiles) {
const filePath = path.join(foldersPath, file);
const { command } = await import(`${filePath}`);
if ('data' in command && 'run' in command) {
commands.push(command.data.toJSON())
client.slashcommands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "run" property.`);
}
}


const rest = new REST().setToken(process.env.TOKEN);
17 Replies
d.js toolkit
d.js toolkitā€¢8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
quaint racoon
quaint racoonā€¢8mo ago
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationCommands("1098175082750300181"),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();


client.on("messageCreate", async (msg) => {
console.log(msg.chanel.type)
if(msg.channel.type === 'dm'){
if(msg.content.startsWith("!ticket")){
client.guilds.cache.get("1168638618617786549")
guild.channels.create({
name: `${msg.author.username} ${date.now}`,
type: ChannelType.GuildText,
parent: "1168992735647236198",

});
msg.channel.send(`ticket created:<#${channel.id}>`)
}

}
})
client.on("guildMemberAdd", async (msg)=>{
client.channels.cache.get("1168935030173737123").setName("members "+await msg.guild.memberCount)
})
client.on("guildMemberRemove", async (msg)=>{
client.channels.cache.get("1168935030173737123").setName("members "+await msg.guild.memberCount)
})

readdirSync('./events').forEach(async file => {
const { event } = await import(`./events/${file}`);

if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
})

client.on("ready", async () => {

client.user.setActivity("making memes")
console.log("ready")
})

client.login(process.env.TOKEN)
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationCommands("1098175082750300181"),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();


client.on("messageCreate", async (msg) => {
console.log(msg.chanel.type)
if(msg.channel.type === 'dm'){
if(msg.content.startsWith("!ticket")){
client.guilds.cache.get("1168638618617786549")
guild.channels.create({
name: `${msg.author.username} ${date.now}`,
type: ChannelType.GuildText,
parent: "1168992735647236198",

});
msg.channel.send(`ticket created:<#${channel.id}>`)
}

}
})
client.on("guildMemberAdd", async (msg)=>{
client.channels.cache.get("1168935030173737123").setName("members "+await msg.guild.memberCount)
})
client.on("guildMemberRemove", async (msg)=>{
client.channels.cache.get("1168935030173737123").setName("members "+await msg.guild.memberCount)
})

readdirSync('./events').forEach(async file => {
const { event } = await import(`./events/${file}`);

if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
})

client.on("ready", async () => {

client.user.setActivity("making memes")
console.log("ready")
})

client.login(process.env.TOKEN)
d.js docs
d.js docsā€¢8mo ago
To receive direct message events on "messageCreate" with your bot, you will need: - The DirectMessages gateway intent - The Channel partial setting
quaint racoon
quaint racoonā€¢8mo ago
what the hell is a partial
Syjalo
Syjaloā€¢8mo ago
Click the link
d.js docs
d.js docsā€¢8mo ago
guide Popular Topics: Partial Structures read more
quaint racoon
quaint racoonā€¢8mo ago
I did although I've been using discord.js since v12 never heard of such thing and I got no idea how to use it šŸ’€ do I like just put it once when defining the client?
Syjalo
Syjaloā€¢8mo ago
Yes, and you should update some code. The guide shows everything
treble/luna
treble/lunaā€¢8mo ago
also
d.js docs
d.js docsā€¢8mo ago
Ratelimits are dynamically assigned by the API based on current load and may change at any point. - The scale from okay to API-spam is sliding and depends heavily on the action you are taking - Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
quaint racoon
quaint racoonā€¢8mo ago
who the fuck decided that receiving on message id's then fetching the full message manually was a good idea? what purpose does this server like tf
Syjalo
Syjaloā€¢8mo ago
The message will have the full data in messageCreate. The channel will have only the id.
quaint racoon
quaint racoonā€¢8mo ago
wait what? I don't get the second part
Syjalo
Syjaloā€¢8mo ago
DM channels aren't cached by default. And Discord doesn't provide it with the messageCreate event. So discord.js won't emit the event if the channel isn't cached, except you'll tell discord.js that you're ready to receive partial data by providing the Channel partial.
quaint racoon
quaint racoonā€¢8mo ago
bro understanding calculus 3 was fucking easier -.- fuck this im just changing my code @Syjalo bruh so I did the partials thingy now it's returning that channel type is 1 šŸ™‚ rather than "dm"
treble/luna
treble/lunaā€¢8mo ago
well yeah you have to use the ChannelType enum to compare just like you did below to create the channel
quaint racoon
quaint racoonā€¢8mo ago
I just noticed that it got changed and I just copied the channel create code