Skip to content

Members, roles and moderation

The cache has the community’s roles and channels, and the members it has seen. Fetch the full member list when you need it:

const members = await community.members.fetch();
const mods = await community.roles.create("Moderators", { permissions: ["KickMembers", "TimeoutMembers"] });
await members.first().roles.add(mods);
if (member.permissions(channel).has("SendMessages")) { /* … */ }

This uses the same resolver as the host, applied to the cache. Use it to hide what a member can’t do; the host still decides (it also applies lockdowns and newcomer rules).

await target.timeout(10 * 60_000, "cool down");
await target.kick("asked to");
await target.ban("spam");

Each needs the matching permission (TIMEOUT_MEMBERS, KICK_MEMBERS, BAN_MEMBERS) and a highest role above the target’s. Nobody can act on the owner. Bans follow the member’s key, so a banned member can’t come back with the same identity.

const link = await community.createInvite({ maxUses: 5, expiresIn: 86_400 });
const lounge = await community.channels.create("lounge", { type: "voice" });