#I wanted to create a discord.js code for my bot that using External app Command user spam
21 messages · Page 1 of 1 (latest)
i believe message.interactionMetadata?.user should have it
or at least something in that interaction metadata should
also you could just remove permissions for using external apps too
-# (if you didnt already know they are abusing user installable bot)
i used but not working
i dont want it because i want bot takees action on that user by giving timeout
just disable external apps in your server and use wick if possible for anti spam??
Not working how? Because that is exactly what you need
Message#interactionMetadata [email protected]
Partial data of the interaction that this message is a result of
Get the member from the guild by their user id and time them out. Or use <Guild>.members.edit(...) with communicationDisabledUntil to directly time them out without having to fetch or cache them
Wick Bypassed already and i dont want it to disable external apps
client.on('messageCreate', async (message) => {
if (message.type !== MessageType.ChatInputCommand) return;
try {
const isBotInServer = await message.guild.members.fetch(message.author.id).catch(() => null);
if (isBotInServer) return;
const executorId = message.interactionMetadata?.user?.id;
if (executorId) {
const memberToPunish = await message.guild.members.fetch(executorId).catch(() => null);
if (memberToPunish) {
await memberToPunish.timeout(60 * 60 * 1000, 'Using unauthorized external apps/spamming');
console.log(`Timed out ${memberToPunish.user.tag} for external app spam.`);
}
}
if (message.deletable) {
await message.delete();
console.log(`Deleted spam message from external bot: ${message.author.tag}`);
}
} catch (error) {
console.error('Error handling external app:', error);
}
});
I have created this but not working idk why
Those aren't chatinputcommands, so your message type doesn't match
btw that first check of isBotInServer can be done simpler by using the message.interactionMetadata.authorizingIntegrationOwners prop
but yeah i was getting ahead of myself, qjuh's right that it exits too early
client.on('messageCreate', async (message) => {
const metadata = message.interactionMetadata;
if (!metadata) return;
const isUserInstalled = !metadata.authorizingIntegrationOwners.has('0');
if (isUserInstalled) {
try {
const executorId = metadata.user?.id;
if (executorId) {
const member = await message.guild.members.fetch(executorId).catch(() => null);
if (member) {
await member.timeout(60 * 60 * 1000, 'Using unauthorized user-installed apps');
console.log(`Timed out ${member.user.tag} for external app usage.`);
}
}
if (message.deletable) await message.delete();
} catch (error) {
console.error('Error handling external app:', error.message);
}
}
});
Like I have did this but not working
hello?
Not working how?
What happens, what doesn't? #how-to-get-help