mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 15:19:12 -06:00
adding existing whitelist overwrites permissions
This commit is contained in:
parent
4007a49d37
commit
d41b16281a
@ -17,17 +17,19 @@ class Group(commands.Cog, name="group"):
|
||||
async def baseperm(self, interaction: discord.Interaction, role: discord.Role, perms: str):
|
||||
if role.id in self.client.whitelistGrps.keys():
|
||||
await interaction.response.send_message(
|
||||
f"**{role.name}** is already added, cannot add it again!"
|
||||
f"**{role.name}** is already added, overwriting permissions..."
|
||||
)
|
||||
self.client.whitelistGrps[role.id].squadPerms = perms
|
||||
self.client.whitelistGrps[role.id].updateGroup()
|
||||
else:
|
||||
log.info(f"Adding {role.name} ({role.id}) as a Whitelist role")
|
||||
await interaction.response.send_message(
|
||||
f"Adding **{role.name}** as a Whitelist role"
|
||||
)
|
||||
self.client.whitelistGrps[role.id] = config.WhitelistGroup(
|
||||
name=role.name, roleID=role.id, permissions=perms
|
||||
)
|
||||
return
|
||||
|
||||
log.info(f"Adding {role.name} ({role.id}) as a Whitelist role")
|
||||
await interaction.response.send_message(
|
||||
f"Adding **{role.name}** as a Whitelist role"
|
||||
)
|
||||
self.client.whitelistGrps[role.id] = config.WhitelistGroup(
|
||||
name=role.name, roleID=role.id, permissions=perms
|
||||
)
|
||||
membsup = []
|
||||
for memb in role.members:
|
||||
membsup.append(memb.id)
|
||||
@ -39,6 +41,7 @@ class Group(commands.Cog, name="group"):
|
||||
udata = memupcur.fetchall()
|
||||
for data in udata:
|
||||
self.client.whitelistGrps[role.id].addMember(config.WhitelistMember(data[2], "unknown", data[0]))
|
||||
interaction.response.send_message("Whitelist group successfully added/updated")
|
||||
self.client.squadjs.commit()
|
||||
|
||||
@app_commands.command()
|
||||
|
@ -33,6 +33,10 @@ class WhitelistGroup:
|
||||
os.remove(f"./wlgrps/{self.name}.cfg")
|
||||
os.remove(f"./wlgrps/{self.name}.json")
|
||||
|
||||
def updateGroup(self):
|
||||
self.updateFile()
|
||||
self.updateWL()
|
||||
|
||||
def updateFile(self):
|
||||
outFile = open(f"./wlgrps/{self.name}.json", "w")
|
||||
outFile.write(jsonpickle.encode(self))
|
||||
|
Loading…
Reference in New Issue
Block a user