nick
nick

Reputation: 25

discord.ext.commands.errors.CommandInvokeError: TypeError: ban() got an unexpected keyword argument 'reason'

I have seen other bots use the =reason argument in ban() but it doesn't work for me. I want the reason to show up in Discord's server logs (in the ban list) rather than mine. Example code:

@client.command(pass_context=True)
async def ban(ctx, member: discord.Member, banreason: str):
await client.ban(member, delete_message_days=7, reason=banreason)

Upvotes: 0

Views: 878

Answers (2)

FoxInFlame
FoxInFlame

Reputation: 950

It looks like the reason parameter is only supported on Discord.py v1.0. The entire library has been rewritten, and that's essentially the newest version.

Unfortunately, the syntax has changed a lot (functions moved from Client to states, etc), but if you have the time, rewriting your bot to 1.0 would be the best option.

Here's the related Github issue. And here's the rewritten API docs for 1.0.

Upvotes: 1

Benjin
Benjin

Reputation: 3497

client.ban does not have a reason parameter when using the latest release of discord.py, see documentation: http://discordpy.readthedocs.io/en/latest/api.html#discord.Client.ban

However, the rewrite branch does contain the reason parameter. http://discordpy.readthedocs.io/en/rewrite/api.html#discord.Guild.ban

Upvotes: 1

Related Questions