刚开始时遇到了一个问题

mwyxok5s  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(214)

这是代码,不确定我做错了什么,但我得到了这个错误
回溯(最近一次调用):文件“main.py”,第23行,在@client.commands()typeerror中:“set”对象不可调用

import discord
import random
import os
from discord.ext import commands

my_secret = os.environ['Token']

client = commands.Bot(command_prefix = '?')

@client.event
async def on_ready():
  print('Bot is ready.')

@client.command()
async def   kick(ctx, member : discord.Member, *, reason=None):
  await member.kick(reason=reason)

@client.command()
async def   ban(ctx, member : discord.Member, *, reason=None):
  await member.ban(reason=reason)
  await ctx.send(f'Banned {member.mention}')

@client.commands()
async def unban(ctx, *, member):
  banned_users = await ctx.guild.bans()
  member_name, member_discriminator = member.split('#')

  for ban_entry in banned_users:
      user = ban_entry.user

      if (user.name, user.discriminator) == (member_name, member_discriminator):
          await ctx.guild.unban(user)
          await ctx.send(f'Unbanned {user.mention}')
          return

client.run(os.environ['Token'])
deyfvvtc

deyfvvtc1#

这本书似乎有错

@client.commands()
async def unban(ctx, *, member):

应该是

@client.command()
async def unban(ctx, *, member):

相关问题