1{ lib
2, aiohttp
3, buildPythonPackage
4, fetchFromGitHub
5, libopus
6, pynacl
7, pythonOlder
8, withVoice ? true
9}:
10
11buildPythonPackage rec {
12 pname = "discord.py";
13 version = "1.7.3";
14 disabled = pythonOlder "3.8";
15
16 src = fetchFromGitHub {
17 owner = "Rapptz";
18 repo = pname;
19 rev = "v${version}";
20 sha256 = "sha256-eKXCzGFSzxpdZed4/4G6uJ96s5yCm6ci8K8XYR1zQlE=";
21 };
22
23 propagatedBuildInputs = [
24 aiohttp
25 ] ++ lib.optionalString withVoice [
26 libopus
27 pynacl
28 ];
29
30 patchPhase = ''
31 substituteInPlace "discord/opus.py" \
32 --replace "ctypes.util.find_library('opus')" "'${libopus}/lib/libopus.so.0'"
33 '';
34
35 # Only have integration tests with discord
36 doCheck = false;
37
38 pythonImportsCheck = [
39 "discord"
40 "discord.file"
41 "discord.member"
42 "discord.user"
43 "discord.state"
44 "discord.guild"
45 "discord.webhook"
46 "discord.ext.commands.bot"
47 ];
48
49 meta = with lib; {
50 description = "Python wrapper for the Discord API";
51 homepage = "https://discordpy.rtfd.org/";
52 maintainers = [ maintainers.ivar ];
53 license = licenses.mit;
54 };
55}