44 |
channel_id: channel.id, |
channel_id: channel.id, |
45 |
reason, |
reason, |
46 |
previous_perms: permJson, |
previous_perms: permJson, |
47 |
role_id: lockRole.id |
role_id: lockRole.id, |
48 |
|
createdAt: new Date() |
49 |
}); |
}); |
50 |
|
|
51 |
await channel.permissionOverwrites.edit(lockRole, { |
await channel.permissionOverwrites.edit(lockRole, { |
83 |
const lockRole = role ? (role instanceof Role ? role : (await channel.guild.roles.fetch(role))!) : channel.guild.roles.everyone; |
const lockRole = role ? (role instanceof Role ? role : (await channel.guild.roles.fetch(role))!) : channel.guild.roles.everyone; |
84 |
|
|
85 |
const channelLock = await ChannelLock.findOne({ |
const channelLock = await ChannelLock.findOne({ |
86 |
where: { |
channel_id: channel.id, |
87 |
channel_id: channel.id, |
guild_id: channel.guild.id, |
88 |
guild_id: channel.guild.id, |
role_id: lockRole.id |
|
role_id: lockRole.id |
|
|
} |
|
89 |
}); |
}); |
90 |
|
|
91 |
if (!channelLock) { |
if (!channelLock) { |
93 |
return false; |
return false; |
94 |
} |
} |
95 |
|
|
96 |
const permissions = channelLock?.get('previous_perms') as { allow: PermissionString[] | null, deny: PermissionString[] | null }; |
const permissions = channelLock?.previous_perms; // as { allow: PermissionString[] | null, deny: PermissionString[] | null } |
97 |
|
|
98 |
if (!permissions && !force) { |
if (!permissions && !force) { |
99 |
console.log('Permission error'); |
console.log('Permission error'); |
101 |
} |
} |
102 |
|
|
103 |
const transform = (key: PermissionString) => { |
const transform = (key: PermissionString) => { |
104 |
if (!permissions.allow || !permissions.deny) { |
if (!permissions?.allow || !permissions?.deny) { |
105 |
return undefined; |
return undefined; |
106 |
} |
} |
107 |
|
|
120 |
} |
} |
121 |
}; |
}; |
122 |
|
|
123 |
if (!permissions.allow && !permissions.deny) { |
if (!permissions?.allow && !permissions?.deny) { |
124 |
await channel.permissionOverwrites.delete(lockRole); |
await channel.permissionOverwrites.delete(lockRole); |
125 |
} |
} |
126 |
else { |
else { |
132 |
}, { reason }); |
}, { reason }); |
133 |
} |
} |
134 |
|
|
135 |
await channelLock?.destroy(); |
await channelLock?.delete(); |
136 |
|
|
137 |
if (sendConfirmation && channel.isText()) { |
if (sendConfirmation && channel.isText()) { |
138 |
await channel.send({ |
await channel.send({ |