mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Update DJS
This commit is contained in:
parent
ac619ec00f
commit
5e73d380c5
23 changed files with 71 additions and 56 deletions
|
@ -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 });
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export async function clearBotSlowmodeFromUserId(
|
|||
// Previously we diffed the overrides so we could clear the "send messages" override without touching other
|
||||
// overrides. Unfortunately, it seems that was a bit buggy - we didn't always receive the event for the changed
|
||||
// overrides and then we also couldn't diff against them. For consistency's sake, we just delete the override now.
|
||||
await channel.permissionOverwrites.get(userId as Snowflake)?.delete();
|
||||
await channel.permissionOverwrites.resolve(userId as Snowflake)?.delete();
|
||||
} catch (e) {
|
||||
if (!force) {
|
||||
throw e;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue