Fix mute command
parent
4e1f8692c3
commit
b7fc65f74c
10
bot.py
10
bot.py
|
@ -190,16 +190,16 @@ async def mute(ctx, target_user:discord.User):
|
||||||
if vote_passed:
|
if vote_passed:
|
||||||
# Add to muted_users
|
# Add to muted_users
|
||||||
muted_users.append(target_user)
|
muted_users.append(target_user)
|
||||||
# add temp. role for mute
|
# add temp. role for mute, edit role position to take precedence over other roles
|
||||||
muted_role = await ctx.guild.create_role(name="Muted")
|
muted_role = await ctx.guild.create_role(name="Muted")
|
||||||
# edit role position to take precedence over other roles
|
|
||||||
await muted_role.edit(position=ctx.guild.get_member(target_user.id).top_role.position+1)
|
await muted_role.edit(position=ctx.guild.get_member(target_user.id).top_role.position+1)
|
||||||
|
|
||||||
# change channel permissions for new role
|
# change channel permissions for new role
|
||||||
for channel in ctx.guild.channels:
|
for channel in ctx.guild.channels:
|
||||||
if channel is discord.TextChannel and target_user in channel.members:
|
if type(channel) is discord.TextChannel and target_user in channel.members:
|
||||||
await channel.set_permissions(muted_role, read_messages=True, send_messages=False, add_reactions=False)
|
await channel.set_permissions(muted_role, read_messages=True, send_messages=False, add_reactions=False)
|
||||||
|
|
||||||
elif channel is discord.VoiceChannel:
|
elif type(channel) is discord.VoiceChannel:
|
||||||
await channel.set_permissions(muted_role, connect=False)
|
await channel.set_permissions(muted_role, connect=False)
|
||||||
|
|
||||||
# Give role to member
|
# Give role to member
|
||||||
|
@ -248,4 +248,4 @@ async def ban(ctx, target_user:discord.User):
|
||||||
banning_users.remove(target_user)
|
banning_users.remove(target_user)
|
||||||
|
|
||||||
# bot.run(open("token.txt").read().strip())
|
# bot.run(open("token.txt").read().strip())
|
||||||
bot.run(environ["BOT_TOKEN"])
|
bot.run(environ["BOT_TOKEN"])
|
Loading…
Reference in New Issue