G
G
Goshujin2021-02-07 13:05:50
Python
Goshujin, 2021-02-07 13:05:50

Error in Discord.py bot command?

@Bot.command()
TypeError: command() missing 1 required positional argument: 'self'.
Tell me how to fix the error, code:

@Bot.command()
@commands.has_permissions(administrator = True)
async def mute(ctx, member: discord.Member, time: int, reason):
    await ctx.channel.purge(limit = 1)
    muterole = discord.utils.get(ctx.guild.roles, id = 807889764539826216)
    emb = discord.Embed(title = "Mute", color = "ff0d0d")
    emb.add_field(name = "Administrator", value = ctx.message.author.mention, inline = False)
    emb.add_field(name = "User", value = member.mention, inline = False)
    emb.add_field(name = "Reason", value = reason, inline = False)
    emb.add_field(name = "Time", value = time, inline = False)
    await member.add_roles(muterole)
    await ctx.send(embed = emb)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2021-02-07
@Goshujin

You are trying to call a method commandon a class, not on an object.
Most likely, at the moment you have:

from discord.ext.commands import Bot

@Bot.command()
async def cmd(...):
    ...

What do you really want:
from discord.ext.commands import Bot

bot = Bot(...)

@bot.command()
async def cmd(...)
    ...

W
wz, 2021-02-07
@rensly

@bot.command( pass_context = True )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question