#What to import when using the Client

22 messages · Page 1 of 1 (latest)

next reef
#

Hi guys, not really an issue regarding a piece of code, but I'm working on a little project on my own and I'd to know know how many imports there are in the 'new Client' for now, I have only stumbled upon GatewayIntentBits and Partials, is there more to it ? I'm adding options and they do not seem to require any import.

small bisonBOT
#
  • 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!
  • Marked as resolved by staff
next reef
#

So, I'd like to know how much (if there are any more) imports there is and their names or where to find a list

deft wolf
#

it depends on what your bot does

#

you only need those 2 to login (and ofc the client itself)

#

and possible the Events enum to listen for events

#

but i dont see why the amount of imports is important

rustic wyvern
#

The official guide has most necessary features and lets you know what to import when trying to use different aspects of djs.

rocky raftBOT
next reef
#
const client = new Client ({
  intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds],
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
``` and from there I need to generate an import
#

so in that case It would be

import { Partials,GatewayIntentBits } from 'discord.js'
#

so yes, that's why I was asking how many "imports" there could be in a "new Client" because on my program I am parsing the Client and generating the imports dynamically

#

And yes SpecialSauce, I looked through the guide and I quite found my answers, but I wanted to know if I was missing more than I read (ngl I think I'm sometimes skipping paragraph)

cyan mason
#

well it's a basic concept of programming in general for things to be defined and accessible within a context before you access them in that context
discord.js is not native to node.js, so there isn't anything in discord.js that will be available at the top level without importing
but there also isn't anything that you're required to use, so you'll only need to import what you use
if you're not already comfortable with javascript and the differences between what's native to it (or at the very least comfortable with being able to search for it) and what relates to the discord api, you may want to consider learning the basics first

next reef
#

I know nothing will be available if I am not importing them, I am pretty familiar with Javascript and how imports are working

#

And I know, I am not required to import everything don't worry, I'm just having a hard time going through Discord.js docs specifically

#

But I mean, to sum it all up, I just wondered if there was a "page" where all the imports were "displayed" for each type in the client Object

#

but if there isn't it's fine, I'll just try further options and see if it hits a wall :p

#

thanks for the help anywayyyyyys that was lovely :3

rustic wyvern
rocky raftBOT