可以关闭门票频道

发布于 2025-02-09 21:57:47 字数 1008 浏览 0 评论 0原文

我正在使用discord.ext.slash为我的票务机器人创建一个密切的斜杠命令,这不会关闭我认为应该应该的频道。谢谢!

@client.slash_cmd()
async def close(ctx: slash.Context):
    """Closes the ticket"""
    await ctx.delete()

编辑: 运行此命令时,我会得到

  File "/home/runner/Ticket-Bot/venv/lib/python3.8/site-packages/discord/ext/slash/__init__.py", line 1371, in on_interaction_create
    raise commands.CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10015): Unknown Webhook

,然后尝试使用ctx.channel.delete()而不是ctx.delete()时,我得到了

Traceback (most recent call last):
  File "/home/runner/Ticket-Bot/venv/lib/python3.8/site-packages/discord/ext/slash/__init__.py", line 1371, in on_interaction_create
    raise commands.CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Object' object has no attribute 'delete'

I'm using discord.ext.slash to create a close slash command for my ticket bot and this won't close the channel which I think it should. Thanks!

@client.slash_cmd()
async def close(ctx: slash.Context):
    """Closes the ticket"""
    await ctx.delete()

Edit:
When running this command, I get

  File "/home/runner/Ticket-Bot/venv/lib/python3.8/site-packages/discord/ext/slash/__init__.py", line 1371, in on_interaction_create
    raise commands.CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10015): Unknown Webhook

And then when I try to use ctx.channel.delete() instead of ctx.delete(), I get

Traceback (most recent call last):
  File "/home/runner/Ticket-Bot/venv/lib/python3.8/site-packages/discord/ext/slash/__init__.py", line 1371, in on_interaction_create
    raise commands.CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Object' object has no attribute 'delete'

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

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

发布评论

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

评论(1

意中人 2025-02-16 21:57:47

解决。我刚刚使该机器人在频道中发送消息,然后使用on_message来关注该消息,然后关闭频道。我知道这不是这样做的专业方式,但它是有效的。

Resolved. I Just made the bot send a message in the channel and then used on_message to watch for that message and then close the channel. I know it's not a professional way to do this but it works so.

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