Search code examples
discorddiscord.py

Discord.py Member "<@userid>" not found. Error


It's just part of a command

@client.command()
@commands.has_permissions(manage_roles=True)
async def rstaff(self,ctx,member:discord.Member,role:discord.Role):
    admin = ctx.author
    chanel= self.bot.get_channel(1080557591899406366)
    lembed = discord.Embed(title="✅Administrator Log", description=f"**
Remove Stuff Command Used**\nAdmin:{admin.mention}\nUser:{member.name}\n
Authorization received:{role.mention}", colour=discord.Colour.green())
    embed = discord.Embed(title="✅Administrator", description=f"{member.mention} 
From {role.mention} authorization received. Admin:{admin.mention}",colour=discord.Colour.green())
    await member.remove_roles(role)
    await ctx.send(embed=embed)
    await chanel.send(embed=lembed)

chanel= ctx.self.bot.get_channel(1080557591899406366)

"Error: self is a required argument that is missing."

I change it

chanel= self.bot.get_channel(1080557591899406366)

"Error: Member<@&777487631889072138>" not found."

I added it to the beginning of the substructure

@client.event
async def on_ready(self):
    await self.client.wait_until_ready()
    self.server = self.client.get_guild(client.server_id)

Solution

  • You command stands alone and is not in a class so there is no self. Simply, remove self and read up on commands.Context.

    @client.command()
    @commands.has_permissions(manage_roles = True)
    async def rstaff(ctx, member: discord.Member, role: discord.Role):
        admin = ctx.author
        chanel = bot.get_channel(1080557591899406366)
        lembed = discord.Embed(...)
        embed = discord.Embed(...)
        await member.remove_roles(role)
        await ctx.send(embed=embed)
        await chanel.send(embed=lembed)
    

    Documentation: commands.Bot, get_channel()