Reputation: 115
I am trying to get this part of my code to create a channel and add the user to the channel to see and type but can't post images.
elif str(reaction) == "❔":
remove_id(member.id)
guild=member.guild
overwrites = {
guild.member: discord.PermissionOverwrite(read_messages=False)
}
category = discord.utils.get(guild.categories, name='application')
channel = await guild.create_text_channel(f'{member.name}-interview', category=category, overwrites=overwrites)
channel_name = discord.utils.get(member.guild.channels, name=channel)
channel_id = channel.id
view_channel = member.guild.get_channel(channel_id)
embed1=discord.Embed(title="Verification Request", description=f"Verification request of {member.mention}", color=int(hex_color, 16))
embed1.set_thumbnail(url=member.avatar_url)
embed1.add_field(name="How did you find this server?", value=found, inline=False)
embed1.add_field(name="How old are you?", value=age, inline=False)
embed1.add_field(name="Tell us about yourself?", value=about, inline=False)
embed1.add_field(name="What are you looking to get out of this server?", value=seek, inline=False)
embed1.set_author(name=member.name)
embed1.set_footer(text=f"User ID: {member.id}")
The error I get is:
Ignoring exception in raw_reactian_add
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-package/discord/client.py", line 312, in _run_event
await coro(•args, ••kwargs)
File "root/Treehouse/cogs/verification.py", line 273, in on_raw_reaction_add
guild.member: discord.PernissionOvervrite(read_nessages=False)
AttributeError: 'Guild' object has no attribute 'member'
I am struggling to add the member to the channel and set the permissions to send_messages=True, read_message=true, and post_images=False
Upvotes: 1
Views: 606
Reputation: 2907
You should have a look at the valid permissions as post_images
is attach_files
.
create_text_channel states the overwrites are
A dict of target (either a role or a member) to PermissionOverwrite to apply upon creation of a channel. Useful for creating secret channels.
guild.member does not exist because guild is a Guild object. Use member
instead as stated by the quote.
elif str(reaction) == "❔":
remove_id(member.id)
guild=member.guild
overwrites = {
member: discord.PermissionOverwrite(read_messages=True, send_messages = True, attach_files = True)
}
category = discord.utils.get(guild.categories, name='application')
channel = await guild.create_text_channel(f'{member.name}-interview', category=category, overwrites=overwrites)
channel_name = discord.utils.get(member.guild.channels, name=channel)
channel_id = channel.id
view_channel = member.guild.get_channel(channel_id)
embed1=discord.Embed(title="Verification Request", description=f"Verification request of {member.mention}", color=int(hex_color, 16))
embed1.set_thumbnail(url=member.avatar_url)
embed1.add_field(name="How did you find this server?", value=found, inline=False)
embed1.add_field(name="How old are you?", value=age, inline=False)
embed1.add_field(name="Tell us about yourself?", value=about, inline=False)
embed1.add_field(name="What are you looking to get out of this server?", value=seek, inline=False)
embed1.set_author(name=member.name)
embed1.set_footer(text=f"User ID: {member.id}")
Upvotes: 1