Search code examples
pythonpython-3.xdiscord.pyembedreplit

How to use Discord Permission on Create Embed Command?


How can I use this?

if (not ctx.author.guild_permissions.manage_messages):
    await ctx.send("Please ask a Supporter")
    return

for this:

@bot.command()
async def cembed(ctx):
    def check(message):
        return message.author == ctx.author and message.channel == ctx.channel

    await ctx.send('Title?', delete_after=5)
    title = await bot.wait_for('message', check=check)
  
    await ctx.send('Description?', delete_after=5)
    desc = await bot.wait_for('message', check=check)

    embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.from_rgb(255,0,0))
    await ctx.send(embed=embed)

I already used the permission code once in a muting command but I am not sure where I need to put it in this code if you answer this please explain why I need to put it there.


Solution

  • like that:

    @bot.command()
    async def cembed(ctx):
       if (not ctx.author.guild_permissions.manage_messages):
        await ctx.send("Please ask a Supporter")
        return
        def check(message):
            return message.author == ctx.author and message.channel == ctx.channel
    
        await ctx.send('Title?', delete_after=5)
        title = await bot.wait_for('message', check=check)
      
        await ctx.send('Description?', delete_after=5)
        desc = await bot.wait_for('message', check=check)
    
        embed = discord.Embed(title=title.content, description=desc.content, color=discord.Color.from_rgb(255,0,0))
        await ctx.send(embed=embed)