3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Update DJS

This commit is contained in:
Dark 2021-07-04 17:41:44 +02:00
parent ac619ec00f
commit 5e73d380c5
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
23 changed files with 71 additions and 56 deletions

View file

@ -11,16 +11,13 @@ export async function applyBotSlowmodeToUserId(
userId: string,
) {
// Deny sendMessage permission from the user. If there are existing permission overwrites, take those into account.
const existingOverride = channel.permissionOverwrites.get(userId as Snowflake);
const newDeniedPermissions =
(existingOverride ? existingOverride.deny.bitfield : 0n) | Permissions.FLAGS.SEND_MESSAGES;
const newAllowedPermissions =
(existingOverride ? existingOverride.allow.bitfield : 0n) & ~Permissions.FLAGS.SEND_MESSAGES;
const existingOverride = channel.permissionOverwrites.resolve(userId as Snowflake);
try {
await channel.overwritePermissions([
{ id: userId, allow: newAllowedPermissions, deny: newDeniedPermissions, type: "member" },
]);
if (existingOverride) {
await existingOverride.edit({ SEND_MESSAGES: false });
} else {
await channel.permissionOverwrites.create(userId as Snowflake, { SEND_MESSAGES: false }, { type: 1 });
}
} catch (e) {
const user = pluginData.client.users.fetch(userId as Snowflake) || new UnknownUser({ id: userId });