added chrom
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Client, GatewayIntentBits } from "discord.js";
|
||||
|
||||
const client = new Client({
|
||||
intents: [GatewayIntentBits.Guilds],
|
||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
|
||||
});
|
||||
|
||||
const token = process.env.DISCORD_BOT_TOKEN;
|
||||
|
||||
@@ -51,12 +51,15 @@ const handleRoleChange = (action: "add" | "remove") => async (req: Request, res:
|
||||
? roleIds.filter((id: string) => !currentRoleIds.includes(id))
|
||||
: roleIds.filter((id: string) => currentRoleIds.includes(id));
|
||||
|
||||
console.log(`Attempting to ${action} roles:`, filteredRoleIds, roleIds);
|
||||
console.log(
|
||||
`Attempting to ${action} roles: ${filteredRoleIds.join(", ")} to member ${member.nickname || member.user.username}`,
|
||||
);
|
||||
// Option to skip if no roles to add/remove
|
||||
/* if (filteredRoleIds.length === 0) {
|
||||
if (filteredRoleIds.length === 0) {
|
||||
console.log(`No roles to ${action}`);
|
||||
res.status(200).json({ message: `No roles to ${action}` });
|
||||
return;
|
||||
} */
|
||||
}
|
||||
|
||||
await member.roles[action](roleIds);
|
||||
res.status(200).json({ message: `Roles ${action}ed successfully` });
|
||||
|
||||
Reference in New Issue
Block a user