async def mute_member(self,ctx,member:Member,*,reason:Optional[str]="No reason provided."): """Mutes a member from the server""" t=datetime.datetime.utcnow() if ctx.author.guild_permissions.manage_roles: channel = get(member.guild.channels, name = "moderation-logs") e=Embed(title='Muted Member', description=f'{member.mention} has been muted successfully.', colour=0x17D8CF) e.add_field(name='Reason',value=reason,inline=False) e.add_field(name='Responsible Mod',value=ctx.author.mention,inline=False) e.set_thumbnail(url=member.avatar_url) e.set_footer(text = t.strftime('%b %d, %Y | %I:%M %p UTC')) role=get(ctx.guild.roles,name="Muted") if ctx.author.top_role.position<member.top_role.position: await ctx.send('you cannot mute a member higher then you.') elif ctx.author==member: await ctx.send('you cannot mute yourself.') elif not role: NewRole=await ctx.guild.create_role(name="Muted") overwrite=PermissionOverwrite() overwrite.send_messages=False for channel in ctx.guild.text_channels: await channel.set_permissions(NewRole,overwrite=overwrite) await member.add_roles(NewRole) await ctx.send(f"**{member.display_name}** has been muted successfully by **{ctx.author.display_name}** for reason: {reason}.") if channel is not None: await channel.send(embed = e) return else: overwrite=PermissionOverwrite() overwrite.send_messages=False for channel in ctx.guild.text_channels: await channel.set_permissions(role,overwrite=overwrite) await member.add_roles(role) await ctx.send(f"**{member.display_name}** has been muted successfully by **{ctx.author.display_name}** for reason:{reason}.") if channel is not None: await channel.send(embed = e) return return else: await ctx.send("You do not have the required permissions")
async def CreateChat(self, guild, channelName, category, discordRole): chan = None cultistRole = get(guild.roles, name="Cultist") if str.lower(self.chat_type) == 'text': chan = await guild.create_text_channel(channelName, category=category) # Set Permissions for the channel # List of Permissions can be found here (they are the attributes): https://discordpy.readthedocs.io/en/stable/api.html?highlight=permissionoverwrite#discord.Permissions role_overwrite = PermissionOverwrite() role_overwrite.view_channel = True role_overwrite.read_messages = True role_overwrite.send_messages = True await chan.set_permissions(discordRole, overwrite=role_overwrite) cultist_overwrite = PermissionOverwrite() cultist_overwrite.view_channel = False await chan.set_permissions(cultistRole, overwrite=cultist_overwrite) if str.lower(self.chat_type) == 'voice': chan = await guild.create_voice_channel(channelName, category=category) await chan.set_permissions(discordRole, view_channel=True, speak=True, stream=True, connect=True) await chan.set_permissions(cultistRole, view_channel=True, connect=False, speak=True) # By default they cannot join, but can see who is in it self.chat_id = chan.id
async def _create_text_channel(self): """ Creates the user-related text-channel """ channels = handler.load_json(JSON_CHANNEL_IDS_FILE) author = self.ctx.author self.users_using[str(author.id)] = 0 channel: TextChannel = await self.ctx.guild.create_text_channel(f'{self.manga["name"]}-{author.name}') ow = PermissionOverwrite() ow.send_messages = False ow.read_messages = True await channel.set_permissions(author, overwrite=ow) default_role = utils.get(self.ctx.guild.roles, name='@everyone') ow.read_messages = False await channel.set_permissions(default_role, overwrite=ow) channels[str(self.ctx.guild.id)][str(author.id)] = str(channel.id) handler.dump_json(JSON_CHANNEL_IDS_FILE, channels) return channel
async def mute(cmd, message, args): channel = message.channel server = message.server if not message.mentions: await cmd.bot.send_message(message.channel, cmd.help()) return user_q = message.mentions[0] overwrite = PermissionOverwrite() overwrite.send_messages = False if message.author is not user_q: if check_man_msg(message.author, channel) and check_man_roles( message.author, channel): try: for chan in server.channels: if str(chan.type).lower() == 'text': if check_write(user_q, chan): await cmd.bot.edit_channel_permissions( chan, user_q, overwrite) await cmd.bot.send_message( message.channel, 'Execution Successful.\nUser **' + user_q.name + '** was muted') except Exception as e: cmd.log.error(e) await cmd.bot.send_message(message.channel, str(e)) else: response = await cmd.bot.send_message( message.channel, 'Only a user with the **Manage Messages and Manage Roles** privilege can use this command. :x:' ) await asyncio.sleep(10) await cmd.bot.delete_message(response)