spectra1duke387
spectra1duke387

Reputation: 1

discord.ext.commands.errors.CommandInvokeError Command raised an exception: NameError: name 'self' is not defined

I am making a bot that mutes people when they join a vc. However, when I run the following code I receive an error about 'self' not being defined. How would I fix this?

async def join(ctx, *, member=discord.Member):
    channel = ctx.author.voice.channel
    await channel.connect()
    await member.edit(mute=True)

Upvotes: 0

Views: 1342

Answers (1)

Jawad
Jawad

Reputation: 2041

If you're inside a Class/Cog you need to pass self as the first parameter.

async def join(self, ctx, *, member=discord.Member):
    channel = ctx.author.voice.channel
    await channel.connect()
    await member.edit(mute=True)

Upvotes: 1

Related Questions