#help bot doesn't respond to messageCreate

26 messages · Page 1 of 1 (latest)

queen wolf
#

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);


heavy runeBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
queen wolf
#
(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)
fickle zodiacBOT
queen wolf
#

what the hell is a partial

humble dew
#

Click the link

fickle zodiacBOT
queen wolf
# humble dew Click the link

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?

humble dew
#

Yes, and you should update some code. The guide shows everything

lament valley
#

also

fickle zodiacBOT
#

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
queen wolf
#

what purpose does this server like tf

humble dew
#

The message will have the full data in messageCreate. The channel will have only the id.

queen wolf
#

I don't get the second part

humble dew
#

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.

queen wolf
#

bro understanding calculus 3 was fucking easier -.-

#

fuck this im just changing my code

#

@humble dew bruh so I did the partials thingy now it's returning that channel type is 1

#

🙂

#

rather than "dm"

lament valley
#

well yeah

#

you have to use the ChannelType enum to compare

#

just like you did below to create the channel