/[sudobot]/trunk/src/services/ChannelLockManager.ts
ViewVC logotype

Diff of /trunk/src/services/ChannelLockManager.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 244 by rakin, Mon Jul 29 17:29:11 2024 UTC revision 331 by rakin, Mon Jul 29 17:29:35 2024 UTC
# Line 44  export default class ChannelLockManager Line 44  export default class ChannelLockManager
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, {
# Line 82  export default class ChannelLockManager Line 83  export default class ChannelLockManager
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) {
# Line 94  export default class ChannelLockManager Line 93  export default class ChannelLockManager
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');
# Line 102  export default class ChannelLockManager Line 101  export default class ChannelLockManager
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    
# Line 121  export default class ChannelLockManager Line 120  export default class ChannelLockManager
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 {
# Line 133  export default class ChannelLockManager Line 132  export default class ChannelLockManager
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({

Legend:
Removed from v.244  
changed lines
  Added in v.331

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26