1
0
Fork 0

Update chan to accept also user mention

This commit is contained in:
Ethanell 2020-05-17 22:13:44 +02:00
parent 7b2fc2ed76
commit 7b68cd34fb

View file

@ -25,18 +25,20 @@ class Chan(commands.Cog):
await ctx.invoke(self.chan_help) await ctx.invoke(self.chan_help)
else: else:
chan: TextChannel = await ctx.guild.create_text_channel(name) chan: TextChannel = await ctx.guild.create_text_channel(name)
if len(ctx.message.role_mentions) != 0: if len(ctx.message.role_mentions) != 0 or len(ctx.message.mentions) != 0:
await chan.set_permissions(ctx.guild.default_role, read_messages=False, send_messages=False) await chan.set_permissions(ctx.guild.default_role, read_messages=False, send_messages=False)
for r in ctx.message.role_mentions: for r in ctx.message.role_mentions:
await chan.set_permissions(r, read_messages=True, send_messages=True) await chan.set_permissions(r, read_messages=True, send_messages=True)
for m in ctx.message.mentions:
await chan.set_permissions(m, read_messages=True, send_messages=True)
@chan.group("help", pass_context=True) @chan.group("help", pass_context=True)
@commands.guild_only() @commands.guild_only()
async def chan_help(self, ctx: commands.Context): async def chan_help(self, ctx: commands.Context):
embed = Embed(title="chan help") embed = Embed(title="chan help")
embed.add_field(name="chan <name> [@role]", embed.add_field(name="chan <name> [@role|@user]",
value="Create a new chan, the roles mentioned will be the only one permitted to read and write " value="Create a new chan, the roles and/or users mentioned will be the only one permitted to "
"in the chan\n", "read and write in the chan\n",
inline=False) inline=False)
await ctx.send(embed=embed) await ctx.send(embed=embed)