discord.py:: massban命令未正确禁止并发送嵌入消息



每当我在VSC中运行代码时,我在终端中没有得到任何错误,所以我不知道从这里去哪里。

当我运行命令时,它应该是!massban。在执行此操作时,它应该检查以确保用户是否在服务器中,并检查以确保给出了原因。之后,它应该向用户发送一个嵌入消息,告诉他们他们被封禁的原因,同时发送另一个嵌入到日志通道,以显示谁对用户进行了操作和原因。最后,用户将被封禁,同时显示有多少封禁成功/有多少封禁失败。

不幸的是,在使用此命令时,它不会检查成员是否在服务器中,也不会检查是否包含原因。它只会禁止第一个给定的ID,不发送嵌入消息给用户,只发送一个日志到mod日志通道,没有说有多少成功的禁令/有多少失败。(我使用所有帐户进行测试,他们都有能力从我的服务器接收消息。)

这是我的代码:

@client.command()
@commands.has_any_role("Head Honcho", "Discord Moderator")
async def massban(ctx, member : commands.Greedy[discord.Member], *, reason: Optional[str]):
if member is None:
return await ctx.send("This member could not be found, or you did not provide an ID.")
if reason is None:
return await ctx.send("Please provide a reason for banning this user.")

success = 0
failures = 0
for user in member:
try:
embed = discord.Embed(title = "You have been **banned** from 🎊 Cold's Jamboree 🎉" , description = "A moderator has banned you regarding your behavior." , color = discord.Color.from_rgb(204,0,0))
embed.add_field(name = "Reason:", value = "{reason}".format(reason=reason) , inline = True )
embed.set_thumbnail(url=ctx.guild.icon_url)
try:
await member.send(embed=embed)
await ctx.guild.ban(user, delete_message_days=1)
except discord.HTTPException:
pass
success +=1
except discord.HTTPException:
failures +=1
finally:
channel = client.get_channel(820100484358471701)
embed = discord.Embed(title = f"", description = "**[🔨] A 'mass ban' has been issued.**", color = discord.Color.from_rgb(204,0,0), timestamp = ctx.message.created_at)
embed.add_field(name = f" `{ctx.author.name}` has banned `{user.name}`.nnReason:", value = "{reason}".format(reason=reason))
embed.set_author(name = f"{user} ({user.id})", icon_url = user.avatar_url)
embed.set_footer(icon_url = ctx.author.avatar_url, text = "Modlog created ")
try:
await channel.send(embed=embed)
except discord.HTTPException:
pass
if ctx.channel.id == 805651955841236993:
reaction_emote = ("<:Checkmark:820467149554319410>")
await ctx.message.add_reaction(reaction_emote)
await ctx.send("Massbanned " + str(success) + " members.n{}".format(f"Failed {failures} members." if failures else ""))
如果有人能帮助我,我将非常感激。VSC没有给我任何错误,我很困惑,因为它应该工作。

你不应该这样做,discord讨厌人们这样做,因为很难区分这是nuking(人们制造机器人来禁止每个人),或者如果它是真实的,所以大多数时候他们会阻止它,如果它不是延迟像10秒或真的很慢。

最新更新