new Client VS new REST + new WebSocketManager

I'm confused. I've read the guide but I see competing examples. Should I use :
// Create REST and WebSocket managers directly
const rest: REST = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
const intents = [GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
const gateway = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
});

// Create a client to emit relevant events.
const client = new Client({ rest, gateway });
// Create REST and WebSocket managers directly
const rest: REST = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);
const intents = [GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
const gateway = new WebSocketManager({
token: process.env.DISCORD_TOKEN,
intents: GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent,
rest,
});

// Create a client to emit relevant events.
const client = new Client({ rest, gateway });
or
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
Using the first option client.on(Events.ClientReady, msg => { never triggers, I need to use gateway.on(Events.ClientReady, msg => { (not client.gateway.on, TS warns about invalid types) I'm guessing I'm also confused betweent the discord.js package and the @discordjs package 😂 I never used discordjs before and I'm very lost. No two starting examples are alike :/ HALP ! 🙏
8 Replies
d.js toolkit
d.js toolkit2mo 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
treble/luna
treble/luna2mo ago
sounds like you just want the second then
d.js docs
d.js docs2mo ago
:guide: Home: What's new read more
JustUseFirefox
JustUseFirefoxOP2mo ago
Why ? Whats the difference ? I dont know what I want, I cant find any explanation of the difference between the two 😂
treble/luna
treble/luna2mo ago
the first is just the second but with extra steps
JustUseFirefox
JustUseFirefoxOP2mo ago
😂 I'm sold
treble/luna
treble/luna2mo ago
if you're new to djs i highly doubt youd want that
JustUseFirefox
JustUseFirefoxOP2mo ago
Arigato! 🙏

Did you find this page helpful?