高级不和谐禁令命令

发布于 2025-01-23 22:19:29 字数 180 浏览 0 评论 0原文

我需要一个禁止命令,该命令禁止成员,而不是DMS被禁止的成员通知他们以及何时发生。 我有一些问题:

  1. 如果关闭用户的DMS怎么办?
  2. 这不是被禁止的成员。
  3. 还包括一个像``!禁令)这样的禁令了,

如果有人可以帮助我,那将是很棒的,我将大力对它进行攻击。 谢谢!

i need a ban command that bans a member and than dms the banned member to inform them about it and when it happened.
I have a few problems:

  1. What if the user's dms are closed?
  2. It is not dming the banned member.
  3. Also includes a perm ban like `!Ban

If anyone can help me out that will be great and i will greatly appricate it.
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

为人所爱 2025-01-30 22:19:29

像您想要的一样,这是简单BAN discord.py的示例,

@client.command()
async def ban(ctx, member:discord.Member, *, reason=None)
    await member.ban
    await member.send(f"You've been banned by {ctx.author}\nReason = {reason}")

如果您要寻找.cogs版本,

@commands.command()
async def ban(self, ctx, member:discord.Member, *, reason = None)
    await member.ban
    await member.send(f"You've been banned by {ctx.author}\nReason = {reason}") ##this send message by DMs for banned member to tell him/her why getting banned

如果您使用Discord-py- Slash-Command您可以创建新问题

Like you want, this is example of simple ban member for discord.py

@client.command()
async def ban(ctx, member:discord.Member, *, reason=None)
    await member.ban
    await member.send(f"You've been banned by {ctx.author}\nReason = {reason}")

If you looking for .cogs version

@commands.command()
async def ban(self, ctx, member:discord.Member, *, reason = None)
    await member.ban
    await member.send(f"You've been banned by {ctx.author}\nReason = {reason}") ##this send message by DMs for banned member to tell him/her why getting banned

If you using discord-py-slash-command you can create new question

千秋岁 2025-01-30 22:19:29

对于1:

 尝试:
     等待user.Send(“ msg”)
除了discord.errors.forbidden:
     代码在这里
 

我不知道这是否可以帮助您

for the 1:

try:
     await user.send("msg")
except discord.errors.Forbidden:
     code here

I don't know if this can help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文