1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 08:57:46 +00:00

Fix channel_perm_tree 4

This commit is contained in:
RGBCube 2022-12-17 21:34:33 +03:00
parent 2fdc826b5e
commit 8c954ed8d2

View file

@ -59,6 +59,8 @@ class Utils(Cog):
string.append(f"category {channel.name}:") string.append(f"category {channel.name}:")
string.append(f" id: {channel.id}") string.append(f" id: {channel.id}")
perms = []
for thing, overwrites in channel.overwrites.items(): for thing, overwrites in channel.overwrites.items():
if isinstance(thing, Role): if isinstance(thing, Role):
typ = "role" typ = "role"
@ -70,8 +72,8 @@ class Utils(Cog):
typ = repr(thing.type) typ = repr(thing.type)
name = "unknown" name = "unknown"
string.append(f" {typ} {name}:") perms.append(f" {typ} {name}:")
string.append(f" id: {thing.id}") perms.append(f" id: {thing.id}")
allow, deny = [], [] allow, deny = [], []
@ -82,14 +84,14 @@ class Utils(Cog):
deny.append(perm) deny.append(perm)
if allow or deny: if allow or deny:
string.append(" permissions:") perms.append(" permissions:")
for a in allow: for a in allow:
string.append(f" {a}: ✅") perms.append(f" {a}: ✅")
for d in deny: for d in deny:
string.append(f" {d}: ❌") perms.append(f" {d}: ❌")
string.append(" channels:") perms.append(" channels:")
for child in channel.channels: for child in channel.channels:
if isinstance(child, TextChannel): if isinstance(child, TextChannel):
@ -106,6 +108,8 @@ class Utils(Cog):
string.append(f" {typ} channel `{child.name}`:") string.append(f" {typ} channel `{child.name}`:")
string.append(f" id: {child.id}") string.append(f" id: {child.id}")
child_perms = []
for child_thing, child_overwrites in child.overwrites.items(): for child_thing, child_overwrites in child.overwrites.items():
if isinstance(child_thing, Role): if isinstance(child_thing, Role):
typ = "role" typ = "role"
@ -117,8 +121,8 @@ class Utils(Cog):
typ = repr(child_thing.type) typ = repr(child_thing.type)
name = "unknown" name = "unknown"
string.append(f" {typ} {name}:") child_perms.append(f" {typ} {name}:")
string.append(f" id: {child_thing.id}") child_perms.append(f" id: {child_thing.id}")
allow, deny = [], [] allow, deny = [], []
@ -142,6 +146,13 @@ class Utils(Cog):
for d in deny: for d in deny:
string.append(f" {d}: ❌") string.append(f" {d}: ❌")
if child_perms:
string.append(" permissions:")
string.extend(child_perms)
if perms:
string.append(" permissions:")
string.extend(perms)
else: else:
if isinstance(channel, TextChannel): if isinstance(channel, TextChannel):
typ = "text" typ = "text"
@ -157,6 +168,8 @@ class Utils(Cog):
string.append(f"{typ} channel `{channel.name}`:") string.append(f"{typ} channel `{channel.name}`:")
string.append(f" id: {channel.id}") string.append(f" id: {channel.id}")
perms = []
for thing, overwrites in channel.overwrites.items(): for thing, overwrites in channel.overwrites.items():
if isinstance(thing, Role): if isinstance(thing, Role):
typ = "role" typ = "role"
@ -187,6 +200,10 @@ class Utils(Cog):
for d in deny: for d in deny:
string.append(f" {d}: ❌") string.append(f" {d}: ❌")
if perms:
string.append(" permissions:")
string.extend(perms)
await ctx.reply( await ctx.reply(
file=File( file=File(
BytesIO("\n".join(string).encode()), BytesIO("\n".join(string).encode()),