Leave (NOT COMMAND)

How do I leave a server through my VSCode if i don't own the server (i have no permissions to kick the bot) and I want my bot to leave their server. Please help
19 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 OP
d.js docs
d.js docs2mo ago
:method: Guild#leave() @14.16.3 Leaves the guild.
// Leave a guild
guild.leave()
.then(guild => console.log(`Left the guild: ${guild.name}`))
.catch(console.error);
// Leave a guild
guild.leave()
.then(guild => console.log(`Left the guild: ${guild.name}`))
.catch(console.error);
Invisible
InvisibleOP2mo ago
and where should i input this into my main index file ?
Syjalo
Syjalo2mo ago
Where your client is ready Eg in ready event
Invisible
InvisibleOP2mo ago
okay ill try it now and where do i input which guild to leave @Syjalo
chewie
chewie2mo ago
client.guilds.cache.get('id') that returns the guild on which you can call .leave()
Invisible
InvisibleOP2mo ago
okay perfect time to test it Sorry, still not quite exactly sure where to plug this in?
chewie
chewie2mo ago
in your ready event
Invisible
InvisibleOP2mo ago
im a noob at coding 😭 what is the ready event
chewie
chewie2mo ago
if you dont have an events folder, probably somewhere in the index.js
Invisible
InvisibleOP2mo ago
okay
chewie
chewie2mo ago
client.on('ready', () => {...})
Invisible
InvisibleOP2mo ago
OH IN THAT JON @chewie here is my code where should i put it in
chewie
chewie2mo ago
not there thats your message event
Invisible
InvisibleOP2mo ago
wait what im so confused
chewie
chewie2mo ago
messageCreate !== ready
Invisible
InvisibleOP2mo ago
in here?
chewie
chewie2mo ago
please... just search for ready :pepe_clap:
Invisible
InvisibleOP2mo ago
okay in that let me try the console.log("Left Server") @chewie holy shit am i dumb i did it thank you

Did you find this page helpful?