kick/ban member in list of servers

why it only kicks from the server i used the command at? the guilds id are consoled correctly
async execute(interaction) {
const user = interaction.options.getUser("user");

for (const guildID of process.env.GUILDS.split(",")) {
console.log(guildID)
const guild = await interaction.guild.fetch(guildID)

await guild.members.kick(user);
}

await interaction.reply(`Kicked ${user.tag}`);
},
async execute(interaction) {
const user = interaction.options.getUser("user");

for (const guildID of process.env.GUILDS.split(",")) {
console.log(guildID)
const guild = await interaction.guild.fetch(guildID)

await guild.members.kick(user);
}

await interaction.reply(`Kicked ${user.tag}`);
},
3 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
Syjalo
Syjalo2mo ago
Because you're fetching the guild, the interaction was executed in. Use interaction.client.guilds.cache.get('id')
Omar
OmarOP2mo ago
thanks for helping!
Want results from more Discord servers?
Add your server