问题标签 [discord.py]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
13141 浏览

python - 获取用户语音通道id

我有以下功能:

我的问题是,如何获取键入命令的用户的语音通道 ID。我知道如何获取服务器 ID,但我在文档中找不到如何获取语音通道 ID。谢谢!

0 投票
2 回答
6581 浏览

python - 无法在 Linux 上的 python 3.6 中 pip install discord.py

我在将discord.py包安装到 python 3.6 时遇到问题。我以前安装过它,但是在我的另一台装有 python 3.4 的 PC 上。

我正在使用的命令如下:

我收到一个看起来像这样的错误,但我不确定它应该是什么意思。该库与 python 3.6 不兼容,还是我做错了什么?如果它相当明显,请原谅我;我是 python 新手。

0 投票
1 回答
207 浏览

python - 编写递归随机变量的更好方法

我知道这真的很糟糕,但它确实有效,而且这是我目前的知识完成这项工作的唯一方法。所以我在实践中寻找一种“更好”的方式来写这个。

基本上它显示了 3 个图像插槽,而这 3 个插槽将图像更改为中列出的随机图像SLOT_PATTERN。图像更改edit_message用于编辑之前的 3 个插槽图像,将它们替换为给定列表中的随机图像。

0 投票
2 回答
1358 浏览

python - 如何匹配精确字符串和通配符字符串

比如说我有这个:

我想做两件事:

1) 使当且仅当用户准确 输入且没有其他内容时,它才会在频道中!test打印出来test

2)如果用户!test首先输入一个空格和至少一个其他字符串字符,它将打印出来test- 例如:a)!test不会打印出任何东西,b)!test !test后跟一个空格) 不会打印出任何东西,c)!test1不会打印出任何东西,d)!testabc不会打印出任何东西,但是 e)!test 1会打印出test,f)!test 123abc会打印出test,g)!test a会打印出test,h)!test ?!abc123会打印出test等等.

我只知道startswithand endswith,据我的研究表明,没有exactand 我不知道如何制作它,因此它在 a 之后需要最少数量的字符startswith

0 投票
1 回答
433 浏览

python - 不知道为什么 `asyncio.Lock` 不起作用

因此,它的作用是,每当有人在聊天室频道中键入命令时!test,它就会将以下适当的字符串打印到聊天频道中。但是,我希望命令一次只使用一次,所以我想锁定命令直到它完成:

但是我收到一个错误NameError: name 'Lock' is not defined,即使我确实将其定义为lock = Lock().

0 投票
2 回答
757 浏览

python - How to stop infinite loop with the same trigger that starts it?

So I have something like this:

What it does is, if someone types in !test into a chat channel, the script will delete that !test message, then send a message into the chat that says the person's name followed by the text test1. Then the script will edit that message to say test2 after a second, then it will edit that same message to say test1, then again to test2, etc., etc. forever.

However, I want to make it so that if another user types in the same command !test again, the script immediately will stop for the user for whom it was previously activated for, and start doing it for the most recent user who issued the command. The lines that I commented out is my attempts at trying to achieve this. How can do I do this?

0 投票
1 回答
585 浏览

python - Discord 创建角色 404 Not Found 错误

当我尝试:

我收到此错误:

有谁知道我如何获得有关此错误的更多信息?

0 投票
1 回答
228 浏览

python - 如何在不同功能之间共享对象

我正在尝试这样做,以便如果用户激活test,它将在聊天室中显示一个测试菜单,如果同一用户对任何消息发表反应,它将删除该测试菜单:

但是,代码不会像其他函数一样读取对象message.authormenu从其他函数读取对象。

0 投票
1 回答
150 浏览

python - 如何使 pyodbc 输出更具可读性/更好?

我目前正在制作一个不和谐的机器人,其中一个命令涉及从 SQL 表中提取数据,为此我使用的是 AioOdbc 模块,它与 Pyodbc 几乎完全相同,唯一真正的区别是它没有t 阻塞异步函数。

以这种格式输出。

我怎样才能让它输出一些更好读的东西?可能像

任何帮助表示赞赏!

0 投票
1 回答
9334 浏览

python - 如何使用 client.send_file discord.py

我使用了它,我得到了错误代码 401 aka Unauthorized

我正在使用它来登录我所有其他命令都可以工作并且不输出此错误。-我对这个网站很陌生,所以我可能做错了什么-