What to import when using the Client

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.
10 Replies
d.js toolkit
d.js toolkit13mo 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! - Marked as resolved by staff
Iluvme
IluvmeOP13mo ago
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
treble/luna
treble/luna13mo ago
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
SpecialSauce
SpecialSauce13mo ago
The official guide has most necessary features and lets you know what to import when trying to use different aspects of djs.
d.js docs
d.js docs13mo ago
guide Home: Introduction read more
Iluvme
IluvmeOP13mo ago
It's not that important, but I just wanted to know, what "imports" the "new Client({})" could contain, like GatewayIntentBits, Partials or whatever else because basically, I'm receiving a string such as :
const client = new Client ({
intents:[GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds, GatewayIntentBits.Guilds],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
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'
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)
duck
duck13mo ago
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
Iluvme
IluvmeOP13mo ago
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
SpecialSauce
SpecialSauce13mo ago
I think the documentation describes each property in the options and what can be supplied as their value. If you’re talking about the intents property you can locate the enum in the docs used to describe the intents you’re using.
d.js docs
d.js docs13mo ago
interface ClientOptions Options for a dtypes v10: GatewayIntentBits read more
Want results from more Discord servers?
Add your server