简体   繁体   中英

How can I implement a !leaveguild <guildID> command (that leaves the specified guild) into my Discord (discord.js) bot?

I want to implement a.leaveguild command that leaves the Discord guild with the specified ID. I'm quite new to discord.js and StackOverflow so any help would be appreciated!

You can use guild.leave() for that

if (!args[0]) return message.reply('enter a guild ID')
const guild = client.guilds.cache.get(args[0])
if (!guild) return message.reply('that is not a valid guild ID')
guild.leave()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM