Fix mute command

pull/5/head
michael 2020-03-24 17:07:09 -07:00
parent 4e1f8692c3
commit b7fc65f74c
1 changed files with 5 additions and 5 deletions

10
bot.py
View File

@ -190,16 +190,16 @@ async def mute(ctx, target_user:discord.User):
if vote_passed:
# Add to muted_users
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")
# 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)
# change channel permissions for new role
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)
elif channel is discord.VoiceChannel:
elif type(channel) is discord.VoiceChannel:
await channel.set_permissions(muted_role, connect=False)
# Give role to member
@ -248,4 +248,4 @@ async def ban(ctx, target_user:discord.User):
banning_users.remove(target_user)
# bot.run(open("token.txt").read().strip())
bot.run(environ["BOT_TOKEN"])
bot.run(environ["BOT_TOKEN"])