Mono-Doc¶
This file holds the entire API reference in a single page; should that be your preference.
Clients¶
Client
¶
Bases: processors.AutoModEvents
, processors.ChannelEvents
, processors.EntitlementEvents
, processors.GuildEvents
, processors.IntegrationEvents
, processors.MemberEvents
, processors.MessageEvents
, processors.ReactionEvents
, processors.RoleEvents
, processors.ScheduledEvents
, processors.StageEvents
, processors.ThreadEvents
, processors.UserEvents
, processors.VoiceEvents
The bot client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intents | Union[int, Intents] | The intents to use | Intents.DEFAULT |
status | Status | The status the bot should log in with (IE ONLINE, DND, IDLE) | Status.ONLINE |
activity | Union[Activity, str] | The activity the bot should log in "playing" | None |
sync_interactions | bool | Should application commands be synced with discord? | True |
delete_unused_application_cmds | bool | Delete any commands from discord that aren't implemented in this client | False |
enforce_interaction_perms | bool | Enforce discord application command permissions, locally | True |
fetch_members | bool | Should the client fetch members from guilds upon startup (this will delay the client being ready) | False |
send_command_tracebacks | bool | Automatically send uncaught tracebacks if a command throws an exception | True |
send_not_ready_messages | bool | Send a message to the user if they try to use a command before the client is ready | False |
auto_defer | Absent[Union[AutoDefer, bool]] | | MISSING |
interaction_context | Type[InteractionContext] | Type[InteractionContext]: InteractionContext: The object to instantiate for Interaction Context | InteractionContext |
component_context | Type[BaseContext] | Type[ComponentContext]: The object to instantiate for Component Context | ComponentContext |
autocomplete_context | Type[BaseContext] | Type[AutocompleteContext]: The object to instantiate for Autocomplete Context | AutocompleteContext |
modal_context | Type[BaseContext] | Type[ModalContext]: The object to instantiate for Modal Context | ModalContext |
total_shards | int | The total number of shards in use | 1 |
shard_id | int | The zero based int ID of this shard | 0 |
debug_scope | Absent[Snowflake_Type] | Force all application commands to be registered within this scope | MISSING |
disable_dm_commands | bool | Should interaction commands be disabled in DMs? | False |
basic_logging | bool | Utilise basic logging to output library data to console. Do not use in combination with | False |
logging_level | int | The level of logging to use for basic_logging. Do not use in combination with | logging.INFO |
logger | logging.Logger | The logger interactions.py should use. Do not use in combination with | MISSING |
proxy | A http/https proxy to use for all requests | required | |
proxy_auth | BasicAuth | tuple[str, str] | None | The auth to use for the proxy - must be either a tuple of (username, password) or aiohttp.BasicAuth | None |
Optionally, you can configure the caches here, by specifying the name of the cache, followed by a dict-style object to use. It is recommended to use smart_cache.create_cache
to configure the cache here. as an example, this is a recommended attribute message_cache=create_cache(250, 50)
,
Intents Note
By default, all non-privileged intents will be enabled
Caching Note
Setting a message cache hard limit to None is not recommended, as it could result in extremely high memory usage, we suggest a sane limit.
Source code in interactions/client/client.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 |
|
activity: Activity
property
¶
Get the activity of the bot.
app: Application
property
¶
Returns the bots application.
application_commands: List[InteractionCommand]
property
¶
A list of all application commands registered within the bot.
async_startup_tasks: list[tuple[Callable[..., Coroutine], Iterable[Any], dict[str, Any]]] = []
instance-attribute
¶
A list of coroutines to run during startup
auto_defer = auto_defer
instance-attribute
¶
A system to automatically defer commands after a set duration
autocomplete_context: Type[BaseContext[Self]] = autocomplete_context
instance-attribute
¶
The object to instantiate for Autocomplete Context
average_latency: float
property
¶
Returns the average latency of the websocket connection (seconds).
component_context: Type[BaseContext[Self]] = component_context
instance-attribute
¶
The object to instantiate for Component Context
context_menu_context: Type[BaseContext[Self]] = context_menu_context
instance-attribute
¶
The object to instantiate for Context Menu Context
debug_scope = to_snowflake(debug_scope) if debug_scope is not MISSING else MISSING
instance-attribute
¶
Sync global commands as guild for quicker command updates during debug
del_unused_app_cmd: bool = delete_unused_application_cmds
instance-attribute
¶
Should unused application commands be deleted?
ext: Dict[str, Extension] = {}
instance-attribute
¶
A dictionary of mounted ext
fetch_members = fetch_members
instance-attribute
¶
Fetch the full members list of all guilds on startup
gateway_started: bool
property
¶
Returns if the gateway has been started.
guild_event_timeout = 3
instance-attribute
¶
How long to wait for guilds to be cached
guilds: List[Guild]
property
¶
Returns a list of all guilds the bot is in.
http: HTTPClient = HTTPClient(logger=self.logger, show_ratelimit_tracebacks=show_ratelimit_tracebacks, proxy=proxy)
instance-attribute
¶
The HTTP client to use when interacting with discord endpoints
interaction_context: Type[BaseContext[Self]] = interaction_context
instance-attribute
¶
The object to instantiate for Interaction Context
interaction_tree: Dict[Snowflake_Type, Dict[str, InteractionCommand | Dict[str, InteractionCommand]]] = {}
instance-attribute
¶
A dictionary of registered application commands in a tree
interactions_by_scope: Dict[Snowflake_Type, Dict[str, InteractionCommand]] = {}
instance-attribute
¶
A dictionary of registered application commands: {scope: [commands]}
is_closed: bool
property
¶
Returns True if the bot has closed.
is_ready: bool
property
¶
Returns True if the bot is ready.
latency: float
property
¶
Returns the latency of the websocket connection (seconds).
logger = logger
instance-attribute
¶
The logger interactions.py should use. Do not use in combination with Client.basic_logging
and Client.logging_level
.
Note
Different loggers with multiple clients are not supported
modal_context: Type[BaseContext[Self]] = modal_context
instance-attribute
¶
The object to instantiate for Modal Context
owner: Optional[User]
property
¶
Returns the bot's owner'.
owners: List[User]
property
¶
Returns the bot's owners as declared via client.owner_ids
.
send_command_tracebacks: bool = send_command_tracebacks
instance-attribute
¶
Should the traceback of command errors be sent in reply to the command invocation
send_not_ready_messages: bool = send_not_ready_messages
instance-attribute
¶
Should the bot send a message when it is not ready yet in response to a command invocation
slash_context: Type[BaseContext[Self]] = slash_context
instance-attribute
¶
The object to instantiate for Slash Context
start_time: datetime
property
¶
The start time of the bot.
status: Status
property
¶
Get the status of the bot.
IE online, afk, dnd
sync_ext: bool = sync_ext
instance-attribute
¶
Should we sync whenever a extension is (un)loaded
sync_interactions: bool = sync_interactions
instance-attribute
¶
Should application commands be synced
user: ClientUser
property
¶
Returns the bot's user.
ws: GatewayClient
property
¶
Returns the websocket client.
__load_module(module, module_name, **load_kwargs)
¶
Internal method that handles loading a module.
Source code in interactions/client/client.py
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 |
|
add_command(func)
¶
Add a command to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func | Callable | The command to add | required |
Source code in interactions/client/client.py
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 |
|
add_component_callback(command)
¶
Add a component callback to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | ComponentCommand | The command to add | required |
Source code in interactions/client/client.py
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 |
|
add_event_processor(event_name=MISSING)
¶
A decorator to be used to add event processors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name | Absent[str] | The event name to use, if not the coroutine name | MISSING |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], AsyncCallable] | A function that can be used to hook into the event. |
Source code in interactions/client/client.py
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 |
|
add_global_autocomplete(callback)
¶
Add a global autocomplete to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
callback | GlobalAutoComplete | The autocomplete to add | required |
Source code in interactions/client/client.py
1461 1462 1463 1464 1465 1466 1467 1468 1469 |
|
add_interaction(command)
¶
Add a slash command to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | InteractionCommand | The command to add | required |
Source code in interactions/client/client.py
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
|
add_listener(listener)
¶
Add a listener for an event, if no event is passed, one is determined.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listener | Listener | The listener to add to the client | required |
Source code in interactions/client/client.py
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 |
|
add_modal_callback(command)
¶
Add a modal callback to the client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command | ModalCommand | The command to add | required |
Source code in interactions/client/client.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 |
|
astart(token=None)
async
¶
Asynchronous method to start the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | str | None | Your bot's token | None |
Source code in interactions/client/client.py
956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 |
|
change_presence(status=Status.ONLINE, activity=None)
async
¶
Change the bots presence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status | Optional[Union[str, Status]] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Optional[Union[Activity, str]] | The activity for the bot to be displayed as doing. | None |
Note
Bots may only be playing
streaming
listening
watching
competing
or custom
Source code in interactions/client/client.py
2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 |
|
command(*args, **kwargs)
¶
A decorator that registers a command. Aliases interactions.slash_command
Source code in interactions/client/client.py
1261 1262 1263 1264 1265 |
|
connect_to_vc(guild_id, channel_id, muted=False, deafened=False)
async
¶
Connect the bot to a voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | id of the guild the voice channel is in. | required |
channel_id | Snowflake_Type | id of the voice channel client wants to join. | required |
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
Type | Description |
---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in interactions/client/client.py
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 |
|
consume_entitlement(entitlement_id)
async
¶
For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entitlement_id | Snowflake_Type | The ID of the entitlement to consume. | required |
Source code in interactions/client/client.py
2656 2657 2658 2659 2660 2661 2662 2663 2664 |
|
create_guild_from_template(template_code, name, icon=MISSING)
async
¶
Creates a new guild based on a template.
Note
This endpoint can only be used by bots in less than 10 guilds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template_code | Union[GuildTemplate, str] | The code of the template to use. | required |
name | str | The name of the guild (2-100 characters) | required |
icon | Absent[UPLOADABLE_TYPE] | Location or File of icon to set | MISSING |
Returns:
Type | Description |
---|---|
Optional[Guild] | The newly created guild object |
Source code in interactions/client/client.py
2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 |
|
create_test_entitlement(sku_id, owner_id, owner_type)
async
¶
Create a test entitlement for the bot's application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sku_id | Snowflake_Type | The ID of the SKU to create the entitlement for. | required |
owner_id | Snowflake_Type | The ID of the owner of the entitlement. | required |
owner_type | int | The type of the owner of the entitlement. 1 for a guild subscription, 2 for a user subscription | required |
Returns:
Type | Description |
---|---|
Entitlement | The created entitlement. |
Source code in interactions/client/client.py
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 |
|
default_error_handler(source, error)
staticmethod
¶
The default error logging behaviour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source | str | The source of this error | required |
error | BaseException | The exception itself | required |
Source code in interactions/client/client.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
|
delete_test_entitlement(entitlement_id)
async
¶
Delete a test entitlement for the bot's application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entitlement_id | Snowflake_Type | The ID of the entitlement to delete. | required |
Source code in interactions/client/client.py
2646 2647 2648 2649 2650 2651 2652 2653 2654 |
|
dispatch(event, *args, **kwargs)
¶
Dispatch an event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event | events.BaseEvent | The event to be dispatched. | required |
Source code in interactions/client/client.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 |
|
fetch_channel(channel_id, *, force=False)
async
¶
Fetch a channel.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
force | bool | Whether to poll the API regardless of cache | False |
Returns:
Type | Description |
---|---|
Optional[TYPE_ALL_CHANNEL] | Channel Object if found, otherwise None |
Source code in interactions/client/client.py
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 |
|
fetch_custom_emoji(emoji_id, guild_id, *, force=False)
async
¶
Fetch a custom emoji by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji_id | Snowflake_Type | The id of the custom emoji. | required |
guild_id | Snowflake_Type | The id of the guild the emoji belongs to. | required |
force | bool | Whether to poll the API regardless of cache. | False |
Returns:
Type | Description |
---|---|
Optional[CustomEmoji] | The custom emoji if found, otherwise None. |
Source code in interactions/client/client.py
2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 |
|
fetch_entitlements(*, user_id=None, sku_ids=None, before=None, after=None, limit=100, guild_id=None, exclude_ended=None)
async
¶
Fetch the entitlements for the bot's application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Optional[Snowflake_Type] | The ID of the user to filter entitlements by. | None |
sku_ids | Optional[list[Snowflake_Type]] | The IDs of the SKUs to filter entitlements by. | None |
before | Optional[Snowflake_Type] | Get entitlements before this ID. | None |
after | Optional[Snowflake_Type] | Get entitlements after this ID. | None |
limit | Optional[int] | The maximum number of entitlements to return. Maximum is 100. | 100 |
guild_id | Optional[Snowflake_Type] | The ID of the guild to filter entitlements by. | None |
exclude_ended | Optional[bool] | Whether to exclude ended entitlements. | None |
Returns:
Type | Description |
---|---|
List[Entitlement] | A list of entitlements. |
Source code in interactions/client/client.py
2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 |
|
fetch_guild(guild_id, *, force=False)
async
¶
Fetch a guild.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get | required |
force | bool | Whether to poll the API regardless of cache | False |
Returns:
Type | Description |
---|---|
Optional[Guild] | Guild Object if found, otherwise None |
Source code in interactions/client/client.py
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 |
|
fetch_member(user_id, guild_id, *, force=False)
async
¶
Fetch a member from a guild.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Snowflake_Type | The ID of the member | required |
guild_id | Snowflake_Type | The ID of the guild to get the member from | required |
force | bool | Whether to poll the API regardless of cache | False |
Returns:
Type | Description |
---|---|
Optional[Member] | Member object if found, otherwise None |
Source code in interactions/client/client.py
2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 |
|
fetch_nitro_packs()
async
¶
List the sticker packs available to Nitro subscribers.
Returns:
Type | Description |
---|---|
Optional[List[StickerPack]] | A list of StickerPack objects if found, otherwise returns None |
Source code in interactions/client/client.py
2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 |
|
fetch_scheduled_event(guild_id, scheduled_event_id, with_user_count=False)
async
¶
Fetch a scheduled event by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get the scheduled event from | required |
scheduled_event_id | Snowflake_Type | The ID of the scheduled event to get | required |
with_user_count | bool | Whether to include the user count in the response | False |
Returns:
Type | Description |
---|---|
Optional[ScheduledEvent] | The scheduled event if found, otherwise None |
Source code in interactions/client/client.py
2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 |
|
fetch_sticker(sticker_id)
async
¶
Fetch a sticker by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sticker_id | Snowflake_Type | The ID of the sticker. | required |
Returns:
Type | Description |
---|---|
Optional[Sticker] | A sticker object if found, otherwise None |
Source code in interactions/client/client.py
2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 |
|
fetch_user(user_id, *, force=False)
async
¶
Fetch a user.
Note
This method is an alias for the cache which will either return a cached object, or query discord for the object if its not already cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Snowflake_Type | The ID of the user to get | required |
force | bool | Whether to poll the API regardless of cache | False |
Returns:
Type | Description |
---|---|
Optional[User] | User Object if found, otherwise None |
Source code in interactions/client/client.py
2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 |
|
fetch_voice_regions()
async
¶
List the voice regions available on Discord.
Returns:
Type | Description |
---|---|
List[VoiceRegion] | A list of voice regions. |
Source code in interactions/client/client.py
2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 |
|
get_application_cmd_by_id(cmd_id, *, scope=None)
¶
Get a application command from the internal cache by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd_id | Snowflake_Type | The ID of the command | required |
scope | Snowflake_Type | Optionally specify a scope to search in | None |
Returns:
Type | Description |
---|---|
Optional[InteractionCommand] | The command, if one with the given ID exists internally, otherwise None |
Source code in interactions/client/client.py
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 |
|
get_bot_voice_state(guild_id)
¶
Get the bot's voice state for a guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The target guild's id. | required |
Returns:
Type | Description |
---|---|
Optional[ActiveVoiceState] | The bot's voice state for the guild if connected, otherwise None. |
Source code in interactions/client/client.py
2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 |
|
get_channel(channel_id)
¶
Get a channel.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
Type | Description |
---|---|
Optional[TYPE_ALL_CHANNEL] | Channel Object if found, otherwise None |
Source code in interactions/client/client.py
2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 |
|
get_custom_emoji(emoji_id, guild_id=None)
¶
Get a custom emoji by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji_id | Snowflake_Type | The id of the custom emoji. | required |
guild_id | Optional[Snowflake_Type] | The id of the guild the emoji belongs to. | None |
Returns:
Type | Description |
---|---|
Optional[CustomEmoji] | The custom emoji if found, otherwise None. |
Source code in interactions/client/client.py
2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 |
|
get_ext(name)
¶
Get a extension with a name or extension name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the extension, or the name of it's extension | required |
Returns:
Type | Description |
---|---|
Extension | None | A extension, if found |
Source code in interactions/client/client.py
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 |
|
get_extensions(name)
¶
Get all ext with a name or extension name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the extension, or the name of it's extension | required |
Returns:
Type | Description |
---|---|
list[Extension] | List of Extensions |
Source code in interactions/client/client.py
2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 |
|
get_guild(guild_id)
¶
Get a guild.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild to get | required |
Returns:
Type | Description |
---|---|
Optional[Guild] | Guild Object if found, otherwise None |
Source code in interactions/client/client.py
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 |
|
get_member(user_id, guild_id)
¶
Get a member from a guild.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Snowflake_Type | The ID of the member | required |
guild_id | Snowflake_Type | The ID of the guild to get the member from | required |
Returns:
Type | Description |
---|---|
Optional[Member] | Member object if found, otherwise None |
Source code in interactions/client/client.py
2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 |
|
get_remote_commands(cmd_scope)
async
¶
Get the remote commands for a scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd_scope | Snowflake_Type | The scope to get the commands for. | required |
Source code in interactions/client/client.py
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 |
|
get_scheduled_event(scheduled_event_id)
¶
Get a scheduled event by id.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scheduled_event_id | Snowflake_Type | The ID of the scheduled event to get | required |
Returns:
Type | Description |
---|---|
Optional[ScheduledEvent] | The scheduled event if found, otherwise None |
Source code in interactions/client/client.py
2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 |
|
get_user(user_id)
¶
Get a user.
Note
This method is an alias for the cache which will return a cached object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Snowflake_Type | The ID of the user to get | required |
Returns:
Type | Description |
---|---|
Optional[User] | User Object if found, otherwise None |
Source code in interactions/client/client.py
2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 |
|
handle_pre_ready_response(data)
async
¶
Respond to an interaction that was received before the bot was ready.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | The interaction data | required |
Source code in interactions/client/client.py
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 |
|
listen(event_name=MISSING)
¶
A decorator to be used in situations that the library can't automatically hook your listeners. Ideally, the standard listen decorator should be used, not this.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name | Absent[str] | The event name to use, if not the coroutine name | MISSING |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], Listener] | A listener that can be used to hook into the event. |
Source code in interactions/client/client.py
1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 |
|
load_extension(name, package=None, **load_kwargs)
¶
Load an extension with given arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
**load_kwargs | Any | The auto-filled mapping of the load keyword arguments | {} |
Source code in interactions/client/client.py
2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 |
|
load_extensions(*packages, recursive=False, **load_kwargs)
¶
Load multiple extensions at once.
Removes the need of manually looping through the package and loading the extensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*packages | str | The package(s) where the extensions are located. | () |
recursive | bool | Whether to load extensions from the subdirectories within the package. | False |
Source code in interactions/client/client.py
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 |
|
login(token=None)
async
¶
Login to discord via http.
Note
You will need to run Client.start_gateway() before you start receiving gateway events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | str | Your bot's token | None |
Source code in interactions/client/client.py
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
|
mention_command(name, scope=0)
¶
Returns a string that would mention the interaction specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the interaction. | required |
scope | int | The scope of the interaction. Defaults to 0, the global scope. | 0 |
Returns:
Name | Type | Description |
---|---|---|
str | str | The interaction's mention in the specified scope. |
Source code in interactions/client/client.py
2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 |
|
on_autocomplete_completion(event)
async
¶
Called after any autocomplete callback is ran.
By default, it will simply log the autocomplete callback.
Listen to the AutocompleteCompletion
event to overwrite this behaviour.
Source code in interactions/client/client.py
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
|
on_autocomplete_error(event)
async
¶
Catches all errors dispatched by autocompletion options.
By default it will dispatch the Error
event.
Listen to the AutocompleteError
event to overwrite this behaviour.
Source code in interactions/client/client.py
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 |
|
on_command_completion(event)
async
¶
Called after any command is ran.
By default, it will simply log the command.
Listen to the CommandCompletion
event to overwrite this behaviour.
Source code in interactions/client/client.py
737 738 739 740 741 742 743 744 745 746 747 |
|
on_command_error(event)
async
¶
Catches all errors dispatched by commands.
By default it will dispatch the Error
event.
Listen to the CommandError
event to overwrite this behaviour.
Source code in interactions/client/client.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
|
on_component_completion(event)
async
¶
Called after any component callback is ran.
By default, it will simply log the component use.
Listen to the ComponentCompletion
event to overwrite this behaviour.
Source code in interactions/client/client.py
769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
|
on_component_error(event)
async
¶
Catches all errors dispatched by components.
By default it will dispatch the Error
event.
Listen to the ComponentError
event to overwrite this behaviour.
Source code in interactions/client/client.py
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
|
on_error(event)
async
¶
Catches all errors dispatched by the library.
By default it will format and print them to console.
Listen to the Error
event to overwrite this behaviour.
Source code in interactions/client/client.py
669 670 671 672 673 674 675 676 677 678 679 |
|
on_modal_completion(event)
async
¶
Called after any modal callback is ran.
By default, it will simply log the modal callback.
Listen to the ModalCompletion
event to overwrite this behaviour.
Source code in interactions/client/client.py
840 841 842 843 844 845 846 847 848 849 850 |
|
on_modal_error(event)
async
¶
Catches all errors dispatched by modals.
By default it will dispatch the Error
event.
Listen to the ModalError
event to overwrite this behaviour.
Source code in interactions/client/client.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
|
reload_extension(name, package=None, *, load_kwargs=None, unload_kwargs=None)
¶
Helper method to reload an extension. Simply unloads, then loads the extension with given arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
load_kwargs | Any | The manually-filled mapping of the load keyword arguments | None |
unload_kwargs | Any | The manually-filled mapping of the unload keyword arguments | None |
Source code in interactions/client/client.py
2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 |
|
start(token=None)
¶
Start the bot.
If uvloop
is installed, it will be used.
info
This is the recommended method to start the bot
Source code in interactions/client/client.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 |
|
start_gateway()
async
¶
Starts the gateway connection.
Source code in interactions/client/client.py
1010 1011 1012 1013 1014 1015 |
|
stop()
async
¶
Shutdown the bot.
Source code in interactions/client/client.py
1017 1018 1019 1020 1021 1022 |
|
sync_scope(cmd_scope, delete_cmds, local_cmds_json)
async
¶
Sync a single scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd_scope | Snowflake_Type | The scope to sync. | required |
delete_cmds | bool | Whether to delete commands. | required |
local_cmds_json | Dict[Snowflake_Type, List[Dict[str, Any]]] | The local commands in json format. | required |
Source code in interactions/client/client.py
1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 |
|
synchronise_interactions(*, scopes=MISSING, delete_commands=MISSING)
async
¶
Synchronise registered interactions with discord.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scopes | Sequence[Snowflake_Type] | Optionally specify which scopes are to be synced. | MISSING |
delete_commands | Absent[bool] | Override the client setting and delete commands. | MISSING |
Returns:
Type | Description |
---|---|
None | None |
Raises:
Type | Description |
---|---|
InteractionMissingAccess | If bot is lacking the necessary access. |
Exception | If there is an error during the synchronization process. |
Source code in interactions/client/client.py
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 |
|
unload_extension(name, package=None, force=False, **unload_kwargs)
¶
Unload an extension with given arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the extension. | required |
package | str | None | The package the extension is in | None |
force | bool | Whether to force unload the extension - for use in reversions | False |
**unload_kwargs | Any | The auto-filled mapping of the unload keyword arguments | {} |
Source code in interactions/client/client.py
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 |
|
update_command_cache(scope, command_name, command_id)
¶
Update the internal cache with a command ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope | Snowflake_Type | The scope of the command to update | required |
command_name | str | The name of the command | required |
command_id | Snowflake | The ID of the command | required |
Source code in interactions/client/client.py
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 |
|
wait_for(event, checks=MISSING, timeout=None)
¶
Waits for a WebSocket event to be dispatched.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event | Union[str, type[BaseEvent]] | The name of event to wait. | required |
checks | Absent[Callable[[BaseEvent], bool] | Callable[[BaseEvent], Awaitable[bool]]] | A predicate to check what to wait for. | MISSING |
timeout | Optional[float] | The number of seconds to wait before timing out. | None |
Returns:
Type | Description |
---|---|
Awaitable[Any] | The event object. |
Source code in interactions/client/client.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 |
|
wait_for_component(messages=None, components=None, check=None, timeout=None)
async
¶
Waits for a component to be sent to the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages | Optional[Union[Message, int, list]] | The message object to check for. | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to wait for. | None |
check | Optional[Callable[[events.Component], bool] | Callable[[events.Component], Awaitable[bool]]] | A predicate to check what to wait for. | None |
timeout | Optional[float] | The number of seconds to wait before timing out. | None |
Returns:
Type | Description |
---|---|
Component |
|
Raises:
Type | Description |
---|---|
asyncio.TimeoutError | if timed out |
Source code in interactions/client/client.py
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
|
wait_for_modal(modal, author=None, timeout=None)
async
¶
Wait for a modal response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
modal | Modal | The modal we're waiting for. | required |
author | Optional[Snowflake_Type] | The user we're waiting for to reply | None |
timeout | Optional[float] | A timeout in seconds to stop waiting | None |
Returns:
Type | Description |
---|---|
ModalContext | The context of the modal response |
Raises:
Type | Description |
---|---|
asyncio.TimeoutError | if no response is received that satisfies the predicate before timeout seconds have passed |
Source code in interactions/client/client.py
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
|
wait_until_ready()
async
¶
Waits for the client to become ready.
Source code in interactions/client/client.py
1066 1067 1068 |
|
AutoShardedClient
¶
Bases: Client
A client to automatically shard the bot.
You can optionally specify the total number of shards to start with, or it will be determined automatically.
Source code in interactions/client/auto_shard_client.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
gateway_started: bool
property
¶
Returns if the gateway has been started in all shards.
latencies: dict[int, float]
property
¶
Return a dictionary of latencies for all shards.
Returns:
Type | Description |
---|---|
dict[int, float] | {shard_id: latency} |
latency: float
property
¶
The average latency of all active gateways.
shards: list[ConnectionState]
property
¶
Returns a list of all shards currently in use.
start_time: datetime
property
¶
The start time of the first shard of the bot.
start_times: dict[int, datetime]
property
¶
The start times of all shards of the bot, keyed by each shard ID.
astart(token=None)
async
¶
Asynchronous method to start the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | str | None | Your bot's token | None |
Source code in interactions/client/auto_shard_client.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
change_presence(status=Status.ONLINE, activity=None, *, shard_id=None)
async
¶
Change the bot's presence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status | Optional[str | Status] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Optional[str | Activity] | The activity for the bot to be displayed as doing. | None |
shard_id | int | None | The shard to change the presence on. If not specified, the presence will be changed on all shards. | None |
Note
Bots may only be playing
streaming
listening
watching
or competing
, other activity types are likely to fail.
Source code in interactions/client/auto_shard_client.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
get_guild_websocket(guild_id)
¶
Get the appropriate websocket for a given guild
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild | required |
Returns:
Type | Description |
---|---|
GatewayClient | A gateway client for the given ID |
Source code in interactions/client/auto_shard_client.py
92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
get_shard_id(guild_id)
¶
Get the shard ID for a given guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The ID of the guild | required |
Returns:
Type | Description |
---|---|
int | The shard ID for the guild |
Source code in interactions/client/auto_shard_client.py
119 120 121 122 123 124 125 126 127 128 129 130 |
|
get_shards_guild(shard_id)
¶
Returns the guilds that the specified shard can see
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shard_id | int | The ID of the shard | required |
Returns:
Type | Description |
---|---|
list[Guild] | A list of guilds |
Source code in interactions/client/auto_shard_client.py
106 107 108 109 110 111 112 113 114 115 116 117 |
|
login(token=None)
async
¶
Login to discord via http.
Note
You will need to run Client.start_gateway() before you start receiving gateway events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | str | Your bot's token | None |
Source code in interactions/client/auto_shard_client.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
|
stop()
async
¶
Shutdown the bot.
Source code in interactions/client/auto_shard_client.py
85 86 87 88 89 90 |
|
ActiveVoiceState
¶
Bases: VoiceState
Source code in interactions/models/internal/active_voice_state.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
connected: bool
property
¶
Is this voice state currently connected?
current_audio: Optional[BaseAudio]
property
¶
The current audio being played
paused: bool
property
¶
Is the player currently paused
player: Optional[Player] = attrs.field(repr=False, default=None)
class-attribute
¶
The playback task that broadcasts audio data to discord
playing: bool
property
¶
Are we currently playing something?
recorder: Optional[Recorder] = attrs.field(default=None)
class-attribute
¶
A recorder task to capture audio from discord
stopped: bool
property
¶
Is the player stopped?
volume: float
writable
property
¶
Get the volume of the player
ws: Optional[VoiceGateway] = attrs.field(repr=False, default=None)
class-attribute
¶
The websocket for this voice state
connect(timeout=5)
async
¶
Establish the voice connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout | int | How long to wait for state and server information from discord | 5 |
Raises:
Type | Description |
---|---|
VoiceAlreadyConnected | if the voice state is already connected to the voice channel |
VoiceConnectionTimeout | if the voice state fails to connect |
Source code in interactions/models/internal/active_voice_state.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
create_recorder()
¶
Create a recorder instance.
Source code in interactions/models/internal/active_voice_state.py
235 236 237 238 239 |
|
disconnect()
async
¶
Disconnect from the voice channel.
Source code in interactions/models/internal/active_voice_state.py
163 164 165 |
|
move(channel, timeout=5)
async
¶
Move to another voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel | Snowflake_Type | The channel to move to | required |
timeout | int | How long to wait for state and server information from discord | 5 |
Source code in interactions/models/internal/active_voice_state.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
pause()
¶
Pause playback
Source code in interactions/models/internal/active_voice_state.py
200 201 202 |
|
play(audio)
async
¶
Start playing an audio object.
Waits for the player to stop before returning.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio | BaseAudio | The audio object to play | required |
Source code in interactions/models/internal/active_voice_state.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
play_no_wait(audio)
¶
Start playing an audio object, but don't wait for playback to finish.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio | BaseAudio | The audio object to play | required |
Source code in interactions/models/internal/active_voice_state.py
225 226 227 228 229 230 231 232 233 |
|
resume()
¶
Resume playback.
Source code in interactions/models/internal/active_voice_state.py
204 205 206 |
|
start_recording(encoding=None, *, output_dir=Missing)
async
¶
Start recording the voice channel.
If no recorder exists, one will be created.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
encoding | Optional[str] | What format the audio should be encoded to. | None |
output_dir | str | Missing | The directory to save the audio to | Missing |
Source code in interactions/models/internal/active_voice_state.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
stop()
async
¶
Stop playback.
Source code in interactions/models/internal/active_voice_state.py
195 196 197 198 |
|
stop_recording()
async
¶
Stop the recording.
Returns:
Type | Description |
---|---|
dict[int, BytesIO] | dict[snowflake, BytesIO]: The recorded audio |
Source code in interactions/models/internal/active_voice_state.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
wait_for_stopped()
async
¶
Wait for the player to stop playing.
Source code in interactions/models/internal/active_voice_state.py
99 100 101 102 103 |
|
ws_connect()
async
¶
Connect to the voice gateway for this voice state
Source code in interactions/models/internal/active_voice_state.py
114 115 116 117 118 119 |
|
User¶
BaseUser
¶
Bases: DiscordObject
, _SendDMMixin
Base class for User, essentially partial user discord model.
Source code in interactions/models/discord/user.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
avatar_url: str
property
¶
The users avatar url.
display_avatar: Asset
property
¶
The users displayed avatar, will return guild_avatar
if one is set, otherwise will return user avatar.
display_name: str
property
¶
The users display name, will return nickname if one is set, otherwise will return username.
mention: str
property
¶
Returns a string that would mention the user.
mutual_guilds: List[Guild]
property
¶
Get a list of mutual guilds shared between this user and the client.
Note
This will only be accurate if the guild members are cached internally
tag: str
property
¶
Returns the user's Discord tag.
fetch_dm(*, force=False)
async
¶
Fetch the DM channel associated with this user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API | False |
Source code in interactions/models/discord/user.py
100 101 102 103 104 105 106 107 108 |
|
get_dm()
¶
Get the DM channel associated with this user.
Source code in interactions/models/discord/user.py
110 111 112 |
|
ClientUser
¶
Bases: User
Source code in interactions/models/discord/user.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
guilds: List[Guild]
property
¶
The guilds the user is in.
edit(*, username=MISSING, avatar=MISSING, banner=MISSING)
async
¶
Edit the client's user.
You can change the username, avatar, and banner, or any combination of the three. avatar
and banner
may be set to None
to remove your bot's avatar/banner
Example Usage:
1 |
|
1 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username | Absent[str] | The username you want to use | MISSING |
avatar | Absent[UPLOADABLE_TYPE] | The avatar to use. Can be a image file, path, or | MISSING |
banner | Absent[UPLOADABLE_TYPE] | The banner to use. Can be a image file, path, or | MISSING |
Raises:
Type | Description |
---|---|
TooManyChanges | If you change the profile too many times |
Source code in interactions/models/discord/user.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
Member
¶
Bases: DiscordObject
, _SendDMMixin
Source code in interactions/models/discord/user.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
avatar_url: str
property
¶
The users avatar url.
display_avatar: Asset
property
¶
The users displayed avatar, will return guild_avatar
if one is set, otherwise will return user avatar.
display_name: str
property
¶
The users display name, will return nickname if one is set, otherwise will return username.
guild: Guild
property
¶
The guild object this member is from.
guild_permissions: Permissions
property
¶
Returns the permissions this member has in the guild.
Returns:
Type | Description |
---|---|
Permissions | Permission data |
nickname: str
writable
property
¶
Alias for nick.
premium: bool
property
¶
Is this member a server booster?
roles: List[Role]
property
¶
The roles this member has.
top_role: Role
property
¶
The member's top most role.
user: User
property
¶
Returns this member's user object.
voice: Optional[VoiceState]
property
¶
Returns the voice state of this user if any.
add_role(role, reason=MISSING)
async
¶
Add a role to this member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role | Union[Snowflake_Type, Role] | The role to add | required |
reason | Absent[str] | The reason for adding this role | MISSING |
Source code in interactions/models/discord/user.py
549 550 551 552 553 554 555 556 557 558 559 560 |
|
add_roles(roles, reason=MISSING)
async
¶
Atomically add multiple roles to this member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
roles | Iterable[Union[Snowflake_Type, Role]] | The roles to add | required |
reason | Absent[str] | The reason for adding the roles | MISSING |
Source code in interactions/models/discord/user.py
562 563 564 565 566 567 568 569 570 571 572 |
|
ban(delete_message_days=MISSING, delete_message_seconds=0, reason=MISSING)
async
¶
Ban a member from the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delete_message_days | Absent[int] | (deprecated) The number of days of messages to delete | MISSING |
delete_message_seconds | int | The number of seconds of messages to delete | 0 |
reason | Absent[str] | The reason for this ban | MISSING |
Source code in interactions/models/discord/user.py
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
channel_permissions(channel)
¶
Returns the permissions this member has in a channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel | TYPE_GUILD_CHANNEL | The channel in question | required |
Returns:
Type | Description |
---|---|
Permissions | Permissions data |
Note
This method is used in Channel.permissions_for
Source code in interactions/models/discord/user.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
disconnect()
async
¶
Disconnects the member from the voice channel.
Source code in interactions/models/discord/user.py
657 658 659 |
|
edit(*, nickname=MISSING, roles=MISSING, mute=MISSING, deaf=MISSING, channel_id=MISSING, communication_disabled_until=MISSING, flags=MISSING, reason=MISSING)
async
¶
Modify attrbutes of this guild member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nickname | Absent[str] | Value to set users nickname to | MISSING |
roles | Absent[Iterable[Snowflake_Type]] | Array of role ids the member is assigned | MISSING |
mute | Absent[bool] | Whether the user is muted in voice channels. Will throw a 400 if the user is not in a voice channel | MISSING |
deaf | Absent[bool] | Whether the user is deafened in voice channels | MISSING |
channel_id | Absent[Snowflake_Type] | id of channel to move user to (if they are connected to voice) | MISSING |
communication_disabled_until | Absent[Union[Timestamp, None]] | when the user's timeout will expire and the user will be able to communicate in the guild again | MISSING |
flags | Absent[int] | Represents the guild member flags | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Source code in interactions/models/discord/user.py
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
|
edit_nickname(new_nickname=MISSING, reason=MISSING)
async
¶
Change the user's nickname.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_nickname | Absent[str] | The new nickname to apply | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Note
Leave new_nickname
empty to clean user's nickname
Source code in interactions/models/discord/user.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
has_any_role(roles)
¶
Checks if the user has any of the given roles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles | List[Union[Snowflake_Type, Role]] | The Role(s) or role id(s) to check for | required |
Source code in interactions/models/discord/user.py
612 613 614 615 616 617 618 619 620 |
|
has_permission(*permissions)
¶
Checks if the member has all the given permission(s).
Example Usage:
Two different styles can be used to call this method.
1 |
|
1 |
|
If member
has both permissions, True
gets returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*permissions | Permissions | The permission(s) to check whether the user has it. | () |
Source code in interactions/models/discord/user.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
|
has_role(*roles)
¶
Checks if the user has the given role(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles | Union[Snowflake_Type, Role] | The role(s) to check whether the user has it. | () |
Source code in interactions/models/discord/user.py
602 603 604 605 606 607 608 609 610 |
|
kick(reason=MISSING)
async
¶
Remove a member from the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[str] | The reason for this removal | MISSING |
Source code in interactions/models/discord/user.py
700 701 702 703 704 705 706 707 708 |
|
move(channel_id)
async
¶
Moves the member to a different voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The voice channel to move the member to | required |
Source code in interactions/models/discord/user.py
647 648 649 650 651 652 653 654 655 |
|
remove_role(role, reason=MISSING)
async
¶
Remove a role from this user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role | Union[Snowflake_Type, Role] | The role to remove | required |
reason | Absent[str] | The reason for this removal | MISSING |
Source code in interactions/models/discord/user.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
|
remove_roles(roles, reason=MISSING)
async
¶
Atomically remove multiple roles from this member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
roles | Iterable[Union[Snowflake_Type, Role]] | The roles to remove | required |
reason | Absent[str] | The reason for removing the roles | MISSING |
Source code in interactions/models/discord/user.py
590 591 592 593 594 595 596 597 598 599 600 |
|
timeout(communication_disabled_until, reason=MISSING)
async
¶
Disable a members communication for a given time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
communication_disabled_until | Union[Timestamp, datetime, int, float, str, None] | The time until the user can communicate again | required |
reason | Absent[str] | The reason for this timeout | MISSING |
Source code in interactions/models/discord/user.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
User
¶
Bases: BaseUser
Source code in interactions/models/discord/user.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
member_instances: List[Member]
property
¶
Returns the member object for all guilds both the bot and the user are in.
Note
This will only be accurate if the guild members are cached internally
VoiceRegion
¶
Bases: DictSerializationMixin
A voice region.
Source code in interactions/models/discord/voice_state.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
custom: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this is a custom voice region (used for events/etc)
deprecated: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this is a deprecated voice region (avoid switching to these)
id: str = attrs.field(repr=True)
class-attribute
¶
unique ID for the region
name: str = attrs.field(repr=True)
class-attribute
¶
name of the region
optimal: bool = attrs.field(repr=False, default=False)
class-attribute
¶
true for a single server that is closest to the current user's client
vip: bool = attrs.field(default=False, repr=True)
class-attribute
¶
whether this is a VIP-only voice region
VoiceState
¶
Bases: ClientObject
Source code in interactions/models/discord/voice_state.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
channel: TYPE_VOICE_CHANNEL
property
¶
The channel the user is connected to.
deaf: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is deafened by the server
guild: Guild
property
¶
The guild this voice state is for.
member: Member
property
¶
The member this voice state is for.
mute: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is muted by the server
request_to_speak_timestamp: Optional[Timestamp] = attrs.field(repr=False, default=None, converter=optional_c(timestamp_converter))
class-attribute
¶
the time at which the user requested to speak
self_deaf: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is locally deafened
self_mute: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is locally muted
self_stream: Optional[bool] = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is streaming using "Go Live"
self_video: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user's camera is enabled
session_id: str = attrs.field(repr=False, default=MISSING)
class-attribute
¶
the session id for this voice state
suppress: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this user is muted by the current user
user_id: Snowflake_Type = attrs.field(repr=False, default=MISSING, converter=to_snowflake)
class-attribute
¶
the user id this voice state is for
Guild¶
AuditLog
¶
Bases: ClientObject
Contains entries and other data given from selected
Source code in interactions/models/discord/guild.py
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 |
|
application_commands: list[InteractionCommand] = attrs.field(repr=False, factory=list, converter=optional(deserialize_app_cmds))
class-attribute
¶
list of application commands that have had their permissions updated
entries: Optional[List[AuditLogEntry]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of audit log entries
integrations: Optional[List[GuildIntegration]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of partial integration objects
scheduled_events: Optional[List[models.ScheduledEvent]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of guild scheduled events found in the audit log
threads: Optional[List[models.ThreadChannel]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of threads found in the audit log
users: Optional[List[models.User]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of users found in the audit log
webhooks: Optional[List[models.Webhook]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
list of webhooks found in the audit log
AuditLogChange
¶
Bases: ClientObject
Source code in interactions/models/discord/guild.py
2383 2384 2385 2386 2387 2388 2389 2390 |
|
key: str = attrs.field(repr=True)
class-attribute
¶
name of audit log change key
new_value: Optional[Union[list, str, int, bool, Snowflake_Type]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
new value of the key
old_value: Optional[Union[list, str, int, bool, Snowflake_Type]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
old value of the key
AuditLogEntry
¶
Bases: DiscordObject
Source code in interactions/models/discord/guild.py
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 |
|
action_type: AuditLogEventType = attrs.field(repr=False, converter=AuditLogEventType)
class-attribute
¶
type of action that occurred
changes: Optional[List[AuditLogChange]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
changes made to the target_id
options: Optional[Union[Snowflake_Type, str]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
additional info for certain action types
reason: Optional[str] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
the reason for the change (0-512 characters)
target_id: Optional[Snowflake_Type] = attrs.field(repr=False, converter=optional(to_snowflake))
class-attribute
¶
id of the affected entity (webhook, user, role, etc.)
user_id: Snowflake_Type = attrs.field(repr=False, converter=optional(to_snowflake))
class-attribute
¶
the user who made the changes
AuditLogHistory
¶
Bases: AsyncIterator
An async iterator for searching through a audit log's entry history.
Attributes:
Name | Type | Description |
---|---|---|
guild | | |
user_id | | |
action_type | | |
before | Snowflake_Type | get messages before this message ID |
after | Snowflake_Type | get messages after this message ID |
limit | Snowflake_Type | The maximum number of entries to return (set to 0 for no limit) |
Source code in interactions/models/discord/guild.py
2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 |
|
fetch()
async
¶
Retrieves the audit log entries from discord API.
Returns:
Type | Description |
---|---|
List[AuditLog] | The list of audit log entries. |
Source code in interactions/models/discord/guild.py
2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 |
|
BaseGuild
¶
Bases: DiscordObject
Source code in interactions/models/discord/guild.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
description: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
The description for the guild, if the guild is discoverable
discovery_splash: Optional[models.Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
Discovery splash image. Only present for guilds with the "DISCOVERABLE" feature.
features: List[str] = attrs.field(repr=False, factory=list)
class-attribute
¶
The features of this guild
icon: Optional[models.Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
Icon image asset
name: str = attrs.field(repr=True)
class-attribute
¶
Name of guild. (2-100 characters, excluding trailing and leading whitespace)
splash: Optional[models.Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
Splash image asset
BulkBanResponse
¶
Bases: ClientObject
Source code in interactions/models/discord/guild.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
banned_user_ids: List[Snowflake_Type]
property
¶
List of user IDs that were successfully banned.
banned_users: List[models.User | None]
property
¶
List of users that were successfully banned.
failed_user_ids: List[Snowflake_Type]
property
¶
List of user IDs that were not banned.
failed_users: List[models.User | None]
property
¶
List of users that were not banned.
Guild
¶
Bases: BaseGuild
Guilds in Discord represent an isolated collection of users and channels, and are often referred to as "servers" in the UI.
Source code in interactions/models/discord/guild.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 |
|
afk_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The channel id for afk.
afk_timeout: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
afk timeout in seconds.
banner: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
Hash for banner image.
bitrate_limit: int
property
¶
The maximum bitrate for this guild.
bots: List[models.Member]
property
¶
Returns a list of all bots within this guild
channels: List[models.TYPE_GUILD_CHANNEL]
property
¶
Returns a list of channels associated with this guild.
chunked = attrs.field(repr=False, factory=asyncio.Event, metadata=no_export_meta)
class-attribute
¶
An event that is fired when this guild has been chunked
command_permissions: dict[Snowflake_Type, CommandPermissions] = attrs.field(repr=False, factory=dict, metadata=no_export_meta)
class-attribute
¶
A cache of all command permissions for this guild
default_message_notifications: Union[DefaultNotificationLevel, int] = attrs.field(repr=False, default=DefaultNotificationLevel.ALL_MESSAGES)
class-attribute
¶
The default message notifications level.
default_role: models.Role
property
¶
The @everyone
role in this guild.
emoji_limit: int
property
¶
The maximum number of emoji this guild can have.
explicit_content_filter: Union[ExplicitContentFilterLevel, int] = attrs.field(repr=False, default=ExplicitContentFilterLevel.DISABLED)
class-attribute
¶
The explicit content filter level.
filesize_limit: int
property
¶
The maximum filesize that may be uploaded within this guild.
gui_sorted_channels: list[models.TYPE_GUILD_CHANNEL]
property
¶
Return this guilds channels sorted by their gui positions
humans: List[models.Member]
property
¶
Returns a list of all humans within this guild
joined_at: str = attrs.field(repr=False, default=None, converter=optional(timestamp_converter))
class-attribute
¶
When this guild was joined at.
large: bool = attrs.field(repr=False, default=False)
class-attribute
¶
True if this is considered a large guild.
max_members: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
The maximum number of members for the guild.
max_presences: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
The maximum number of presences for the guild. (None is always returned, apart from the largest of guilds)
max_video_channel_users: int = attrs.field(repr=False, default=0)
class-attribute
¶
The maximum amount of users in a video channel.
me: models.Member
property
¶
Returns this bots member object within this guild.
member_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
The total number of members in this guild.
members: List[models.Member]
property
¶
Returns a list of all members within this guild.
mention_onboarding_browse: str
property
¶
Return a mention string for the browse section of Onboarding
mention_onboarding_customize: str
property
¶
Return a mention string for the customise section of Onboarding
mention_onboarding_guide: str
property
¶
Return a mention string for the guide section of Onboarding
mfa_level: Union[MFALevel, int] = attrs.field(repr=False, default=MFALevel.NONE)
class-attribute
¶
The required MFA (Multi Factor Authentication) level for the guild.
my_role: Optional[models.Role]
property
¶
The role associated with this client, if set.
nsfw_level: Union[NSFWLevel, int] = attrs.field(repr=False, default=NSFWLevel.DEFAULT)
class-attribute
¶
The guild NSFW level.
permissions: Permissions
property
¶
Alias for me.guild_permissions
preferred_locale: str = attrs.field(repr=False)
class-attribute
¶
The preferred locale of a Community guild. Used in server discovery and notices from Discord. Defaults to "en-US"
premium_progress_bar_enabled: bool = attrs.field(repr=False, default=False)
class-attribute
¶
True if the guild has the boost progress bar enabled
premium_subscriber_role: Optional[models.Role]
property
¶
The role given to boosters of this server, if set.
premium_subscribers: List[models.Member]
property
¶
Returns a list of all premium subscribers
premium_subscription_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
The number of boosts this guild currently has.
premium_tier: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The premium tier level. (Server Boost level)
presences: List[dict] = attrs.field(repr=False, factory=list)
class-attribute
¶
The presences of the members in the guild, will only include non-offline members if the size is greater than large threshold.
public_updates_channel: Optional[models.GuildText]
property
¶
Returns the channel where server staff receive notices from Discord.
public_updates_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The id of the channel where admins and moderators of Community guilds receive notices from Discord.
roles: List[models.Role]
property
¶
Returns a list of roles associated with this guild.
rules_channel: Optional[models.GuildText]
property
¶
Returns the channel declared as a rules channel.
rules_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The id of the channel where Community guilds can display rules and/or guidelines.
safety_alerts_channel: Optional[models.GuildText]
property
¶
Returns the channel where server staff receive safety alerts from Discord.
safety_alerts_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord.
stage_instances: List[dict] = attrs.field(repr=False, factory=list)
class-attribute
¶
Stage instances in the guild.
sticker_limit: int
property
¶
The maximum number of stickers this guild can have.
system_channel: Optional[models.GuildText]
property
¶
Returns the channel this guild uses for system messages.
system_channel_flags: SystemChannelFlags = attrs.field(repr=False, default=SystemChannelFlags.NONE, converter=SystemChannelFlags)
class-attribute
¶
The system channel flags.
system_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The id of the channel where guild notices such as welcome messages and boost events are posted.
threads: List[models.TYPE_THREAD_CHANNEL]
property
¶
Returns a list of threads associated with this guild.
unavailable: bool = attrs.field(repr=False, default=False)
class-attribute
¶
True if this guild is unavailable due to an outage.
vanity_url_code: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The vanity url code for the guild.
verification_level: Union[VerificationLevel, int] = attrs.field(repr=False, default=VerificationLevel.NONE)
class-attribute
¶
The verification level required for the guild.
voice_state: Optional[models.VoiceState]
property
¶
Get the bot's voice state for the guild.
voice_states: List[models.VoiceState]
property
¶
Get a list of the active voice states in this guild.
welcome_screen: Optional[GuildWelcome] = attrs.field(repr=False, default=None)
class-attribute
¶
The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object.
widget_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The channel id that the widget will generate an invite to, or None if set to no invite.
widget_enabled: bool = attrs.field(repr=False, default=False)
class-attribute
¶
True if the server widget is enabled.
audit_log_history(user_id=MISSING, action_type=MISSING, before=MISSING, after=MISSING, limit=100)
¶
Get an async iterator for the history of the audit log.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | | MISSING | |
action_type | | MISSING | |
before | Optional[Snowflake_Type] | get entries before this message ID | MISSING |
after | Optional[Snowflake_Type] | get entries after this message ID | MISSING |
limit | int | The maximum number of entries to return (set to 0 for no limit) | 100 |
Example Usage:
1 2 3 4 |
|
1 2 3 |
|
Returns:
Type | Description |
---|---|
AuditLogHistory | AuditLogHistory (AsyncIterator) |
Source code in interactions/models/discord/guild.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
|
ban(user, delete_message_days=MISSING, delete_message_seconds=0, reason=MISSING)
async
¶
Ban a user from the guild.
Note
You must have the ban members
permission
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to ban | required |
delete_message_days | Absent[int] | (deprecated) How many days worth of messages to remove | MISSING |
delete_message_seconds | int | How many seconds worth of messages to remove | 0 |
reason | Absent[str] | The reason for the ban | MISSING |
Source code in interactions/models/discord/guild.py
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 |
|
bulk_ban(users, delete_message_seconds=0, reason=None)
async
¶
Bans a list of users from the guild.
Note
You must have the ban members
permission
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | The users to ban | required | |
delete_message_seconds | int | How many seconds worth of messages to remove | 0 |
reason | Optional[str] | The reason for the ban | None |
Source code in interactions/models/discord/guild.py
1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 |
|
chunk()
async
¶
Populates all members of this guild using the REST API.
Source code in interactions/models/discord/guild.py
649 650 651 |
|
chunk_guild(wait=True, presences=True)
async
¶
Trigger a gateway get_members
event, populating this object with members.
Depreciation Warning
Gateway chunking is deprecated and replaced by http chunking. Use guild.gateway_chunk
if you need gateway chunking.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wait | bool | Wait for chunking to be completed before continuing | True |
presences | bool | Do you need presence data for members? | True |
Source code in interactions/models/discord/guild.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
|
create(name, client, *, icon=MISSING, verification_level=MISSING, default_message_notifications=MISSING, explicit_content_filter=MISSING, roles=MISSING, channels=MISSING, afk_channel_id=MISSING, afk_timeout=MISSING, system_channel_id=MISSING, system_channel_flags=MISSING)
classmethod
async
¶
Create a guild.
Note
This method will only work for bots in less than 10 guilds.
Param notes
Roles: - When using the roles
parameter, the first member of the array is used to change properties of the guild's @everyone
role. If you are trying to bootstrap a guild with additional roles, keep this in mind. - When using the roles
parameter, the required id field within each role object is an integer placeholder, and will be replaced by the API upon consumption. Its purpose is to allow you to overwrite a role's permissions in a channel when also passing in channels with the channels array.
Channels: - When using the channels
parameter, the position field is ignored, and none of the default channels are created. - When using the channels
parameter, the id field within each channel object may be set to an integer placeholder, and will be replaced by the API upon consumption. Its purpose is to allow you to create GUILD_CATEGORY
channels by setting the parent_id
field on any children to the category's id field. Category channels must be listed before any children.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | name of the guild (2-100 characters) | required |
client | Client | The client | required |
icon | Absent[Optional[UPLOADABLE_TYPE]] | An icon for the guild | MISSING |
verification_level | Absent[VerificationLevel] | The guild's verification level | MISSING |
default_message_notifications | Absent[DefaultNotificationLevel] | The default message notification level | MISSING |
explicit_content_filter | Absent[ExplicitContentFilterLevel] | The guild's explicit content filter level | MISSING |
roles | Absent[list[dict]] | An array of partial role dictionaries | MISSING |
channels | Absent[list[dict]] | An array of partial channel dictionaries | MISSING |
afk_channel_id | Absent[Snowflake_Type] | id for afk channel | MISSING |
afk_timeout | Absent[int] | afk timeout in seconds | MISSING |
system_channel_id | Absent[Snowflake_Type] | the id of the channel where guild notices should go | MISSING |
system_channel_flags | Absent[SystemChannelFlags] | flags for the system channel | MISSING |
Returns:
Type | Description |
---|---|
Guild | The created guild object |
Source code in interactions/models/discord/guild.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
|
create_auto_moderation_rule(name, *, trigger, actions, exempt_roles=MISSING, exempt_channels=MISSING, enabled=True, event_type=AutoModEvent.MESSAGE_SEND)
async
¶
Create an auto-moderation rule in this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the rule | required |
trigger | BaseTrigger | The trigger for this rule | required |
actions | list[BaseAction] | A list of actions to take upon triggering | required |
exempt_roles | list[Snowflake_Type] | Roles that ignore this rule | MISSING |
exempt_channels | list[Snowflake_Type] | Channels that ignore this role | MISSING |
enabled | bool | Is this rule enabled? | True |
event_type | AutoModEvent | The type of event that triggers this rule | AutoModEvent.MESSAGE_SEND |
Returns:
Type | Description |
---|---|
AutoModRule | The created rule |
Source code in interactions/models/discord/guild.py
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 |
|
create_category(name, position=MISSING, permission_overwrites=MISSING, reason=MISSING)
async
¶
Create a category within this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildCategory | The newly created category. |
Source code in interactions/models/discord/guild.py
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 |
|
create_channel(channel_type, name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, bitrate=64000, user_limit=0, rate_limit_per_user=0, reason=MISSING, **kwargs)
async
¶
Create a guild channel, allows for explicit channel type setting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_type | Union[ChannelType, int] | The type of channel to create | required |
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
kwargs | dict | Additional keyword arguments to pass to the channel creation | {} |
Returns:
Type | Description |
---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in interactions/models/discord/guild.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
create_custom_emoji(name, imagefile, roles=MISSING, reason=MISSING)
async
¶
Create a new custom emoji for the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the emoji | required |
imagefile | UPLOADABLE_TYPE | The emoji image. (Supports PNG, JPEG, WebP, GIF) | required |
roles | Absent[List[Union[Snowflake_Type, Role]]] | Roles allowed to use this emoji. | MISSING |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Returns:
Type | Description |
---|---|
CustomEmoji | The new custom emoji created. |
Source code in interactions/models/discord/guild.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
create_custom_sticker(name, file, tags, description=MISSING, reason=MISSING)
async
¶
Creates a custom sticker for a guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the sticker (2-30 characters) | required |
file | UPLOADABLE_TYPE | The sticker file to upload, must be a PNG, APNG, or Lottie JSON file (max 500 KB) | required |
tags | list[str] | Autocomplete/suggestion tags for the sticker (max 200 characters) | required |
description | Absent[Optional[str]] | The description of the sticker (empty or 2-100 characters) | MISSING |
reason | Absent[Optional[str]] | Reason for creating the sticker | MISSING |
Returns:
Type | Description |
---|---|
Sticker | New Sticker instance |
Source code in interactions/models/discord/guild.py
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 |
|
create_forum_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, rate_limit_per_user=0, default_reaction_emoji=MISSING, available_tags=MISSING, layout=ForumLayoutType.NOT_SET, sort_order=MISSING, reason=MISSING)
async
¶
Create a forum channel in this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the forum channel | required |
topic | Absent[Optional[str]] | The topic of the forum channel | MISSING |
position | Absent[Optional[int]] | The position of the forum channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the forum channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this forum channel should be within | None |
nsfw | bool | Should this forum be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
default_reaction_emoji | Absent[Union[dict, PartialEmoji, DefaultReaction, str]] | The default emoji to react with when creating a thread | MISSING |
available_tags | Absent[ThreadTag] | The available tags for this forum channel | MISSING |
layout | ForumLayoutType | The layout of the forum channel | ForumLayoutType.NOT_SET |
sort_order | Absent[ForumSortOrder] | The sort order of the forum channel | MISSING |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildForum | The newly created forum channel. |
Source code in interactions/models/discord/guild.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 |
|
create_guild_template(name, description=MISSING)
async
¶
Create a new guild template based on this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the template (1-100 characters) | required |
description | Absent[str] | The description for the template (0-120 characters) | MISSING |
Returns:
Type | Description |
---|---|
GuildTemplate | The new guild template created. |
Source code in interactions/models/discord/guild.py
890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
|
create_news_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, reason=MISSING)
async
¶
Create a news channel in this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildNews | The newly created news channel. |
Source code in interactions/models/discord/guild.py
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
|
create_role(name=MISSING, permissions=MISSING, colour=MISSING, color=MISSING, hoist=False, mentionable=False, icon=MISSING, reason=MISSING)
async
¶
Create a new role for the guild. You must have the manage roles
permission.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[Optional[str]] | The name the role should have. | MISSING |
permissions | Absent[Optional[Permissions]] | The permissions the role should have. | MISSING |
colour | Absent[Optional[Union[Color, int]]] | The colour of the role. Can be either | MISSING |
color | Absent[Optional[Union[Color, int]]] | Alias for | MISSING |
icon | Absent[Optional[UPLOADABLE_TYPE]] | Can be either a bytes like object or a path to an image, or a unicode emoji which is supported by discord. | MISSING |
hoist | Optional[bool] | Whether the role is shown separately in the members list. | False |
mentionable | Optional[bool] | Whether the role can be mentioned. | False |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Returns:
Type | Description |
---|---|
Role | A role object or None if the role is not found. |
Source code in interactions/models/discord/guild.py
1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
|
create_scheduled_event(name, event_type, start_time, end_time=MISSING, description=MISSING, channel_id=MISSING, external_location=MISSING, entity_metadata=None, privacy_level=ScheduledEventPrivacyLevel.GUILD_ONLY, cover_image=MISSING, reason=MISSING)
async
¶
Create a scheduled guild event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | event name | required |
event_type | ScheduledEventType | event type | required |
start_time | Timestamp |
| required |
end_time | Absent[Optional[Timestamp]] |
| MISSING |
description | Absent[Optional[str]] | event description | MISSING |
channel_id | Absent[Optional[Snowflake_Type]] | channel id | MISSING |
external_location | Absent[Optional[str]] | event external location (For external events) | MISSING |
entity_metadata | Optional[dict] | event metadata (additional data for the event) | None |
privacy_level | ScheduledEventPrivacyLevel | event privacy level | ScheduledEventPrivacyLevel.GUILD_ONLY |
cover_image | Absent[UPLOADABLE_TYPE] | the cover image of the scheduled event | MISSING |
reason | Absent[Optional[str]] | reason for creating this scheduled event | MISSING |
Returns:
Type | Description |
---|---|
ScheduledEvent | The newly created ScheduledEvent object |
Note
For external events, external_location is required For voice/stage events, channel_id is required
Note
entity_metadata is the backend dictionary for fluff fields. Where possible, we plan to expose these fields directly. The full list of supported fields is https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-metadata Example: entity_metadata=dict(location="cool place")
Source code in interactions/models/discord/guild.py
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
|
create_stage_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=MISSING, bitrate=64000, user_limit=0, reason=MISSING)
async
¶
Create a guild stage channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Absent[Union[Snowflake_Type, GuildCategory]] | The category this channel should be within | MISSING |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildStageVoice | The newly created stage channel. |
Source code in interactions/models/discord/guild.py
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 |
|
create_text_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, rate_limit_per_user=0, reason=MISSING)
async
¶
Create a text channel in this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildText | The newly created text channel. |
Source code in interactions/models/discord/guild.py
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 |
|
create_voice_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, category=None, nsfw=False, bitrate=64000, user_limit=0, reason=MISSING)
async
¶
Create a guild voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
category | Union[Snowflake_Type, GuildCategory] | The category this channel should be within | None |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildVoice | The newly created voice channel. |
Source code in interactions/models/discord/guild.py
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 |
|
delete()
async
¶
Delete the guild.
Note
You must own this guild to do this.
Source code in interactions/models/discord/guild.py
1723 1724 1725 1726 1727 1728 1729 1730 1731 |
|
delete_auto_moderation_rule(rule, reason=MISSING)
async
¶
Delete a given auto moderation rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule | Snowflake_Type | The rule to delete | required |
reason | Absent[str] | The reason for deleting this rule | MISSING |
Source code in interactions/models/discord/guild.py
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 |
|
delete_channel(channel, reason=None)
async
¶
Delete the given channel, can handle either a snowflake or channel object.
This is effectively just an alias for channel.delete()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel | Union[TYPE_GUILD_CHANNEL, Snowflake_Type] | The channel to be deleted | required |
reason | str | None | The reason for this deletion | None |
Source code in interactions/models/discord/guild.py
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 |
|
edit(*, name=MISSING, description=MISSING, verification_level=MISSING, default_message_notifications=MISSING, explicit_content_filter=MISSING, afk_channel=MISSING, afk_timeout=MISSING, system_channel=MISSING, system_channel_flags=MISSING, owner=MISSING, icon=MISSING, splash=MISSING, discovery_splash=MISSING, banner=MISSING, rules_channel=MISSING, public_updates_channel=MISSING, safety_alerts_channel=MISSING, preferred_locale=MISSING, premium_progress_bar_enabled=False, features=MISSING, reason=MISSING)
async
¶
Edit the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[Optional[str]] | The new name of the guild. | MISSING |
description | Absent[Optional[str]] | The new description of the guild. | MISSING |
verification_level | Absent[Optional[VerificationLevel]] | The new verification level for the guild. | MISSING |
default_message_notifications | Absent[Optional[DefaultNotificationLevel]] | The new notification level for the guild. | MISSING |
explicit_content_filter | Absent[Optional[ExplicitContentFilterLevel]] | The new explicit content filter level for the guild. | MISSING |
afk_channel | Absent[Optional[Union[GuildVoice, Snowflake_Type]]] | The voice channel that should be the new AFK channel. | MISSING |
afk_timeout | Absent[Optional[int]] | How many seconds does a member need to be afk before they get moved to the AFK channel. Must be either | MISSING |
icon | Absent[Optional[UPLOADABLE_TYPE]] | The new icon. Requires a bytes like object or a path to an image. | MISSING |
owner | Absent[Optional[Union[Member, Snowflake_Type]]] | The new owner of the guild. You, the bot, need to be owner for this to work. | MISSING |
splash | Absent[Optional[UPLOADABLE_TYPE]] | The new invite splash image. Requires a bytes like object or a path to an image. | MISSING |
discovery_splash | Absent[Optional[UPLOADABLE_TYPE]] | The new discovery image. Requires a bytes like object or a path to an image. | MISSING |
banner | Absent[Optional[UPLOADABLE_TYPE]] | The new banner image. Requires a bytes like object or a path to an image. | MISSING |
system_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where new system messages should appear. This includes boosts and welcome messages. | MISSING |
system_channel_flags | Absent[Union[SystemChannelFlags, int]] | The new settings for the system channel. | MISSING |
rules_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where your rules and community guidelines are displayed. | MISSING |
public_updates_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where updates from discord should appear. | MISSING |
safety_alerts_channel | Absent[Optional[Union[GuildText, Snowflake_Type]]] | The text channel where safety alerts from discord should appear. | MISSING |
preferred_locale | Absent[Optional[str]] | The new preferred locale of the guild. Must be an ISO 639 code. | MISSING |
premium_progress_bar_enabled | Absent[Optional[bool]] | The status of the Nitro boost bar. | False |
features | Absent[Optional[list[str]]] | The enabled guild features | MISSING |
reason | Absent[Optional[str]] | An optional reason for the audit log. | MISSING |
Source code in interactions/models/discord/guild.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
edit_nickname(new_nickname=MISSING, reason=MISSING)
async
¶
Alias for me.edit_nickname
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_nickname | Absent[str] | The new nickname to apply | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Note
Leave new_nickname
empty to clean user's nickname
Source code in interactions/models/discord/guild.py
608 609 610 611 612 613 614 615 616 617 618 619 620 |
|
estimate_prune_members(days=7, roles=MISSING)
async
¶
Calculate how many members would be pruned, should guild.prune_members
be used. By default, members with roles are excluded from pruning, to include them, pass their role (or role id) in roles
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
days | int | number of days to prune (1-30) | 7 |
roles | List[Union[Snowflake_Type, Role]] | list of roles to include in the prune | MISSING |
Returns:
Type | Description |
---|---|
int | Total number of members that would be pruned |
Source code in interactions/models/discord/guild.py
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 |
|
fetch_active_threads()
async
¶
Fetches all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order.
Returns:
Type | Description |
---|---|
ThreadList | List of active threads and thread member object for each returned thread the bot user has joined. |
Source code in interactions/models/discord/guild.py
1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 |
|
fetch_all_custom_emojis()
async
¶
Gets all the custom emoji present for this guild.
Returns:
Type | Description |
---|---|
List[CustomEmoji] | A list of custom emoji objects. |
Source code in interactions/models/discord/guild.py
916 917 918 919 920 921 922 923 924 925 |
|
fetch_all_custom_stickers()
async
¶
Fetches all custom stickers for a guild.
Returns:
Type | Description |
---|---|
List[Sticker] | List of Sticker objects |
Source code in interactions/models/discord/guild.py
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 |
|
fetch_all_webhooks()
async
¶
Fetches all the webhooks for this guild.
Returns:
Type | Description |
---|---|
List[Webhook] | A list of webhook objects. |
Source code in interactions/models/discord/guild.py
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 |
|
fetch_app_cmd_perms()
async
¶
Fetch the application command permissions for this guild.
Returns:
Type | Description |
---|---|
dict[Snowflake_Type, CommandPermissions] | The application command permissions for this guild. |
Source code in interactions/models/discord/guild.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
|
fetch_audit_log(user_id=MISSING, action_type=MISSING, before=MISSING, after=MISSING, limit=100)
async
¶
Fetch section of the audit log for this guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | Optional[Snowflake_Type] | The ID of the user to filter by | MISSING |
action_type | Optional[AuditLogEventType] | The type of action to filter by | MISSING |
before | Optional[Snowflake_Type] | The ID of the entry to start at | MISSING |
after | Optional[Snowflake_Type] | The ID of the entry to end at | MISSING |
limit | int | The number of entries to return | 100 |
Returns:
Type | Description |
---|---|
AuditLog | An AuditLog object |
Source code in interactions/models/discord/guild.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
|
fetch_auto_moderation_rules()
async
¶
Get this guild's auto moderation rules.
Returns:
Type | Description |
---|---|
List[AutoModRule] | A list of auto moderation rules |
Source code in interactions/models/discord/guild.py
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 |
|
fetch_ban(user)
async
¶
Fetches the ban information for the specified user in the guild. You must have the ban members
permission.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to look up. | required |
Returns:
Type | Description |
---|---|
Optional[GuildBan] | The ban information. If the user is not banned, returns None. |
Source code in interactions/models/discord/guild.py
1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 |
|
fetch_bans(before=MISSING, after=MISSING, limit=1000)
async
¶
Fetches bans for the guild. You must have the ban members
permission.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
before | Optional[Snowflake_Type] | consider only users before given user id | MISSING |
after | Optional[Snowflake_Type] | consider only users after given user id | MISSING |
limit | int | number of users to return (up to maximum 1000) | 1000 |
Returns:
Type | Description |
---|---|
list[GuildBan] | A list containing bans and information about them. |
Source code in interactions/models/discord/guild.py
1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 |
|
fetch_channel(channel_id, *, force=False)
async
¶
Returns a channel with the given channel_id
from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
Optional[TYPE_GUILD_CHANNEL] | The channel object. If the channel does not exist, returns None. |
Source code in interactions/models/discord/guild.py
1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 |
|
fetch_channels()
async
¶
Fetch this guild's channels.
Returns:
Type | Description |
---|---|
List[TYPE_GUILD_CHANNEL] | A list of channels in this guild |
Source code in interactions/models/discord/guild.py
561 562 563 564 565 566 567 568 569 570 |
|
fetch_custom_emoji(emoji_id, *, force=False)
async
¶
Fetches the custom emoji present for this guild, based on the emoji id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji_id | Snowflake_Type | The target emoji to get data of. | required |
force | bool | Whether to force fetch the emoji from the API. | False |
Returns:
Type | Description |
---|---|
Optional[CustomEmoji] | The custom emoji object. If the emoji is not found, returns None. |
Source code in interactions/models/discord/guild.py
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 |
|
fetch_custom_sticker(sticker_id)
async
¶
Fetches a specific custom sticker for a guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sticker_id | Snowflake_Type | ID of sticker to get | required |
Returns:
Type | Description |
---|---|
Optional[Sticker] | The custom sticker object. If the sticker does not exist, returns None. |
Source code in interactions/models/discord/guild.py
1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 |
|
fetch_guild_integrations()
async
¶
Fetches all integrations for the guild.
Returns:
Type | Description |
---|---|
List[GuildIntegration] | A list of integrations for the guild. |
Source code in interactions/models/discord/guild.py
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 |
|
fetch_guild_templates()
async
¶
Fetch all guild templates for this guild.
Returns:
Type | Description |
---|---|
List[GuildTemplate] | A list of guild template objects. |
Source code in interactions/models/discord/guild.py
905 906 907 908 909 910 911 912 913 914 |
|
fetch_invites()
async
¶
Fetches all invites for the guild.
Returns:
Type | Description |
---|---|
List[Invite] | A list of invites for the guild. |
Source code in interactions/models/discord/guild.py
2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
|
fetch_member(member_id, *, force=False)
async
¶
Return the Member with the given discord ID, fetching from the API if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member_id | Snowflake_Type | The ID of the member. | required |
force | bool | Whether to force a fetch from the API. | False |
Returns:
Type | Description |
---|---|
Optional[Member] | The member object fetched. If the member is not in this guild, returns None. |
Source code in interactions/models/discord/guild.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
|
fetch_onboarding()
async
¶
Fetches the guild's onboarding settings.
Returns:
Type | Description |
---|---|
Onboarding | The guild's onboarding settings. |
Source code in interactions/models/discord/guild.py
2091 2092 2093 2094 2095 2096 2097 2098 2099 |
|
fetch_owner(*, force=False)
async
¶
Return the Guild owner, fetching from the API if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API. | False |
Returns:
Type | Description |
---|---|
Member | Member object or None |
Source code in interactions/models/discord/guild.py
538 539 540 541 542 543 544 545 546 547 548 549 |
|
fetch_role(role_id, *, force=False)
async
¶
Fetch the specified role by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role_id | Snowflake_Type | The ID of the role to get | required |
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
Optional[Role] | The role object. If the role does not exist, returns None. |
Source code in interactions/models/discord/guild.py
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 |
|
fetch_scheduled_event(scheduled_event_id, with_user_count=False, *, force=False)
async
¶
Fetches a scheduled event by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scheduled_event_id | Snowflake_Type | The id of the scheduled event. | required |
with_user_count | bool | Whether to include the user count in the response. | False |
force | bool | If the cache should be ignored, and the event should be fetched from the API | False |
Returns:
Type | Description |
---|---|
Optional[ScheduledEvent] | The scheduled event. If the event does not exist, returns None. |
Source code in interactions/models/discord/guild.py
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
|
fetch_thread(thread_id, *, force=False)
async
¶
Returns a Thread with the given thread_id
from the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thread_id | Snowflake_Type | The ID of the thread to get | required |
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
Optional[TYPE_THREAD_CHANNEL] | Thread object if found, otherwise None |
Source code in interactions/models/discord/guild.py
1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
|
fetch_voice_regions()
async
¶
Fetches the voice regions for the guild.
Unlike the Client.fetch_voice_regions
method, this will returns VIP servers when the guild is VIP-enabled.
Returns:
Type | Description |
---|---|
List[VoiceRegion] | A list of voice regions. |
Source code in interactions/models/discord/guild.py
2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 |
|
fetch_widget()
async
¶
Fetches the guilds widget.
Returns:
Type | Description |
---|---|
GuildWidget | The guilds widget object. |
Source code in interactions/models/discord/guild.py
2004 2005 2006 2007 2008 2009 2010 2011 2012 |
|
fetch_widget_image(style=None)
async
¶
Fetch a guilds widget image.
For a list of styles, look here: https://discord.com/developers/docs/resources/guild#get-guild-widget-image-widget-style-options
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style | str | None | The style to use for the widget image | None |
Returns:
Type | Description |
---|---|
str | The URL of the widget image. |
Source code in interactions/models/discord/guild.py
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 |
|
fetch_widget_settings()
async
¶
Fetches the guilds widget settings.
Returns:
Type | Description |
---|---|
GuildWidgetSettings | The guilds widget settings object. |
Source code in interactions/models/discord/guild.py
1994 1995 1996 1997 1998 1999 2000 2001 2002 |
|
gateway_chunk(wait=True, presences=True)
async
¶
Trigger a gateway get_members
event, populating this object with members.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wait | bool | Wait for chunking to be completed before continuing | True |
presences | bool | Do you need presence data for members? | True |
Source code in interactions/models/discord/guild.py
635 636 637 638 639 640 641 642 643 644 645 646 647 |
|
get_channel(channel_id)
¶
Returns a channel with the given channel_id
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get | required |
Returns:
Type | Description |
---|---|
Optional[TYPE_GUILD_CHANNEL] | Channel object if found, otherwise None |
Source code in interactions/models/discord/guild.py
1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 |
|
get_channel_gui_position(channel_id)
¶
Get a given channels gui position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_id | Snowflake_Type | The ID of the channel to get the gui position for. | required |
Returns:
Type | Description |
---|---|
int | The gui position of the channel. |
Source code in interactions/models/discord/guild.py
2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 |
|
get_custom_emoji(emoji_id)
¶
Gets the custom emoji present for this guild, based on the emoji id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji_id | Snowflake_Type | The target emoji to get data of. | required |
Returns:
Type | Description |
---|---|
Optional[CustomEmoji] | The custom emoji object. |
Source code in interactions/models/discord/guild.py
946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
|
get_member(member_id)
¶
Return the Member with the given discord ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member_id | Snowflake_Type | The ID of the member | required |
Returns:
Type | Description |
---|---|
Optional[Member] | Member object or None |
Source code in interactions/models/discord/guild.py
525 526 527 528 529 530 531 532 533 534 535 536 |
|
get_owner()
¶
Return the Guild owner
Returns:
Type | Description |
---|---|
Member | Member object or None |
Source code in interactions/models/discord/guild.py
551 552 553 554 555 556 557 558 559 |
|
get_role(role_id)
¶
Get the specified role by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role_id | Snowflake_Type | The ID of the role to get | required |
Returns:
Type | Description |
---|---|
Optional[Role] | A role object or None if the role is not found. |
Source code in interactions/models/discord/guild.py
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
|
get_scheduled_event(scheduled_event_id)
¶
Gets a scheduled event from the cache by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scheduled_event_id | Snowflake_Type | The id of the scheduled event. | required |
Returns:
Type | Description |
---|---|
Optional[ScheduledEvent] | The scheduled event. If the event does not exist, returns None. |
Source code in interactions/models/discord/guild.py
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 |
|
get_thread(thread_id)
¶
Returns a Thread with the given thread_id
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thread_id | Snowflake_Type | The ID of the thread to get | required |
Returns:
Type | Description |
---|---|
Optional[TYPE_THREAD_CHANNEL] | Thread object if found, otherwise None |
Source code in interactions/models/discord/guild.py
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 |
|
http_chunk()
async
¶
Populates all members of this guild using the REST API.
Source code in interactions/models/discord/guild.py
622 623 624 625 626 627 628 629 630 631 632 633 |
|
is_owner(user)
¶
Whether the user is owner of the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Snowflake_Type | The user to check | required |
Returns:
Type | Description |
---|---|
bool | True if the user is the owner of the guild, False otherwise. |
Note
the user
argument can be any type that meets Snowflake_Type
Source code in interactions/models/discord/guild.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
|
kick(user, reason=MISSING)
async
¶
Kick a user from the guild.
Note
You must have the kick members
permission
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to kick | required |
reason | Absent[str] | The reason for the kick | MISSING |
Source code in interactions/models/discord/guild.py
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 |
|
leave()
async
¶
Leave this guild.
Source code in interactions/models/discord/guild.py
1719 1720 1721 |
|
list_scheduled_events(with_user_count=False)
async
¶
List all scheduled events in this guild.
Returns:
Type | Description |
---|---|
List[ScheduledEvent] | A list of scheduled events. |
Source code in interactions/models/discord/guild.py
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 |
|
modify_auto_moderation_rule(rule, *, name=MISSING, trigger=MISSING, trigger_type=MISSING, trigger_metadata=MISSING, actions=MISSING, exempt_channels=MISSING, exempt_roles=MISSING, event_type=MISSING, enabled=MISSING, reason=MISSING)
async
¶
Modify an existing automod rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rule | Snowflake_Type | The rule to modify | required |
name | Absent[str] | The name of the rule | MISSING |
trigger | Absent[BaseTrigger] | A trigger for this rule | MISSING |
trigger_type | Absent[AutoModTriggerType] | The type trigger for this rule (ignored if trigger specified) | MISSING |
trigger_metadata | Absent[dict] | Metadata for the trigger (ignored if trigger specified) | MISSING |
actions | Absent[list[BaseAction]] | A list of actions to take upon triggering | MISSING |
exempt_roles | Absent[list[Snowflake_Type]] | Roles that ignore this rule | MISSING |
exempt_channels | Absent[list[Snowflake_Type]] | Channels that ignore this role | MISSING |
enabled | Absent[bool] | Is this rule enabled? | MISSING |
event_type | Absent[AutoModEvent] | The type of event that triggers this rule | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
Type | Description |
---|---|
AutoModRule | The updated rule |
Source code in interactions/models/discord/guild.py
1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 |
|
modify_widget(enabled=MISSING, channel=MISSING, settings=MISSING)
async
¶
Modify the guild's widget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled | Absent[bool] | Should the widget be enabled? | MISSING |
channel | Absent[Union[TYPE_GUILD_CHANNEL, Snowflake_Type]] | The channel to use in the widget | MISSING |
settings | Absent[GuildWidgetSettings] | The settings to use for the widget | MISSING |
Returns:
Type | Description |
---|---|
GuildWidget | The updated guilds widget object. |
Source code in interactions/models/discord/guild.py
2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 |
|
process_member_chunk(chunk)
async
¶
Receive and either cache or process the chunks of members from gateway.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chunk | dict | A member chunk from discord | required |
Source code in interactions/models/discord/guild.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 |
|
prune_members(days=7, roles=None, compute_prune_count=True, reason=MISSING)
async
¶
Begin a guild prune. Removes members from the guild who who have not interacted for the last days
days. By default, members with roles are excluded from pruning, to include them, pass their role (or role id) in roles
Requires kick members
permission.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
days | int | number of days to prune (1-30) | 7 |
roles | Optional[List[Snowflake_Type]] | list of roles to include in the prune | None |
compute_prune_count | bool | Whether the number of members pruned should be calculated (disable this for large guilds) | True |
reason | Absent[str] | The reason for this prune | MISSING |
Returns:
Type | Description |
---|---|
Optional[int] | The total number of members pruned, if |
Source code in interactions/models/discord/guild.py
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 |
|
search_members(query, limit=1)
async
¶
Search for members in the guild whose username or nickname starts with a provided string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query | str | Query string to match username(s) and nickname(s) against. | required |
limit | int | Max number of members to return (1-1000) | 1 |
Returns:
Type | Description |
---|---|
List[Member] | A list of members matching the query. |
Source code in interactions/models/discord/guild.py
2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 |
|
unban(user, reason=MISSING)
async
¶
Unban a user from the guild.
Note
You must have the ban members
permission
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Member, Snowflake_Type] | The user to unban | required |
reason | Absent[str] | The reason for the ban | MISSING |
Source code in interactions/models/discord/guild.py
1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 |
|
GuildBan
¶
Source code in interactions/models/discord/guild.py
81 82 83 84 85 86 |
|
GuildIntegration
¶
Bases: DiscordObject
Source code in interactions/models/discord/guild.py
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 |
|
account: dict = attrs.field(repr=False)
class-attribute
¶
integration account information
application: Optional[models.Application] = attrs.field(repr=False, default=None)
class-attribute
¶
The bot/OAuth2 application for discord integrations
enable_emoticons: bool = attrs.field(repr=False, default=MISSING)
class-attribute
¶
whether emoticons should be synced for this integration (twitch only currently)
enabled: bool = attrs.field(repr=True)
class-attribute
¶
is this integration enabled
expire_behavior: IntegrationExpireBehaviour = attrs.field(repr=False, default=MISSING, converter=optional(IntegrationExpireBehaviour))
class-attribute
¶
the behavior of expiring subscribers
expire_grace_period: int = attrs.field(repr=False, default=MISSING)
class-attribute
¶
the grace period (in days) before expiring subscribers
name: str = attrs.field(repr=True)
class-attribute
¶
The name of the integration
revoked: bool = attrs.field(repr=False, default=MISSING)
class-attribute
¶
has this integration been revoked
role_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
id that this integration uses for "subscribers"
subscriber_count: int = attrs.field(repr=False, default=MISSING)
class-attribute
¶
how many subscribers this integration has
synced_at: models.Timestamp = attrs.field(repr=False, default=MISSING, converter=optional(timestamp_converter))
class-attribute
¶
when this integration was last synced
syncing: Optional[bool] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
is this integration syncing
type: str = attrs.field(repr=True)
class-attribute
¶
integration type (twitch, youtube, or discord)
user: models.BaseUser = attrs.field(repr=False, default=MISSING)
class-attribute
¶
user for this integration
delete(reason=MISSING)
async
¶
Delete this guild integration.
Source code in interactions/models/discord/guild.py
2303 2304 2305 |
|
GuildPreview
¶
Bases: BaseGuild
A partial guild object.
Source code in interactions/models/discord/guild.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
approximate_member_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
Approximate number of members in this guild
approximate_presence_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
Approximate number of online members in this guild
emoji: list[models.PartialEmoji] = attrs.field(repr=False, factory=list)
class-attribute
¶
A list of custom emoji from this guild
GuildTemplate
¶
Bases: ClientObject
Source code in interactions/models/discord/guild.py
2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 |
|
delete()
async
¶
Delete the guild template.
Source code in interactions/models/discord/guild.py
2237 2238 2239 |
|
modify(name=MISSING, description=MISSING)
async
¶
Modify the template's metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | The name for the template | MISSING |
description | Absent[str] | The description for the template | MISSING |
Returns:
Type | Description |
---|---|
GuildTemplate | The modified template object. |
Source code in interactions/models/discord/guild.py
2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 |
|
synchronise()
async
¶
Synchronise the template to the source guild's current state.
Source code in interactions/models/discord/guild.py
2213 2214 2215 2216 2217 |
|
GuildWidget
¶
Bases: DiscordObject
Source code in interactions/models/discord/guild.py
2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 |
|
instant_invite: str = attrs.field(repr=True, default=None)
class-attribute
¶
Instant invite for the guilds specified widget invite channel
name: str = attrs.field(repr=True)
class-attribute
¶
Guild name (2-100 characters)
presence_count: int = attrs.field(repr=True, default=0)
class-attribute
¶
Number of online members in this guild
fetch_channels(*, force=False)
async
¶
Gets voice and stage channels which are accessible by @everyone. Fetches the channels from API if they are not cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force fetch the channels from API | False |
Returns:
Type | Description |
---|---|
List[TYPE_VOICE_CHANNEL] | List of channels |
Source code in interactions/models/discord/guild.py
2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 |
|
fetch_members(*, force=False)
async
¶
Gets special widget user objects that includes users presence (Limit 100). Fetches the users from API if they are not cached.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force fetch the users from API | False |
Returns:
Type | Description |
---|---|
List[User] | List of users |
Source code in interactions/models/discord/guild.py
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 |
|
get_channels()
¶
Gets voice and stage channels which are accessible by @everyone
Returns:
Type | Description |
---|---|
List[TYPE_VOICE_CHANNEL] | List of channels |
Source code in interactions/models/discord/guild.py
2336 2337 2338 2339 2340 2341 2342 2343 2344 |
|
get_members()
¶
Gets special widget user objects that includes users presence (Limit 100)
Returns:
Type | Description |
---|---|
List[User] | List of users |
Source code in interactions/models/discord/guild.py
2359 2360 2361 2362 2363 2364 2365 2366 2367 |
|
GuildWidgetSettings
¶
Bases: DictSerializationMixin
Source code in interactions/models/discord/guild.py
2308 2309 2310 2311 2312 |
|
ScheduledEvent
¶
Bases: DiscordObject
Source code in interactions/models/discord/scheduled_event.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
cover: Asset | None = attrs.field(repr=False, default=None)
class-attribute
¶
The cover image of this event
creator: Optional[User]
async
property
¶
Returns the user who created this event.
Note
Events made before October 25th, 2021 will not have a creator.
end_time: Optional[Timestamp] = attrs.field(repr=False, default=None, converter=optional(timestamp_converter))
class-attribute
¶
Optional Timstamp object representing the scheduled end time, required if entity_type is EXTERNAL
entity_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=MISSING, converter=optional(to_snowflake))
class-attribute
¶
The id of an entity associated with a guild scheduled event
entity_metadata: Optional[Dict[str, Any]] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
The metadata associated with the entity_type
entity_type: Union[ScheduledEventType, int] = attrs.field(repr=False, converter=ScheduledEventType)
class-attribute
¶
The type of the scheduled event
location: Optional[str]
property
¶
Returns the external locatian of this event.
privacy_level: Union[ScheduledEventPrivacyLevel, int] = attrs.field(repr=False, converter=ScheduledEventPrivacyLevel)
class-attribute
¶
Privacy level of the scheduled event
Note
Discord only has GUILD_ONLY
at the momment.
start_time: Timestamp = attrs.field(repr=False, converter=timestamp_converter)
class-attribute
¶
A Timestamp object representing the scheduled start time of the event
status: Union[ScheduledEventStatus, int] = attrs.field(repr=False, converter=ScheduledEventStatus)
class-attribute
¶
Current status of the scheduled event
user_count: Absent[int] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
Amount of users subscribed to the scheduled event
delete(reason=MISSING)
async
¶
Deletes this event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[str] | The reason for deleting this event | MISSING |
Source code in interactions/models/discord/scheduled_event.py
156 157 158 159 160 161 162 163 164 |
|
edit(*, name=MISSING, start_time=MISSING, end_time=MISSING, status=MISSING, description=MISSING, channel_id=MISSING, event_type=MISSING, external_location=MISSING, entity_metadata=MISSING, privacy_level=MISSING, cover_image=MISSING, reason=MISSING)
async
¶
Edits this event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | The name of the event | MISSING |
description | Absent[str] | The description of the event | MISSING |
channel_id | Absent[Optional[Snowflake_Type]] | The channel id of the event | MISSING |
event_type | Absent[ScheduledEventType] | The type of the event | MISSING |
start_time | Absent[Timestamp] | The scheduled start time of the event | MISSING |
end_time | Absent[Timestamp] | The scheduled end time of the event | MISSING |
status | Absent[ScheduledEventStatus] | The status of the event | MISSING |
external_location | Absent[Optional[str]] | The location of the event (1-100 characters) | MISSING |
entity_metadata | Absent[dict] | The metadata of the event | MISSING |
privacy_level | Absent[ScheduledEventPrivacyLevel] | The privacy level of the event | MISSING |
cover_image | Absent[UPLOADABLE_TYPE] | the cover image of the scheduled event | MISSING |
reason | Absent[str] | The reason for editing the event | MISSING |
Note
If updating event_type to EXTERNAL: channel_id
is required and must be set to null
1 2 3 |
|
Source code in interactions/models/discord/scheduled_event.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
fetch_channel(*, force=False)
async
¶
Returns the channel this event is scheduled in if it is scheduled in a channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force fetch the channel from the API | False |
Source code in interactions/models/discord/scheduled_event.py
105 106 107 108 109 110 111 112 113 114 115 |
|
fetch_event_users(limit=100, with_member_data=False, before=MISSING, after=MISSING)
async
¶
Fetch event users.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | Optional[int] | Discord defualts to 100 | 100 |
with_member_data | bool | Whether to include guild member data | False |
before | Absent[Optional[Snowflake_Type]] | Snowflake of a user to get before | MISSING |
after | Absent[Optional[Snowflake_Type]] | Snowflake of a user to get after | MISSING |
Note
This method is paginated
Source code in interactions/models/discord/scheduled_event.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
get_channel()
¶
Returns the channel this event is scheduled in if it is scheduled in a channel.
Source code in interactions/models/discord/scheduled_event.py
117 118 119 120 121 |
|
Sticker
¶
Bases: StickerItem
Represents a sticker that can be sent in messages.
Source code in interactions/models/discord/sticker.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
available: Optional[bool] = attrs.field(repr=False, default=True)
class-attribute
¶
Whether this guild sticker can be used, may be false due to loss of Server Boosts.
description: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
Description of the sticker.
pack_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=optional(to_snowflake))
class-attribute
¶
For standard stickers, id of the pack the sticker is from.
sort_value: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
The standard sticker's sort order within its pack.
tags: str = attrs.field(repr=False)
class-attribute
¶
autocomplete/suggestion tags for the sticker (max 200 characters)
type: Union[StickerTypes, int] = attrs.field(repr=False, converter=StickerTypes)
class-attribute
¶
Type of sticker.
url: str
property
¶
CDN url for the sticker.
delete(reason=MISSING)
async
¶
Delete a sticker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Optional[str] | Reason for the deletion | MISSING |
Raises:
Type | Description |
---|---|
ValueError | If you attempt to delete a non-guild sticker |
Source code in interactions/models/discord/sticker.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
edit(*, name=MISSING, description=MISSING, tags=MISSING, reason=MISSING)
async
¶
Edit a sticker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[Optional[str]] | New name of the sticker | MISSING |
description | Absent[Optional[str]] | New description of the sticker | MISSING |
tags | Absent[Optional[str]] | New tags of the sticker | MISSING |
reason | Absent[Optional[str]] | Reason for the edit | MISSING |
Returns:
Type | Description |
---|---|
Sticker | The updated sticker instance |
Source code in interactions/models/discord/sticker.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
fetch_creator(*, force=False)
async
¶
Fetch the user who created this emoji.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
User | User object |
Source code in interactions/models/discord/sticker.py
48 49 50 51 52 53 54 55 56 57 58 59 |
|
fetch_guild(*, force=False)
async
¶
Fetch the guild associated with this emoji.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
Guild | Guild object |
Source code in interactions/models/discord/sticker.py
71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_creator()
¶
Get the user who created this emoji.
Returns:
Type | Description |
---|---|
User | User object |
Source code in interactions/models/discord/sticker.py
61 62 63 64 65 66 67 68 69 |
|
get_guild()
¶
Get the guild associated with this emoji.
Returns:
Type | Description |
---|---|
Guild | Guild object |
Source code in interactions/models/discord/sticker.py
84 85 86 87 88 89 90 91 92 |
|
StickerItem
¶
Bases: DiscordObject
Source code in interactions/models/discord/sticker.py
20 21 22 23 24 25 |
|
StickerPack
¶
Bases: DiscordObject
Represents a pack of standard stickers.
Source code in interactions/models/discord/sticker.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
banner_asset_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
id of the sticker pack's banner image.
cover_sticker_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
id of a sticker in the pack which is shown as the pack's icon.
description: str = attrs.field(repr=False)
class-attribute
¶
Description of the sticker pack.
name: str = attrs.field(repr=True)
class-attribute
¶
Name of the sticker pack.
sku_id: Snowflake_Type = attrs.field(repr=True)
class-attribute
¶
id of the pack's SKU.
stickers: List[Sticker] = attrs.field(repr=False, factory=list)
class-attribute
¶
The stickers in the pack.
Webhook
¶
Bases: DiscordObject
, SendMixin
Source code in interactions/models/discord/webhooks.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
application_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the bot/OAuth2 application that created this webhook
avatar: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
the default user avatar hash of the webhook
channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the channel id this webhook is for, if any
guild_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the guild id this webhook is for, if any
name: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
the default name of the webhook
source_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the channel that this webhook is following (returned for Channel Follower Webhooks)
source_guild_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
token: str = attrs.field(repr=False, default=MISSING)
class-attribute
¶
the secure token of the webhook (returned for Incoming Webhooks)
type: WebhookTypes = attrs.field(repr=False)
class-attribute
¶
The type of webhook
url: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
the url used for executing the webhook (returned by the webhooks OAuth2 flow)
user_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
the user this webhook was created by
create(client, channel, name, avatar=MISSING)
classmethod
async
¶
Create a webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client | Client | The bot's client | required |
channel | Union[Snowflake_Type, TYPE_MESSAGEABLE_CHANNEL] | The channel to create the webhook in | required |
name | str | The name of the webhook | required |
avatar | Absent[UPLOADABLE_TYPE] | An optional default avatar to use | MISSING |
Returns:
Type | Description |
---|---|
Webhook | New webhook object |
Raises:
Type | Description |
---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in interactions/models/discord/webhooks.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
delete()
async
¶
Delete this webhook.
Source code in interactions/models/discord/webhooks.py
168 169 170 |
|
delete_message(message, *, delay=0)
async
¶
Delete a message as this webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | Union[Message, Snowflake_Type] | Message to delete | required |
delay | int | Seconds to wait before deleting message. | 0 |
Source code in interactions/models/discord/webhooks.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
edit(*, name=MISSING, avatar=MISSING, channel_id=MISSING)
async
¶
Edit this webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | The default name of the webhook. | MISSING |
avatar | Absent[UPLOADABLE_TYPE] | The image for the default webhook avatar. | MISSING |
channel_id | Absent[Snowflake_Type] | The new channel id this webhook should be moved to. | MISSING |
Raises:
Type | Description |
---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in interactions/models/discord/webhooks.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
edit_message(message, *, content=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, flags=None)
async
¶
Edit a message as this webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | Union[Message, Snowflake_Type] | Message to edit | required |
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
Returns:
Type | Description |
---|---|
Optional[Message] | Updated message object that was sent if |
Source code in interactions/models/discord/webhooks.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
fetch_message(message_id)
async
¶
Returns a previously-sent webhook message from the same token. Returns a message object on success.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_id | Union[Message, Snowflake_Type] | ID of message to retrieve. | required |
Returns:
Type | Description |
---|---|
Optional[Message] | The message object fetched. If the message is not found, returns None. |
Source code in interactions/models/discord/webhooks.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
from_url(url, client)
classmethod
¶
Webhook object from a URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client | Client | The client to use to make the request. | required |
url | str | Webhook URL | required |
Returns:
Type | Description |
---|---|
Webhook | A Webhook object. |
Source code in interactions/models/discord/webhooks.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
send(content=None, *, embed=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, suppress_embeds=False, flags=None, poll=None, username=None, avatar_url=None, wait=False, thread=None, **kwargs)
async
¶
Send a message as this webhook.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
suppress_embeds | bool | Should embeds be suppressed on this send | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
poll | Optional[Poll | dict] | A poll. | None |
username | str | None | The username to use | None |
avatar_url | str | None | The url of an image to use as the avatar | None |
wait | bool | Waits for confirmation of delivery. Set this to True if you intend to edit the message | False |
thread | Snowflake_Type | Send this webhook to a thread channel | None |
Returns:
Type | Description |
---|---|
Optional[Message] | New message object that was sent if |
Source code in interactions/models/discord/webhooks.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
WebhookTypes
¶
Bases: IntEnum
Source code in interactions/models/discord/webhooks.py
36 37 38 39 40 41 42 |
|
APPLICATION = 3
class-attribute
¶
Application webhooks are webhooks used with Interactions
CHANNEL_FOLLOWER = 2
class-attribute
¶
Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
INCOMING = 1
class-attribute
¶
Incoming Webhooks can post messages to channels with a generated token
BaseChannel
¶
Bases: DiscordObject
Source code in interactions/models/discord/channel.py
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 |
|
mention: str
property
¶
Returns a string that would mention the channel.
name: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
The name of the channel (1-100 characters)
permissions: Optional[Permissions] = attrs.field(repr=False, default=None, converter=optional_c(Permissions))
class-attribute
¶
Calculated permissions for the bot in this channel, only given when using channels as an option with slash commands
type: Union[ChannelType, int] = attrs.field(repr=True, converter=ChannelType)
class-attribute
¶
The channel topic (0-1024 characters)
delete(reason=MISSING)
async
¶
Delete this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[Optional[str]] | The reason for deleting this channel | MISSING |
Source code in interactions/models/discord/channel.py
903 904 905 906 907 908 909 910 911 |
|
edit(*, name=MISSING, icon=MISSING, type=MISSING, position=MISSING, topic=MISSING, nsfw=MISSING, rate_limit_per_user=MISSING, bitrate=MISSING, user_limit=MISSING, permission_overwrites=MISSING, parent_id=MISSING, rtc_region=MISSING, video_quality_mode=MISSING, default_auto_archive_duration=MISSING, flags=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, invitable=MISSING, reason=MISSING, **kwargs)
async
¶
Edits the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
icon | Absent[UPLOADABLE_TYPE] | DM Group icon | MISSING |
type | Absent[ChannelType] | The type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
position | Absent[int] | The position of the channel in the left-hand listing | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
nsfw | Absent[bool] | Whether the channel is nsfw | MISSING |
rate_limit_per_user | Absent[int] | Amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
bitrate | Absent[int] | The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) | MISSING |
user_limit | Absent[int] | The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Channel or category-specific permissions | MISSING |
parent_id | Absent[Snowflake_Type] | The id of the new parent category for a channel | MISSING |
rtc_region | Absent[Union[VoiceRegion, str]] | Channel voice region id, automatic when set to None. | MISSING |
video_quality_mode | Absent[VideoQualityMode] | The camera video quality mode of the voice channel | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | The default duration that the clients use (not the API) for newly created threads in the channel, in minutes, to automatically archive the thread after recent activity | MISSING |
flags | Absent[Union[int, ChannelFlags]] | Channel flags combined as a bitfield. Only REQUIRE_TAG is supported for now. | MISSING |
archived | Absent[bool] | Whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | Whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
invitable | Absent[bool] | Whether non-moderators can add other non-moderators to a thread; only available on private threads | MISSING |
reason | Absent[str] | The reason for editing the channel | MISSING |
Returns:
Type | Description |
---|---|
TYPE_ALL_CHANNEL | The edited channel. May be a new object if the channel type changes. |
Source code in interactions/models/discord/channel.py
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
|
from_dict_factory(data, client)
classmethod
¶
Creates a channel object of the appropriate type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | The channel data. | required |
client | Client | The bot. | required |
Returns:
Type | Description |
---|---|
TYPE_ALL_CHANNEL | The new channel object. |
Source code in interactions/models/discord/channel.py
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
|
ChannelHistory
¶
Bases: AsyncIterator
An async iterator for searching through a channel's history.
Attributes:
Name | Type | Description |
---|---|---|
channel | BaseChannel | The channel to search through |
limit | BaseChannel | The maximum number of messages to return (set to 0 for no limit) |
before | Snowflake_Type | get messages before this message ID |
after | Snowflake_Type | get messages after this message ID |
around | Snowflake_Type | get messages "around" this message ID |
Source code in interactions/models/discord/channel.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
fetch()
async
¶
Fetch additional objects.
Your implementation of this method must return a list of objects. If no more objects are available, raise QueueEmpty
Returns:
Type | Description |
---|---|
List[Message] | List of objects |
Raises:
Type | Description |
---|---|
QueueEmpty | when no more objects are available. |
Source code in interactions/models/discord/channel.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
DM
¶
Bases: DMChannel
Source code in interactions/models/discord/channel.py
939 940 941 942 943 944 |
|
recipient: models.User
property
¶
Returns the user that is in this DM channel.
DMChannel
¶
Bases: BaseChannel
, MessageableMixin
Source code in interactions/models/discord/channel.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 |
|
DMGroup
¶
Bases: DMChannel
Source code in interactions/models/discord/channel.py
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
|
application_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
Application id of the group DM creator if it is bot-created
owner_id: Snowflake_Type = attrs.field(repr=True)
class-attribute
¶
id of the creator of the group DM
add_recipient(user, access_token, nickname=MISSING)
async
¶
Add a recipient to this DM Group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Snowflake_Type] | The user to add | required |
access_token | str | access token of a user that has granted your app the gdm.join scope | required |
nickname | Absent[Optional[str]] | nickname to apply to the user being added | MISSING |
Source code in interactions/models/discord/channel.py
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 |
|
edit(*, name=MISSING, icon=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this DM Channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
icon | Absent[UPLOADABLE_TYPE] | An icon to use | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Source code in interactions/models/discord/channel.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
|
fetch_owner(*, force=False)
async
¶
Fetch the owner of this DM group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API | False |
Source code in interactions/models/discord/channel.py
973 974 975 976 977 978 979 980 981 |
|
get_owner()
¶
Get the owner of this DM group
Source code in interactions/models/discord/channel.py
983 984 985 |
|
remove_recipient(user)
async
¶
Remove a recipient from this DM Group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[User, Snowflake_Type] | The user to remove | required |
Source code in interactions/models/discord/channel.py
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
|
GuildCategory
¶
Bases: GuildChannel
Source code in interactions/models/discord/channel.py
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
|
channels: List[TYPE_GUILD_CHANNEL]
property
¶
Get all channels within the category
news_channels: List[GuildNews]
property
¶
Get all news channels within the category
stage_channels: List[GuildStageVoice]
property
¶
Get all stage channels within the category
text_channels: List[GuildText]
property
¶
Get all text channels within the category
voice_channels: List[GuildVoice]
property
¶
Get all voice channels within the category
create_channel(channel_type, name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, bitrate=64000, user_limit=0, rate_limit_per_user=0, reason=MISSING)
async
¶
Create a guild channel within this category, allows for explicit channel type setting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel_type | Union[ChannelType, int] | The type of channel to create | required |
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in interactions/models/discord/channel.py
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 |
|
create_news_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, reason=MISSING)
async
¶
Create a news channel in this guild within this category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildNews | The newly created news channel. |
Source code in interactions/models/discord/channel.py
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 |
|
create_stage_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, bitrate=64000, user_limit=0, reason=MISSING)
async
¶
Create a guild stage channel within this category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildStageVoice | The newly created stage channel. |
Source code in interactions/models/discord/channel.py
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 |
|
create_text_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, rate_limit_per_user=0, reason=MISSING)
async
¶
Create a text channel in this guild within this category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
rate_limit_per_user | int | The time users must wait between sending messages | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildText | The newly created text channel. |
Source code in interactions/models/discord/channel.py
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
|
create_voice_channel(name, topic=MISSING, position=MISSING, permission_overwrites=MISSING, nsfw=False, bitrate=64000, user_limit=0, reason=MISSING)
async
¶
Create a guild voice channel within this category.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the channel | required |
topic | Absent[Optional[str]] | The topic of the channel | MISSING |
position | Absent[Optional[int]] | The position of the channel in the channel list | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | Permission overwrites to apply to the channel | MISSING |
nsfw | bool | Should this channel be marked nsfw | False |
bitrate | int | The bitrate of this channel, only for voice | 64000 |
user_limit | int | The max users that can be in this channel, only for voice | 0 |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
GuildVoice | The newly created voice channel. |
Source code in interactions/models/discord/channel.py
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 |
|
edit(*, name=MISSING, position=MISSING, permission_overwrites=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | channel or category-specific permissions | MISSING |
reason | Absent[str] | the reason for this change | MISSING |
Returns:
Type | Description |
---|---|
GuildCategory | The updated channel object. |
Source code in interactions/models/discord/channel.py
1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 |
|
GuildChannel
¶
Bases: BaseChannel
Source code in interactions/models/discord/channel.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
|
bots: List[models.Member]
property
¶
Returns a list of bots that can see this channel.
category: Optional[GuildCategory]
property
¶
The parent category of this channel.
gui_position: int
property
¶
The position of this channel in the Discord interface.
guild: models.Guild
property
¶
The guild this channel belongs to.
humans: List[models.Member]
property
¶
Returns a list of humans that can see this channel.
members: List[models.Member]
property
¶
Returns a list of members that can see this channel.
nsfw: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether the channel is nsfw
parent_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the parent category for a channel (each parent category can contain up to 50 channels)
permission_overwrites: list[PermissionOverwrite] = attrs.field(repr=False, factory=list)
class-attribute
¶
A list of the overwritten permissions for the members and roles
position: Optional[int] = attrs.field(repr=False, default=0)
class-attribute
¶
Sorting position of the channel
add_permission(target, type=None, allow=None, deny=None, reason=None)
async
¶
Add a permission to this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Union[PermissionOverwrite, Role, User, Member, Snowflake_Type] | The updated PermissionOverwrite object, or the Role or User object/id to update | required |
type | Optional[OverwriteType] | The type of permission overwrite. Only applicable if target is an id | None |
allow | Optional[List[Permissions] | int] | List of permissions to allow. Only applicable if target is not an PermissionOverwrite object | None |
deny | Optional[List[Permissions] | int] | List of permissions to deny. Only applicable if target is not an PermissionOverwrite object | None |
reason | Optional[str] | The reason for this change | None |
Raises:
Type | Description |
---|---|
ValueError | Invalid target for permission |
Source code in interactions/models/discord/channel.py
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
|
clone(name=None, reason=MISSING)
async
¶
Clone this channel and create a new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Optional[str] | The name of the new channel. Defaults to the current name | None |
reason | Absent[Optional[str]] | The reason for creating this channel | MISSING |
Returns:
Type | Description |
---|---|
TYPE_GUILD_CHANNEL | The newly created channel. |
Source code in interactions/models/discord/channel.py
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
|
delete_permission(target, reason=MISSING)
async
¶
Delete a permission overwrite for this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Union[PermissionOverwrite, Role, User] | The permission overwrite to delete | required |
reason | Absent[Optional[str]] | The reason for this change | MISSING |
Source code in interactions/models/discord/channel.py
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 |
|
edit_permission(overwrite, reason=None)
async
¶
Edit the permissions for this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
overwrite | PermissionOverwrite | The permission overwrite to apply | required |
reason | Optional[str] | The reason for this change | None |
Source code in interactions/models/discord/channel.py
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
|
permissions_for(instance)
¶
Calculates permissions for an instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance | Snowflake_Type | Member or Role instance (or its ID) | required |
Returns:
Type | Description |
---|---|
Permissions | Permissions data |
Raises:
Type | Description |
---|---|
ValueError | If could not find any member or role by given ID |
RuntimeError | If given instance is from another guild |
Source code in interactions/models/discord/channel.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
|
set_permission(target, *, add_reactions=None, administrator=None, attach_files=None, ban_members=None, change_nickname=None, connect=None, create_instant_invite=None, deafen_members=None, embed_links=None, kick_members=None, manage_channels=None, manage_emojis_and_stickers=None, manage_events=None, manage_guild=None, manage_messages=None, manage_nicknames=None, manage_roles=None, manage_threads=None, manage_webhooks=None, mention_everyone=None, moderate_members=None, move_members=None, mute_members=None, priority_speaker=None, read_message_history=None, request_to_speak=None, send_messages=None, send_messages_in_threads=None, send_tts_messages=None, speak=None, start_embedded_activities=None, stream=None, use_application_commands=None, use_external_emojis=None, use_external_stickers=None, use_private_threads=None, use_public_threads=None, use_vad=None, view_audit_log=None, view_channel=None, view_guild_insights=None, reason=None)
async
¶
Set the Permission Overwrites for a given target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target | Union[Role, Member, User] | The target to set permission overwrites for | required |
add_reactions | bool | None | Allows for the addition of reactions to messages | None |
administrator | bool | None | Allows all permissions and bypasses channel permission overwrites | None |
attach_files | bool | None | Allows for uploading images and files | None |
ban_members | bool | None | Allows banning members | None |
change_nickname | bool | None | Allows for modification of own nickname | None |
connect | bool | None | Allows for joining of a voice channel | None |
create_instant_invite | bool | None | Allows creation of instant invites | None |
deafen_members | bool | None | Allows for deafening of members in a voice channel | None |
embed_links | bool | None | Links sent by users with this permission will be auto-embedded | None |
kick_members | bool | None | Allows kicking members | None |
manage_channels | bool | None | Allows management and editing of channels | None |
manage_emojis_and_stickers | bool | None | Allows management and editing of emojis and stickers | None |
manage_events | bool | None | Allows for creating, editing, and deleting scheduled events | None |
manage_guild | bool | None | Allows management and editing of the guild | None |
manage_messages | bool | None | Allows for deletion of other users messages | None |
manage_nicknames | bool | None | Allows for modification of other users nicknames | None |
manage_roles | bool | None | Allows management and editing of roles | None |
manage_threads | bool | None | Allows for deleting and archiving threads, and viewing all private threads | None |
manage_webhooks | bool | None | Allows management and editing of webhooks | None |
mention_everyone | bool | None | Allows for using the | None |
moderate_members | bool | None | Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels | None |
move_members | bool | None | Allows for moving of members between voice channels | None |
mute_members | bool | None | Allows for muting members in a voice channel | None |
priority_speaker | bool | None | Allows for using priority speaker in a voice channel | None |
read_message_history | bool | None | Allows for reading of message history | None |
request_to_speak | bool | None | Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) | None |
send_messages | bool | None | Allows for sending messages in a channel (does not allow sending messages in threads) | None |
send_messages_in_threads | bool | None | Allows for sending messages in threads | None |
send_tts_messages | bool | None | Allows for sending of | None |
speak | bool | None | Allows for speaking in a voice channel | None |
start_embedded_activities | bool | None | Allows for using Activities (applications with the | None |
stream | bool | None | Allows the user to go live | None |
use_application_commands | bool | None | Allows members to use application commands, including slash commands and context menu commands | None |
use_external_emojis | bool | None | Allows the usage of custom emojis from other servers | None |
use_external_stickers | bool | None | Allows the usage of custom stickers from other servers | None |
use_private_threads | bool | None | Allows for creating private threads | None |
use_public_threads | bool | None | Allows for creating public and announcement threads | None |
use_vad | bool | None | Allows for using voice-activity-detection in a voice channel | None |
view_audit_log | bool | None | Allows for viewing of audit logs | None |
view_channel | bool | None | Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels | None |
view_guild_insights | bool | None | Allows for viewing guild insights | None |
reason | str | None | The reason for creating this overwrite | None |
Source code in interactions/models/discord/channel.py
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
|
GuildForum
¶
Bases: GuildChannel
, InvitableMixin
Source code in interactions/models/discord/channel.py
2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 |
|
available_tags: List[ThreadTag] = attrs.field(repr=False, factory=list)
class-attribute
¶
A list of tags available to assign to threads
default_forum_layout: ForumLayoutType = attrs.field(repr=False, default=ForumLayoutType.NOT_SET, converter=ForumLayoutType)
class-attribute
¶
The default forum layout view used to display posts in GUILD_FORUM channels. Defaults to 0, which indicates a layout view has not been set by a channel admin
default_reaction_emoji: Optional[DefaultReaction] = attrs.field(repr=False, default=None)
class-attribute
¶
The default emoji to react with for posts
default_sort_order: Optional[ForumSortOrder] = attrs.field(repr=False, default=None, converter=ForumSortOrder.converter)
class-attribute
¶
the default sort order type used to order posts in GUILD_FORUM channels. Defaults to null, which indicates a preferred sort order hasn't been set by a channel admin
rate_limit_per_user: int = attrs.field(repr=False, default=0)
class-attribute
¶
Amount of seconds a user has to wait before sending another message (0-21600)
archived_posts(limit=0, before=None)
¶
An async iterator for all archived posts in this channel.
Source code in interactions/models/discord/channel.py
2544 2545 2546 |
|
create_post(name, content, applied_tags=MISSING, *, auto_archive_duration=AutoArchiveDuration.ONE_DAY, rate_limit_per_user=MISSING, embeds=None, embed=None, components=None, stickers=None, allowed_mentions=None, files=None, file=None, tts=False, reason=MISSING)
async
¶
Create a post within this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the post | required |
content | str | None | The text content of this post | required |
applied_tags | Absent[List[Union[Snowflake_Type, ThreadTag, str]]] | A list of tag ids or tag objects to apply to this post | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
rate_limit_per_user | Absent[int] | The time users must wait between sending messages | MISSING |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
files | Optional[Union[UPLOADABLE_TYPE, List[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
reason | Absent[str] | The reason for creating this post | MISSING |
Returns:
Type | Description |
---|---|
GuildForumPost | A GuildForumPost object representing the created post. |
Source code in interactions/models/discord/channel.py
2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 |
|
create_tag(name, emoji=None, moderated=False)
async
¶
Create a tag for this forum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the tag | required |
emoji | Union[PartialEmoji, dict, str, None] | The emoji to use for the tag | None |
moderated | bool | whether this tag can only be added to or removed from threads by a member with the MANAGE_THREADS permission | False |
Note
If the emoji is a custom emoji, it must be from the same guild as the channel.
Returns:
Type | Description |
---|---|
ThreadTag | The created tag object. |
Source code in interactions/models/discord/channel.py
2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 |
|
delete_tag(tag_id)
async
¶
Delete a tag for this forum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_id | Snowflake_Type | The ID of the tag to delete | required |
Source code in interactions/models/discord/channel.py
2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 |
|
edit_tag(tag_id, *, name=None, emoji=None)
async
¶
Edit a tag for this forum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_id | Snowflake_Type | The id of the tag to edit | required |
name | str | None | The name for this tag | None |
emoji | Union[PartialEmoji, dict, str, None] | The emoji for this tag | None |
Source code in interactions/models/discord/channel.py
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 |
|
fetch_post(id, *, force=False)
async
¶
Fetch a post within this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id | Snowflake_Type | The id of the post to fetch | required |
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
GuildForumPost | A GuildForumPost object representing the post. |
Source code in interactions/models/discord/channel.py
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 |
|
fetch_posts()
async
¶
Requests all active posts within this channel.
Returns:
Type | Description |
---|---|
List[GuildForumPost] | A list of GuildForumPost objects representing the posts. |
Source code in interactions/models/discord/channel.py
2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 |
|
get_post(id)
¶
Get a post within this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id | Snowflake_Type | The id of the post to get | required |
Returns:
Type | Description |
---|---|
GuildForumPost | A GuildForumPost object representing the post. |
Source code in interactions/models/discord/channel.py
2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 |
|
get_posts(*, exclude_archived=True)
¶
List all, cached, active posts within this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exclude_archived | bool | Whether to exclude archived posts from the response | True |
Returns:
Type | Description |
---|---|
List[GuildForumPost] | A list of GuildForumPost objects representing the posts. |
Source code in interactions/models/discord/channel.py
2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
|
get_tag(value, *, case_insensitive=False)
¶
Get a tag within this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | str | Snowflake_Type | The name or ID of the tag to get | required |
case_insensitive | bool | Whether to ignore case when searching for the tag | False |
Returns:
Type | Description |
---|---|
Optional[ThreadTag] | A ThreadTag object representing the tag. |
Source code in interactions/models/discord/channel.py
2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 |
|
GuildForumPost
¶
Bases: GuildPublicThread
A forum post
Note
This model is an abstraction of the api - In reality all posts are GuildPublicThread
Source code in interactions/models/discord/channel.py
2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
|
applied_tags: list[ThreadTag]
property
¶
The tags applied to this thread.
initial_post: Optional[Message]
property
¶
The initial message posted by the OP.
pinned: bool
property
¶
Whether this thread is pinned.
edit(*, name=MISSING, archived=MISSING, auto_archive_duration=MISSING, applied_tags=MISSING, locked=MISSING, rate_limit_per_user=MISSING, flags=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
applied_tags | Absent[List[Union[Snowflake_Type, ThreadTag]]] | list of tags to apply | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
flags | Absent[Union[int, ChannelFlags]] | channel flags to apply | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
Type | Description |
---|---|
GuildForumPost | The edited thread channel object. |
Source code in interactions/models/discord/channel.py
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 |
|
pin(reason=MISSING)
async
¶
Pin this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[str] | The reason for this pin | MISSING |
Source code in interactions/models/discord/channel.py
2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 |
|
unpin(reason=MISSING)
async
¶
Unpin this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[str] | The reason for this unpin | MISSING |
Source code in interactions/models/discord/channel.py
2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
|
GuildNews
¶
Bases: GuildChannel
, MessageableMixin
, InvitableMixin
, ThreadableMixin
, WebhookMixin
Source code in interactions/models/discord/channel.py
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
|
topic: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The channel topic (0-1024 characters)
create_thread_from_message(name, message, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None)
async
¶
Creates a new news thread in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-100 character thread name. | required |
message | Snowflake_Type | The message to connect this thread to. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | None | The reason for creating this thread. | None |
Returns:
Type | Description |
---|---|
GuildNewsThread | The created public thread, if successful |
Source code in interactions/models/discord/channel.py
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
|
edit(*, name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, nsfw=MISSING, topic=MISSING, channel_type=MISSING, default_auto_archive_duration=MISSING, reason=MISSING, **kwargs)
async
¶
Edit the guild text channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of PermissionOverwrite | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
nsfw | Absent[bool] | whether the channel is nsfw | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
channel_type | Absent[ChannelType] | the type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | optional AutoArchiveDuration | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Returns:
Type | Description |
---|---|
Union[GuildNews, GuildText] | The edited channel. |
Source code in interactions/models/discord/channel.py
1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 |
|
follow(webhook_channel_id)
async
¶
Follow this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webhook_channel_id | Snowflake_Type | The ID of the channel to post messages from this channel to | required |
Source code in interactions/models/discord/channel.py
1663 1664 1665 1666 1667 1668 1669 1670 1671 |
|
GuildNewsThread
¶
Bases: ThreadChannel
Source code in interactions/models/discord/channel.py
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 |
|
edit(*, name=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, rate_limit_per_user=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
Type | Description |
---|---|
GuildNewsThread | The edited thread channel object. |
Source code in interactions/models/discord/channel.py
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 |
|
GuildPrivateThread
¶
Bases: ThreadChannel
Source code in interactions/models/discord/channel.py
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 |
|
invitable: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether non-moderators can add other non-moderators to a thread
edit(*, name=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, rate_limit_per_user=MISSING, invitable=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
invitable | Absent[bool] | whether non-moderators can add other non-moderators to a thread; only available on private threads | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
Type | Description |
---|---|
GuildPrivateThread | The edited thread channel object. |
Source code in interactions/models/discord/channel.py
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 |
|
GuildPublicThread
¶
Bases: ThreadChannel
Source code in interactions/models/discord/channel.py
2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 |
|
edit(*, name=MISSING, archived=MISSING, auto_archive_duration=MISSING, locked=MISSING, rate_limit_per_user=MISSING, flags=MISSING, reason=MISSING, **kwargs)
async
¶
Edit this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
archived | Absent[bool] | whether the thread is archived | MISSING |
auto_archive_duration | Absent[AutoArchiveDuration] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | MISSING |
locked | Absent[bool] | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
flags | Absent[Union[int, ChannelFlags]] | channel flags for forum threads | MISSING |
reason | Absent[str] | The reason for this change | MISSING |
Returns:
Type | Description |
---|---|
GuildPublicThread | The edited thread channel object. |
Source code in interactions/models/discord/channel.py
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 |
|
GuildStageVoice
¶
Bases: GuildVoice
Source code in interactions/models/discord/channel.py
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 |
|
stage_instance: models.StageInstance = attrs.field(repr=False, default=MISSING)
class-attribute
¶
The stage instance that this voice channel belongs to
close_stage(reason=MISSING)
async
¶
Closes the live stage instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[Optional[str]] | The reason for closing the stage | MISSING |
Source code in interactions/models/discord/channel.py
2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 |
|
create_stage_instance(topic, privacy_level=StagePrivacyLevel.GUILD_ONLY, reason=MISSING)
async
¶
Create a stage instance in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topic | str | The topic of the stage (1-120 characters) | required |
privacy_level | StagePrivacyLevel | The privacy level of the stage | StagePrivacyLevel.GUILD_ONLY |
reason | Absent[Optional[str]] | The reason for creating this instance | MISSING |
Returns:
Type | Description |
---|---|
StageInstance | The created stage instance object. |
Source code in interactions/models/discord/channel.py
2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 |
|
fetch_stage_instance()
async
¶
Fetches the stage instance associated with this channel.
Returns:
Type | Description |
---|---|
StageInstance | The stage instance associated with this channel. If no stage is live, will return None. |
Source code in interactions/models/discord/channel.py
2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 |
|
GuildText
¶
Bases: GuildChannel
, MessageableMixin
, InvitableMixin
, ThreadableMixin
, WebhookMixin
Source code in interactions/models/discord/channel.py
1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 |
|
topic: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The channel topic (0-1024 characters)
create_private_thread(name, invitable=MISSING, auto_archive_duration=AutoArchiveDuration.ONE_DAY, rate_limit_per_user=MISSING, reason=None)
async
¶
Creates a new private thread in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-100 character thread name. | required |
invitable | Absent[bool] | Whether non-moderators can add other non-moderators to a thread. | MISSING |
rate_limit_per_user | Absent[int] | The time users must wait between sending messages (0-21600). | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | None | The reason for creating this thread. | None |
Returns:
Type | Description |
---|---|
GuildPrivateThread | The created thread, if successful |
Source code in interactions/models/discord/channel.py
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 |
|
create_public_thread(name, auto_archive_duration=AutoArchiveDuration.ONE_DAY, rate_limit_per_user=MISSING, reason=None)
async
¶
Creates a new public thread in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-100 character thread name. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
rate_limit_per_user | Absent[int] | The time users must wait between sending messages (0-21600). | MISSING |
reason | Absent[str] | None | The reason for creating this thread. | None |
Returns:
Type | Description |
---|---|
GuildPublicThread | The created public thread, if successful |
Source code in interactions/models/discord/channel.py
1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 |
|
create_thread_from_message(name, message, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None)
async
¶
Creates a new public thread in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-100 character thread name. | required |
message | Snowflake_Type | The message to connect this thread to. | required |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | None | The reason for creating this thread. | None |
Returns:
Type | Description |
---|---|
GuildPublicThread | The created public thread, if successful |
Source code in interactions/models/discord/channel.py
1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 |
|
edit(*, name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, nsfw=MISSING, topic=MISSING, channel_type=MISSING, default_auto_archive_duration=MISSING, rate_limit_per_user=MISSING, reason=MISSING, **kwargs)
async
¶
Edit the guild text channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of PermissionOverwrite | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
nsfw | Absent[bool] | whether the channel is nsfw | MISSING |
topic | Absent[str] | 0-1024 character channel topic | MISSING |
channel_type | Absent[ChannelType] | the type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature | MISSING |
default_auto_archive_duration | Absent[AutoArchiveDuration] | optional AutoArchiveDuration | MISSING |
rate_limit_per_user | Absent[int] | amount of seconds a user has to wait before sending another message (0-21600) | MISSING |
reason | Absent[str] | An optional reason for the audit log | MISSING |
Returns:
Type | Description |
---|---|
Union[GuildText, GuildNews] | The edited channel. |
Source code in interactions/models/discord/channel.py
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 |
|
InvitableMixin
¶
Source code in interactions/models/discord/channel.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
create_invite(max_age=86400, max_uses=0, temporary=False, unique=False, target_type=None, target_user=None, target_application=None, reason=None)
async
¶
Creates a new channel invite.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_age | int | Max age of invite in seconds, default 86400 (24 hours). | 86400 |
max_uses | int | Max uses of invite, default 0. | 0 |
temporary | bool | Grants temporary membership, default False. | False |
unique | bool | Invite is unique, default false. | False |
target_type | Optional[InviteTargetType] | Target type for streams and embedded applications. | None |
target_user | Optional[Union[Snowflake_Type, User]] | Target User ID for Stream target type. | None |
target_application | Optional[Union[Snowflake_Type, Application]] | Target Application ID for Embedded App target type. | None |
reason | Optional[str] | The reason for creating this invite. | None |
Returns:
Type | Description |
---|---|
Invite | Newly created Invite object. |
Source code in interactions/models/discord/channel.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
|
fetch_invites()
async
¶
Fetches all invites (with invite metadata) for the channel.
Returns:
Type | Description |
---|---|
List[Invite] | List of Invite objects. |
Source code in interactions/models/discord/channel.py
546 547 548 549 550 551 552 553 554 555 |
|
MessageableMixin
¶
Bases: SendMixin
Source code in interactions/models/discord/channel.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
default_auto_archive_duration: int = attrs.field(repr=False, default=AutoArchiveDuration.ONE_DAY)
class-attribute
¶
Default duration that the clients (not the API) will use for newly created threads, in minutes, to automatically archive the thread after recent activity
last_message_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The id of the last message sent in this channel (may not point to an existing or valid message)
last_pin_timestamp: Optional[models.Timestamp] = attrs.field(repr=False, default=None, converter=optional_c(timestamp_converter))
class-attribute
¶
When the last pinned message was pinned. This may be None when a message is not pinned.
rate_limit_per_user: int = attrs.field(repr=False, default=0)
class-attribute
¶
Amount of seconds a user has to wait before sending another message (0-21600)
typing: Typing
property
¶
A context manager to send a typing state to a given channel as long as long as the wrapped operation takes.
delete_message(message, reason=None)
async
¶
Delete a single message from a channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | Union[Snowflake_Type, Message] | The message to delete | required |
reason | str | None | The reason for this action | None |
Source code in interactions/models/discord/channel.py
394 395 396 397 398 399 400 401 402 403 404 |
|
delete_messages(messages, reason=MISSING)
async
¶
Bulk delete messages from channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages | List[Union[Snowflake_Type, Message]] | List of messages or message IDs to delete. | required |
reason | Absent[Optional[str]] | The reason for this action. Used for audit logs. | MISSING |
Source code in interactions/models/discord/channel.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
fetch_message(message_id, *, force=False)
async
¶
Fetch a message from the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_id | Snowflake_Type | ID of message to retrieve. | required |
force | bool | Whether to force a fetch from the API. | False |
Returns:
Type | Description |
---|---|
Optional[Message] | The message object fetched. If the message is not found, returns None. |
Source code in interactions/models/discord/channel.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
fetch_messages(limit=50, around=MISSING, before=MISSING, after=MISSING)
async
¶
Fetch multiple messages from the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | Max number of messages to return, default | 50 |
around | Snowflake_Type | Message to get messages around | MISSING |
before | Snowflake_Type | Message to get messages before | MISSING |
after | Snowflake_Type | Message to get messages after | MISSING |
Returns:
Type | Description |
---|---|
List[Message] | A list of messages fetched. |
Source code in interactions/models/discord/channel.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
fetch_pinned_messages()
async
¶
Fetch pinned messages from the channel.
Returns:
Type | Description |
---|---|
List[Message] | A list of messages fetched. |
Source code in interactions/models/discord/channel.py
361 362 363 364 365 366 367 368 369 370 |
|
get_message(message_id)
¶
Get a message from the channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_id | Snowflake_Type | ID of message to retrieve. | required |
Returns:
Type | Description |
---|---|
Message | The message object fetched. |
Source code in interactions/models/discord/channel.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
history(limit=100, before=None, after=None, around=None)
¶
Get an async iterator for the history of this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | The maximum number of messages to return (set to 0 for no limit) | 100 |
before | Snowflake_Type | get messages before this message ID | None |
after | Snowflake_Type | get messages after this message ID | None |
around | Snowflake_Type | get messages "around" this message ID | None |
Example Usage:
1 2 3 4 5 |
|
1 2 3 |
|
Returns:
Type | Description |
---|---|
ChannelHistory | ChannelHistory (AsyncIterator) |
Source code in interactions/models/discord/channel.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
purge(deletion_limit=50, search_limit=100, predicate=MISSING, avoid_loading_msg=True, return_messages=False, before=MISSING, after=MISSING, around=MISSING, reason=MISSING)
async
¶
Bulk delete messages within a channel. If a predicate
is provided, it will be used to determine which messages to delete, otherwise all messages will be deleted within the deletion_limit
.
Example Usage:
1 2 3 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deletion_limit | int | The target amount of messages to delete | 50 |
search_limit | int | How many messages to search through | 100 |
predicate | Callable[[Message], bool] | A function that returns True or False, and takes a message as an argument | MISSING |
avoid_loading_msg | bool | Should the bot attempt to avoid deleting its own loading messages (recommended enabled) | True |
return_messages | bool | Should the bot return the messages that were deleted | False |
before | Optional[Snowflake_Type] | Search messages before this ID | MISSING |
after | Optional[Snowflake_Type] | Search messages after this ID | MISSING |
around | Optional[Snowflake_Type] | Search messages around this ID | MISSING |
reason | Absent[Optional[str]] | The reason for this deletion | MISSING |
Returns:
Type | Description |
---|---|
int | List[Message] | The total amount of messages deleted |
Source code in interactions/models/discord/channel.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
trigger_typing()
async
¶
Trigger a typing animation in this channel.
Source code in interactions/models/discord/channel.py
479 480 481 |
|
PermissionOverwrite
¶
Bases: SnowflakeObject
, DictSerializationMixin
Channel Permissions Overwrite object.
Note
id
here is not an attribute of the overwrite, it is the ID of the overwritten instance
Source code in interactions/models/discord/channel.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
allow: Optional[Permissions] = attrs.field(repr=True, converter=optional_c(Permissions), kw_only=True, default=None)
class-attribute
¶
Permissions to allow
deny: Optional[Permissions] = attrs.field(repr=True, converter=optional_c(Permissions), kw_only=True, default=None)
class-attribute
¶
Permissions to deny
type: OverwriteType = attrs.field(repr=True, converter=OverwriteType)
class-attribute
¶
Permission overwrite type (role or member)
add_allows(*perms)
¶
Add permissions to allow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*perms | Permissions | Permissions to add | () |
Source code in interactions/models/discord/channel.py
206 207 208 209 210 211 212 213 214 215 216 217 |
|
add_denies(*perms)
¶
Add permissions to deny.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*perms | Permissions | Permissions to add | () |
Source code in interactions/models/discord/channel.py
219 220 221 222 223 224 225 226 227 228 229 230 |
|
for_target(target_type)
classmethod
¶
Create a PermissionOverwrite for a role or member.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_type | Union[Role, Member, User] | The type of the target (role or member) | required |
Returns:
Type | Description |
---|---|
PermissionOverwrite | PermissionOverwrite |
Source code in interactions/models/discord/channel.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
ThreadChannel
¶
Bases: BaseChannel
, MessageableMixin
, WebhookMixin
Source code in interactions/models/discord/channel.py
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 |
|
archive_timestamp: Optional[models.Timestamp] = attrs.field(repr=False, default=None, converter=optional_c(timestamp_converter))
class-attribute
¶
Timestamp when the thread's archive status was last changed, used for calculating recent activity
archived: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether the thread is archived
auto_archive_duration: int = attrs.field(repr=False, default=attrs.Factory(lambda self: self.default_auto_archive_duration, takes_self=True))
class-attribute
¶
Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
clyde_created: bool
property
¶
Whether this thread was created by Clyde.
create_timestamp: Optional[models.Timestamp] = attrs.field(repr=False, default=None, converter=optional_c(timestamp_converter))
class-attribute
¶
Timestamp when the thread was created
flags: ChannelFlags = attrs.field(repr=False, default=ChannelFlags.NONE, converter=ChannelFlags)
class-attribute
¶
Flags for the thread
guild: models.Guild
property
¶
The guild this channel belongs to.
is_private: bool
property
¶
Is this a private thread?
locked: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether the thread is locked
member_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
An approximate count of users in a thread, stops counting at 50
mention: str
property
¶
Returns a string that would mention this thread.
message_count: int = attrs.field(repr=False, default=0)
class-attribute
¶
An approximate count of messages in a thread, stops counting at 50
owner_id: Snowflake_Type = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the creator of the thread
parent_channel: Union[GuildText, GuildForum]
property
¶
The channel this thread is a child of.
parent_id: Snowflake_Type = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the text channel this thread was created
parent_message: Optional[Message]
property
¶
The message this thread is a child of.
permission_overwrites: List[PermissionOverwrite]
property
¶
The permission overwrites for this channel.
topic: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The thread topic (0-1024 characters)
add_member(member)
async
¶
Add a member to this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member | Union[Member, Snowflake_Type] | The member to add | required |
Source code in interactions/models/discord/channel.py
1947 1948 1949 1950 1951 1952 1953 1954 1955 |
|
archive(locked=False, reason=MISSING)
async
¶
Helper method to archive this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
locked | bool | whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it | False |
reason | Absent[str] | The reason for this archive | MISSING |
Returns:
Type | Description |
---|---|
TYPE_THREAD_CHANNEL | The archived thread channel object. |
Source code in interactions/models/discord/channel.py
1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 |
|
fetch_members()
async
¶
Get the members that have access to this thread.
Source code in interactions/models/discord/channel.py
1942 1943 1944 1945 |
|
join()
async
¶
Join this thread.
Source code in interactions/models/discord/channel.py
1967 1968 1969 |
|
leave()
async
¶
Leave this thread.
Source code in interactions/models/discord/channel.py
1971 1972 1973 |
|
permissions_for(instance)
¶
Calculates permissions for an instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance | Snowflake_Type | Member or Role instance (or its ID) | required |
Returns:
Type | Description |
---|---|
Permissions | Permissions data |
Raises:
Type | Description |
---|---|
ValueError | If could not find any member or role by given ID |
RuntimeError | If given instance is from another guild |
Source code in interactions/models/discord/channel.py
1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 |
|
remove_member(member)
async
¶
Remove a member from this thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
member | Union[Member, Snowflake_Type] | The member to remove | required |
Source code in interactions/models/discord/channel.py
1957 1958 1959 1960 1961 1962 1963 1964 1965 |
|
ThreadableMixin
¶
Source code in interactions/models/discord/channel.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
create_thread(name, message=MISSING, thread_type=MISSING, invitable=MISSING, rate_limit_per_user=MISSING, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None)
async
¶
Creates a new thread in this channel. If a message is provided, it will be used as the initial message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-100 character thread name | required |
message | Absent[Snowflake_Type] | The message to connect this thread to. Required for news channel. | MISSING |
thread_type | Absent[ChannelType] | Is the thread private or public. Not applicable to news channel, it will always be GUILD_NEWS_THREAD. | MISSING |
invitable | Absent[bool] | whether non-moderators can add other non-moderators to a thread. Only applicable when creating a private thread. | MISSING |
rate_limit_per_user | Absent[int] | The time users must wait between sending messages (0-21600). | MISSING |
auto_archive_duration | AutoArchiveDuration | Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted. | AutoArchiveDuration.ONE_DAY |
reason | Absent[str] | None | The reason for creating this thread. | None |
Returns:
Type | Description |
---|---|
TYPE_THREAD_CHANNEL | The created thread, if successful |
Source code in interactions/models/discord/channel.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
fetch_active_threads()
async
¶
Gets all active threads in the channel, including public and private threads.
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
|
fetch_all_threads()
async
¶
Gets all threads in the channel. Active and archived, including public and private threads.
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
fetch_archived_threads(limit=None, before=None)
async
¶
Get a ThreadList
of archived threads available in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | None | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
|
fetch_joined_private_archived_threads(limit=None, before=None)
async
¶
Get a ThreadList
of threads the bot is a participant of in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | None | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
|
fetch_private_archived_threads(limit=None, before=None)
async
¶
Get a ThreadList
of archived private threads available in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | None | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
fetch_public_archived_threads(limit=None, before=None)
async
¶
Get a ThreadList
of archived public threads available in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit | int | None | optional maximum number of threads to return | None |
before | Optional[Timestamp] | Returns threads before this timestamp | None |
Returns:
Type | Description |
---|---|
ThreadList | A |
Source code in interactions/models/discord/channel.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
|
VoiceChannel
¶
Bases: GuildChannel
Source code in interactions/models/discord/channel.py
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 |
|
bitrate: int = attrs.field(repr=False)
class-attribute
¶
The bitrate (in bits) of the voice channel
members: List[models.Member]
property
¶
Returns a list of members that have access to this voice channel
rtc_region: str = attrs.field(repr=False, default='auto')
class-attribute
¶
Voice region id for the voice channel, automatic when set to None
user_limit: int = attrs.field(repr=False)
class-attribute
¶
The user limit of the voice channel
video_quality_mode: Union[VideoQualityMode, int] = attrs.field(repr=False, default=VideoQualityMode.AUTO)
class-attribute
¶
The camera video quality mode of the voice channel, 1 when not present
voice_members: List[models.Member]
property
¶
Returns a list of members that are currently in the channel.
Note
This will not be accurate if the bot was offline while users joined the channel
voice_state: Optional[ActiveVoiceState]
property
¶
Returns the voice state of the bot in this channel if it is connected
connect(muted=False, deafened=False)
async
¶
Connect the bot to this voice channel, or move the bot to this voice channel if it is already connected in another voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
Type | Description |
---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in interactions/models/discord/channel.py
2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 |
|
disconnect()
async
¶
Disconnect from the currently connected voice state.
Raises:
Type | Description |
---|---|
VoiceNotConnected | if the bot is not connected to a voice channel |
Source code in interactions/models/discord/channel.py
2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 |
|
edit(*, name=MISSING, position=MISSING, permission_overwrites=MISSING, parent_id=MISSING, bitrate=MISSING, user_limit=MISSING, rtc_region=MISSING, video_quality_mode=MISSING, reason=MISSING, **kwargs)
async
¶
Edit guild voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str] | 1-100 character channel name | MISSING |
position | Absent[int] | the position of the channel in the left-hand listing | MISSING |
permission_overwrites | Absent[Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]]] | a list of | MISSING |
parent_id | Absent[Snowflake_Type] | the parent category | MISSING |
bitrate | Absent[int] | the bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) | MISSING |
user_limit | Absent[int] | the user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit | MISSING |
rtc_region | Absent[str] | channel voice region id, automatic when not set | MISSING |
video_quality_mode | Absent[VideoQualityMode] | the camera video quality mode of the voice channel | MISSING |
reason | Absent[str] | optional reason for audit logs | MISSING |
Returns:
Type | Description |
---|---|
Union[GuildVoice, GuildStageVoice] | The edited voice channel object. |
Source code in interactions/models/discord/channel.py
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 |
|
WebhookMixin
¶
Source code in interactions/models/discord/channel.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
|
create_webhook(name, avatar=MISSING)
async
¶
Create a webhook in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of the webhook | required |
avatar | Absent[UPLOADABLE_TYPE] | An optional default avatar image to use | MISSING |
Returns:
Type | Description |
---|---|
Webhook | The created webhook object |
Raises:
Type | Description |
---|---|
ValueError | If you try to name the webhook "Clyde" |
Source code in interactions/models/discord/channel.py
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
delete_webhook(webhook)
async
¶
Delete a given webhook in this channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webhook | Webhook | The webhook to delete | required |
Source code in interactions/models/discord/channel.py
754 755 756 757 758 759 760 761 762 |
|
fetch_webhooks()
async
¶
Fetches all the webhooks for this channel.
Returns:
Type | Description |
---|---|
List[Webhook] | List of webhook objects |
Source code in interactions/models/discord/channel.py
764 765 766 767 768 769 770 771 772 773 |
|
process_permission_overwrites(overwrites)
¶
Processes a permission overwrite lists into format for sending to discord.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
overwrites | Union[dict, PermissionOverwrite, List[Union[dict, PermissionOverwrite]]] | The permission overwrites to process | required |
Returns:
Type | Description |
---|---|
List[dict] | The processed permission overwrites |
Source code in interactions/models/discord/channel.py
2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 |
|
Invite
¶
Bases: ClientObject
Source code in interactions/models/discord/invite.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
approximate_member_count: Optional[int] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
Approximate count of total members, returned when fetching invites with with_counts
set as True
approximate_presence_count: Optional[int] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
Approximate count of online members, returned when fetching invites with with_counts
set as True
channel: Optional[TYPE_GUILD_CHANNEL]
property
¶
The cached channel the invite is for.
code: str = attrs.field(repr=True)
class-attribute
¶
The invite code (unique ID)
created_at: Timestamp = attrs.field(default=MISSING, converter=optional_c(timestamp_converter), repr=True)
class-attribute
¶
When this invite was created
expires_at: Optional[Timestamp] = attrs.field(default=None, converter=optional_c(timestamp_converter), repr=True)
class-attribute
¶
The expiration date of this invite, returned when fetching invites with with_expiration
set as True
guild: Optional[Guild]
property
¶
The cached guild the invite is.
guild_preview: Optional[GuildPreview] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
The guild this invite is for - not given in invite events
inviter: Optional[User]
property
¶
The user that created the invite or None.
link: str
property
¶
The invite link.
max_age: int = attrs.field(repr=False, default=0)
class-attribute
¶
Duration (in seconds) after which the invite expires
max_uses: int = attrs.field(repr=False, default=0)
class-attribute
¶
Max number of times this invite can be used
scheduled_event: Optional[Snowflake_Type] = attrs.field(default=None, converter=optional_c(to_snowflake), repr=True)
class-attribute
¶
Guild scheduled event data, only included if guild_scheduled_event_id
contains a valid guild scheduled event id
stage_instance: Optional[StageInstance] = attrs.field(repr=False, default=None)
class-attribute
¶
Stage instance data if there is a public Stage instance in the Stage channel this invite is for (deprecated)
target_application: Optional[dict] = attrs.field(repr=False, default=None)
class-attribute
¶
The embedded application to open for this voice channel embedded application invite
target_type: Optional[Union[InviteTargetType, int]] = attrs.field(default=None, converter=optional_c(InviteTargetType), repr=True)
class-attribute
¶
The type of target for this voice channel invite
target_user: Optional[User]
property
¶
The user whose stream to display for this voice channel stream invite or None.
temporary: bool = attrs.field(default=False, repr=True)
class-attribute
¶
Whether this invite only grants temporary membership
uses: int = attrs.field(default=0, repr=True)
class-attribute
¶
How many times this invite has been used
delete(reason=MISSING)
async
¶
Delete this invite.
Note
You must have the manage_channels
permission on the channel this invite belongs to.
Note
With manage_guild
permission, you can delete any invite across the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Absent[str] | The reason for the deletion of invite. | MISSING |
Source code in interactions/models/discord/invite.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
Role
¶
Bases: DiscordObject
Source code in interactions/models/discord/role.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
bot_managed: bool
property
¶
Is this role owned/managed by a bot.
default: bool
property
¶
Is this the @everyone
role.
guild: Guild
property
¶
The guild object this role is from.
icon: Asset | PartialEmoji | None
property
¶
The icon of this role
Note
You have to use this method instead of the _icon
attribute, because the first does account for unicode emojis
integration: bool
property
¶
Is this role owned/managed by an integration.
is_assignable: bool
property
¶
Can this role be assigned or removed by this bot?
Note
This does not account for permissions, only the role hierarchy
is_linked_role: bool
property
¶
Is this role a linked role.
members: list[Member]
property
¶
List of members with this role
mention: str
property
¶
Returns a string that would mention the role.
delete(reason=MISSING)
async
¶
Delete this role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | str | Missing | An optional reason for this deletion | MISSING |
Source code in interactions/models/discord/role.py
172 173 174 175 176 177 178 179 180 |
|
edit(*, name=None, permissions=None, color=None, hoist=None, mentionable=None, icon=None, unicode_emoji=None)
async
¶
Edit this role, all arguments are optional.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | None | name of the role | None |
permissions | str | None | New permissions to use | None |
color | Color | COLOR_TYPES | None | The color of the role | None |
hoist | bool | None | whether the role should be displayed separately in the sidebar | None |
mentionable | bool | None | whether the role should be mentionable | None |
icon | bytes | UPLOADABLE_TYPE | None | (Guild Level 2+) Bytes-like object representing the icon; supports PNG, JPEG and WebP | None |
unicode_emoji | str | None | (Guild Level 2+) Unicode emoji for the role; can't be used with icon | None |
Returns:
Type | Description |
---|---|
Role | Role with updated information |
Source code in interactions/models/discord/role.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
fetch_bot(*, force=False)
async
¶
Fetch the bot associated with this role if any.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force fetch the bot from the API. | False |
Returns:
Type | Description |
---|---|
Member | None | Member object if any |
Source code in interactions/models/discord/role.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_bot()
¶
Get the bot associated with this role if any.
Returns:
Type | Description |
---|---|
Member | None | Member object if any |
Source code in interactions/models/discord/role.py
104 105 106 107 108 109 110 111 112 113 114 |
|
move(position, reason=MISSING)
async
¶
Move this role to a new position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position | int | The new position of the role | required |
reason | str | Missing | An optional reason for this move | MISSING |
Returns:
Type | Description |
---|---|
Role | The role object |
Source code in interactions/models/discord/role.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
CustomEmoji
¶
Bases: PartialEmoji
, ClientObject
Represent a custom emoji in a guild with all its properties.
Source code in interactions/models/discord/emoji.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|
available: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this emoji can be used, may be false due to loss of Server Boosts.
creator: Optional[Union[Member, User]]
property
¶
The member that created this emoji.
guild: Guild
property
¶
The guild this emoji belongs to.
is_usable: bool
property
¶
Determines if this emoji is usable by the current user.
managed: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this emoji is managed
require_colons: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this emoji must be wrapped in colons
roles: List[Role]
property
¶
The roles allowed to use this emoji.
url: str
property
¶
CDN url for the emoji.
delete(reason=None)
async
¶
Deletes the custom emoji from the guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reason | Optional[str] | Attach a reason to this action, used for audit logs. | None |
Source code in interactions/models/discord/emoji.py
196 197 198 199 200 201 202 203 204 205 206 207 |
|
edit(*, name=None, roles=None, reason=None)
async
¶
Modify the custom emoji information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Optional[str] | The name of the emoji. | None |
roles | Optional[List[Union[Snowflake_Type, Role]]] | The roles allowed to use this emoji. | None |
reason | Optional[str] | Attach a reason to this action, used for audit logs. | None |
Returns:
Type | Description |
---|---|
CustomEmoji | The newly modified custom emoji. |
Source code in interactions/models/discord/emoji.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
PartialEmoji
¶
Bases: SnowflakeObject
, DictSerializationMixin
Represent a basic ("partial") emoji used in discord.
Source code in interactions/models/discord/emoji.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
animated: bool = attrs.field(repr=True, default=False)
class-attribute
¶
Whether this emoji is animated
id: Optional[Snowflake_Type] = attrs.field(repr=True, default=None, converter=optional(to_snowflake))
class-attribute
¶
The custom emoji id. Leave empty if you are using standard unicode emoji.
name: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
The custom emoji name, or standard unicode emoji in string
req_format: str
property
¶
Format used for web request.
from_str(emoji_str, *, language='alias')
classmethod
¶
Generate a PartialEmoji from a discord Emoji string representation, or unicode emoji.
Handles
<:emoji_name:emoji_id> :emoji_name:emoji_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji_str | str | The string representation an emoji | required |
language | str | The language to use for the unicode emoji parsing | 'alias' |
Returns:
Type | Description |
---|---|
Optional[PartialEmoji] | A PartialEmoji object |
Raises:
Type | Description |
---|---|
ValueError | if the string cannot be parsed |
Source code in interactions/models/discord/emoji.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
process_emoji(emoji)
¶
Processes the emoji parameter into the dictionary format required by the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Optional[Union[PartialEmoji, dict, str]] | The emoji to process. | required |
Returns:
Type | Description |
---|---|
Optional[dict] | formatted dictionary for discord |
Source code in interactions/models/discord/emoji.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
process_emoji_req_format(emoji)
¶
Processes the emoji parameter into the str format required by the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Optional[Union[PartialEmoji, dict, str]] | The emoji to process. | required |
Returns:
Type | Description |
---|---|
Optional[str] | formatted string for discord |
Source code in interactions/models/discord/emoji.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
Message¶
AllowedMentions
¶
Bases: DictSerializationMixin
The allowed mention field allows for more granular control over mentions without various hacks to the message content.
This will always validate against message content to avoid phantom pings, and check against user/bot permissions.
Source code in interactions/models/discord/message.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
|
parse: Optional[List[str]] = attrs.field(repr=False, factory=list)
class-attribute
¶
An array of allowed mention types to parse from the content.
replied_user = attrs.field(repr=False, default=False)
class-attribute
¶
For replies, whether to mention the author of the message being replied to. (default false)
roles: Optional[List[Snowflake_Type]] = attrs.field(repr=False, factory=list, converter=to_snowflake_list)
class-attribute
¶
Array of role_ids to mention. (Max size of 100)
users: Optional[List[Snowflake_Type]] = attrs.field(repr=False, factory=list, converter=to_snowflake_list)
class-attribute
¶
Array of user_ids to mention. (Max size of 100)
add_parse(*mention_types)
¶
Add a mention type to the list of allowed mentions to parse.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*mention_types | Union[MentionType, str] | The types of mentions to add | () |
Source code in interactions/models/discord/message.py
300 301 302 303 304 305 306 307 308 309 310 311 |
|
add_roles(*roles)
¶
Add roles that are allowed to be mentioned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles | Union[Role, Snowflake_Type] | The roles to add | () |
Source code in interactions/models/discord/message.py
313 314 315 316 317 318 319 320 321 322 |
|
add_users(*users)
¶
Add users that are allowed to be mentioned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*users | Union[Member, BaseUser, Snowflake_Type] | The users to add | () |
Source code in interactions/models/discord/message.py
324 325 326 327 328 329 330 331 332 333 |
|
all()
classmethod
¶
Allows every user and role to be mentioned.
Returns:
Type | Description |
---|---|
AllowedMentions | An AllowedMentions object |
Source code in interactions/models/discord/message.py
335 336 337 338 339 340 341 342 343 344 |
|
none()
classmethod
¶
Disallows any user or role to be mentioned.
Returns:
Type | Description |
---|---|
AllowedMentions | An AllowedMentions object |
Source code in interactions/models/discord/message.py
346 347 348 349 350 351 352 353 354 355 |
|
Attachment
¶
Bases: DiscordObject
Source code in interactions/models/discord/message.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
content_type: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
the attachment's media type
description: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
description for the file
duration_secs: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
the duration of the audio file (currently for voice messages)
ephemeral: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether this attachment is ephemeral
filename: str = attrs.field(repr=False)
class-attribute
¶
name of file attached
height: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
height of file (if image)
proxy_url: str = attrs.field(repr=False)
class-attribute
¶
a proxied url of file
resolution: tuple[Optional[int], Optional[int]]
property
¶
Returns the image resolution of the attachment file
size: int = attrs.field(repr=False)
class-attribute
¶
size of file in bytes
url: str = attrs.field(repr=False)
class-attribute
¶
source url of file
waveform: bytearray = attrs.field(repr=False, default=None)
class-attribute
¶
base64 encoded bytearray representing a sampled waveform (currently for voice messages)
width: Optional[int] = attrs.field(repr=False, default=None)
class-attribute
¶
width of file (if image)
BaseMessage
¶
Bases: DiscordObject
Source code in interactions/models/discord/message.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
author: Union[models.Member, models.User]
property
¶
The author of this message. Only a valid user in the case where the message is generated by a user or bot user.
channel: models.TYPE_MESSAGEABLE_CHANNEL
property
¶
The channel the message was sent in
guild: models.Guild
property
¶
The guild the message was sent in
thread: models.TYPE_THREAD_CHANNEL
property
¶
The thread that was started from this message, includes thread member object
ChannelMention
¶
Bases: DiscordObject
Source code in interactions/models/discord/message.py
151 152 153 154 155 156 157 158 159 160 161 162 |
|
Message
¶
Bases: BaseMessage
Source code in interactions/models/discord/message.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 |
|
activity: Optional[MessageActivity] = attrs.field(repr=False, default=None, converter=optional_c(MessageActivity))
class-attribute
¶
Activity sent with Rich Presence-related chat embeds
application: Optional[models.Application] = attrs.field(repr=False, default=None)
class-attribute
¶
Application sent with Rich Presence-related chat embeds
application_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=to_optional_snowflake)
class-attribute
¶
If the message is an Interaction or application-owned webhook, this is the id of the application
attachments: List[Attachment] = attrs.field(repr=False, factory=list)
class-attribute
¶
Any attached files
components: Optional[List[models.ActionRow]] = attrs.field(repr=False, default=None)
class-attribute
¶
Sent if the message contains components like buttons, action rows, or other interactive components
content: str = attrs.field(repr=False, default=MISSING)
class-attribute
¶
Contents of the message
editable: bool
property
¶
Whether this message can be edited by the current user
edited_timestamp: Optional[models.Timestamp] = attrs.field(repr=False, default=None, converter=optional_c(timestamp_converter))
class-attribute
¶
When this message was edited (or None
if never)
embeds: List[models.Embed] = attrs.field(repr=False, factory=list)
class-attribute
¶
Any embedded content
flags: MessageFlags = attrs.field(repr=False, default=MessageFlags.NONE, converter=MessageFlags)
class-attribute
¶
Message flags combined as a bitfield
interaction: Optional[MessageInteraction] = attrs.field(repr=False, default=None)
class-attribute
¶
(Deprecated in favor of interaction_metadata) Sent if the message is a response to an Interaction
interaction_metadata: Optional[MessageInteractionMetadata] = attrs.field(repr=False, default=None)
class-attribute
¶
Sent if the message is a response to an Interaction
jump_url: str
property
¶
A url that allows the client to jump to this message.
mention_channels: List[ChannelMention] = attrs.field(repr=False, factory=list)
class-attribute
¶
Channels specifically mentioned in this message
mention_everyone: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this message mentions everyone
mention_roles: AsyncGenerator[models.Role, None]
async
property
¶
A generator of roles mentioned in this message
mention_users: AsyncGenerator[Union[models.Member, models.User], None]
async
property
¶
A generator of users mentioned in this message
message_reference: Optional[MessageReference] = attrs.field(repr=False, default=None, converter=optional_c(MessageReference.from_dict))
class-attribute
¶
Data showing the source of a crosspost, channel follow add, pin, or reply message
nonce: Optional[Union[int, str]] = attrs.field(repr=False, default=None)
class-attribute
¶
Used for validating a message was sent
pinned: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this message is pinned
poll: Optional[Poll] = attrs.field(repr=False, default=None, converter=optional_c(Poll.from_dict))
class-attribute
¶
A poll.
proto_url: str
property
¶
A URL like jump_url
that uses protocols.
reactions: List[models.Reaction] = attrs.field(repr=False, factory=list)
class-attribute
¶
Reactions to the message
sticker_items: Optional[List[models.StickerItem]] = attrs.field(repr=False, default=None)
class-attribute
¶
Sent if the message contains stickers
system_content: Optional[str]
property
¶
Content for system messages. (boosts, welcomes, etc)
thread: models.TYPE_THREAD_CHANNEL
property
¶
The thread that was started from this message, if any
timestamp: models.Timestamp = attrs.field(repr=False, default=MISSING, converter=optional_c(timestamp_converter))
class-attribute
¶
When this message was sent
tts: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether this was a TTS message
type: MessageType = attrs.field(repr=False, default=MISSING, converter=optional_c(MessageType))
class-attribute
¶
Type of message
webhook_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=to_optional_snowflake)
class-attribute
¶
If the message is generated by a webhook, this is the webhook's id
add_reaction(emoji)
async
¶
Add a reaction to this message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | the emoji to react with | required |
Source code in interactions/models/discord/message.py
883 884 885 886 887 888 889 890 891 892 |
|
answer_voters(answer_id, limit=0, before=None)
¶
An async iterator for getting the voters for an answer in the poll this message has.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
answer_id | int | The answer to get voters for | required |
after | Get messages after this user ID | required | |
limit | int | The max number of users to return (default 25, max 100) | 0 |
Source code in interactions/models/discord/message.py
681 682 683 684 685 686 687 688 689 690 691 692 693 |
|
clear_all_reactions()
async
¶
Clear all emojis from a message.
Source code in interactions/models/discord/message.py
927 928 929 |
|
clear_reactions(emoji)
async
¶
Clear a specific reaction from message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | The emoji to clear | required |
Source code in interactions/models/discord/message.py
916 917 918 919 920 921 922 923 924 925 |
|
contains_mention(query, *, tag_as_mention=False)
¶
Check whether the message contains the query or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query | Role | The query to search for | required |
tag_as_mention | bool | Should | False |
Returns:
Type | Description |
---|---|
bool | A boolean indicating whether the query could be found or not |
Source code in interactions/models/discord/message.py
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|
create_thread(name, auto_archive_duration=AutoArchiveDuration.ONE_DAY, reason=None)
async
¶
Create a thread from this message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The name of this thread | required |
auto_archive_duration | Union[AutoArchiveDuration, int] | duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 | AutoArchiveDuration.ONE_DAY |
reason | Optional[str] | The optional reason for creating this thread | None |
Returns:
Type | Description |
---|---|
TYPE_THREAD_CHANNEL | The created thread object |
Raises:
Type | Description |
---|---|
ThreadOutsideOfGuild | if this is invoked on a message outside of a guild |
Source code in interactions/models/discord/message.py
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
|
delete(delay=0, *, context=None)
async
¶
Delete message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delay | int | Seconds to wait before deleting message. | 0 |
context | InteractionContext | None | An optional interaction context to delete ephemeral messages. | None |
Source code in interactions/models/discord/message.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
|
edit(*, content=None, embeds=None, embed=None, components=None, allowed_mentions=None, attachments=None, files=None, file=None, tts=False, flags=None, context=None)
async
¶
Edits the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[Sequence[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[Sequence[Sequence[Union[BaseComponent, dict]]], Sequence[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
attachments | Optional[Optional[Sequence[Union[Attachment, dict]]]] | The attachments to keep, only used when editing message. | None |
files | Optional[Union[UPLOADABLE_TYPE, Sequence[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
context | InteractionContext | None | The interaction context to use for the edit | None |
Returns:
Type | Description |
---|---|
Message | New message object with edits applied |
Source code in interactions/models/discord/message.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
|
end_poll()
async
¶
Ends the poll contained in this message.
Source code in interactions/models/discord/message.py
950 951 952 953 954 |
|
fetch_reaction(emoji, limit=MISSING, after=MISSING)
async
¶
Fetches reactions of a specific emoji from this message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | The emoji to get | required |
limit | Absent[int] | Max number of users to return (1-100) | MISSING |
after | Absent[Snowflake_Type] | Get users after this user ID | MISSING |
Returns:
Type | Description |
---|---|
List[User] | list of users who have reacted with that emoji |
Source code in interactions/models/discord/message.py
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
|
fetch_referenced_message(*, force=False)
async
¶
Fetch the message this message is referencing, if any.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | bool | Whether to force a fetch from the API | False |
Returns:
Type | Description |
---|---|
Optional[Message] | The referenced message, if found |
Source code in interactions/models/discord/message.py
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
get_referenced_message()
¶
Get the message this message is referencing, if any.
Returns:
Type | Description |
---|---|
Optional[Message] | The referenced message, if found |
Source code in interactions/models/discord/message.py
502 503 504 505 506 507 508 509 510 511 512 |
|
pin()
async
¶
Pin message.
Source code in interactions/models/discord/message.py
931 932 933 934 |
|
publish()
async
¶
Publish this message.
(Discord api calls it "crosspost")
Source code in interactions/models/discord/message.py
941 942 943 944 945 946 947 948 |
|
remove_reaction(emoji, member=MISSING)
async
¶
Remove a specific reaction that a user reacted with.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
emoji | Union[PartialEmoji, dict, str] | Emoji to remove | required |
member | Optional[Union[Member, User, Snowflake_Type]] | Member to remove reaction of. Default's to ClientUser. | MISSING |
Source code in interactions/models/discord/message.py
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
|
reply(content=None, embeds=None, embed=None, **kwargs)
async
¶
Reply to this message, takes all the same attributes as send
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | Optional[Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
**kwargs | Mapping[str, Any] | Additional options to pass to | {} |
Returns:
Type | Description |
---|---|
Message | New message object. |
Source code in interactions/models/discord/message.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
|
suppress_embeds()
async
¶
Suppress embeds for this message.
Note
Requires the Permissions.MANAGE_MESSAGES
permission.
Source code in interactions/models/discord/message.py
846 847 848 849 850 851 852 853 854 855 856 857 858 |
|
unpin()
async
¶
Unpin message.
Source code in interactions/models/discord/message.py
936 937 938 939 |
|
MessageActivity
dataclass
¶
Source code in interactions/models/discord/message.py
165 166 167 168 169 170 |
|
MessageInteraction
¶
Bases: DiscordObject
Source code in interactions/models/discord/message.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
MessageInteractionMetadata
¶
Bases: DiscordObject
Source code in interactions/models/discord/message.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
authorizing_integration_owners: dict[IntegrationType, Snowflake] = attrs.field(repr=False, factory=dict)
class-attribute
¶
IDs for installation context(s) related to an interaction.
interacted_message_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=to_optional_snowflake)
class-attribute
¶
ID of the message that contained interactive component, present only on messages created from component interactions
original_response_message_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=to_optional_snowflake)
class-attribute
¶
ID of the original response message, present only on follow-up messages
triggering_interaction_metadata: Optional[MessageInteractionMetadata] = attrs.field(repr=False, default=None)
class-attribute
¶
Metadata for the interaction that was used to open the modal, present only on modal submit interactions
type: InteractionType = attrs.field(repr=False, converter=InteractionType)
class-attribute
¶
The type of interaction
user: models.User
property
¶
Get the user associated with this interaction.
MessageReference
¶
Bases: DictSerializationMixin
Reference to an originating message.
Can be used for replies.
Source code in interactions/models/discord/message.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
channel_id: Optional[int] = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the originating message's channel.
fail_if_not_exists: bool = attrs.field(repr=False, default=True)
class-attribute
¶
When sending a message, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true.
guild_id: Optional[int] = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the originating message's guild.
message_id: int = attrs.field(repr=False, default=None, converter=optional_c(to_snowflake))
class-attribute
¶
id of the originating message.
for_message(message, fail_if_not_exists=True)
classmethod
¶
Creates a reference to a message.
Parameters message: The target message to reference. fail_if_not_exists: Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message
Returns:
Type | Description |
---|---|
MessageReference | A MessageReference object. |
Source code in interactions/models/discord/message.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
MessageType
¶
Bases: CursedIntEnum
Types of message.
Ref: https://discord.com/developers/docs/resources/channel#message-object-message-types
Source code in interactions/models/discord/enums.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
deletable()
classmethod
¶
Return a tuple of message types that can be deleted.
Source code in interactions/models/discord/enums.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
process_allowed_mentions(allowed_mentions)
¶
Process allowed mentions into a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions object or dictionary | required |
Returns:
Type | Description |
---|---|
Optional[dict] | Dictionary of allowed mentions |
Raises:
Type | Description |
---|---|
ValueError | Invalid allowed mentions |
Source code in interactions/models/discord/message.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 |
|
process_message_payload(content=None, embeds=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, attachments=None, tts=False, flags=None, nonce=None, enforce_nonce=False, poll=None, **kwargs)
¶
Format message content for it to be ready to send discord.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | Optional[str] | Message text content. | None |
embeds | Optional[Union[List[Union[Embed, dict]], Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
components | Optional[Union[List[List[Union[BaseComponent, dict]]], List[Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | Optional[Union[List[Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | Optional[Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
attachments | Optional[List[Union[Attachment, dict]]] | The attachments to keep, only used when editing message. | None |
tts | bool | Should this message use Text To Speech. | False |
flags | Optional[Union[int, MessageFlags]] | Message flags to apply. | None |
nonce | Optional[str | int] | Used to verify a message was sent. | None |
enforce_nonce | bool | If enabled and nonce is present, it will be checked for uniqueness in the past few minutes. If another message was created by the same author with the same nonce, that message will be returned and no new message will be created. | False |
poll | Optional[Poll | dict] | A poll. | None |
Returns:
Type | Description |
---|---|
dict | Dictionary |
Source code in interactions/models/discord/message.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
|
process_message_reference(message_reference)
¶
Process mention references into a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_reference | Optional[Union[MessageReference, Message, dict, Snowflake_Type]] | Message reference object | required |
Returns:
Type | Description |
---|---|
Optional[dict] | Message reference dictionary |
Raises:
Type | Description |
---|---|
ValueError | Invalid message reference |
Source code in interactions/models/discord/message.py
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
Reaction
¶
Bases: ClientObject
Source code in interactions/models/discord/reaction.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
channel: TYPE_ALL_CHANNEL
property
¶
The channel this reaction is on.
count: int = attrs.field(repr=False)
class-attribute
¶
times this emoji has been used to react
emoji: PartialEmoji = attrs.field(repr=False, converter=PartialEmoji.from_dict)
class-attribute
¶
emoji information
me: bool = attrs.field(repr=False, default=False)
class-attribute
¶
whether the current user reacted using this emoji
message: Message
property
¶
The message this reaction is on.
remove()
async
¶
Remove all this emoji's reactions from the message.
Source code in interactions/models/discord/reaction.py
95 96 97 |
|
users(limit=0, after=None)
¶
Users who reacted using this emoji.
Source code in interactions/models/discord/reaction.py
81 82 83 |
|
ReactionUsers
¶
Bases: AsyncIterator
An async iterator for searching through a channel's history.
Attributes:
Name | Type | Description |
---|---|---|
reaction | Reaction | The reaction to search through |
limit | Reaction | The maximum number of users to return (set to 0 for no limit) |
after | Snowflake_Type | get users after this message ID |
Source code in interactions/models/discord/reaction.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
fetch()
async
¶
Gets all the users who reacted to the message. Requests user data from discord API if not cached.
Returns:
Type | Description |
---|---|
List[User] | A list of users who reacted to the message. |
Source code in interactions/models/discord/reaction.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
UX.¶
Embed
¶
Bases: DictSerializationMixin
Represents a discord embed object.
Source code in interactions/models/discord/embed.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
author: Optional[EmbedAuthor] = attrs.field(repr=False, default=None, converter=c_optional(EmbedAuthor.from_dict))
class-attribute
¶
The author of the embed
color: Optional[Union[Color, dict, tuple, list, str, int]] = attrs.field(default=None, repr=True, metadata=export_converter(process_color))
class-attribute
¶
The colour of the embed
description: Optional[str] = attrs.field(default=None, repr=True)
class-attribute
¶
The description of the embed
fields: List[EmbedField] = attrs.field(factory=list, converter=EmbedField.from_list, repr=True)
class-attribute
¶
A list of fields to go in the embed
footer: Optional[EmbedFooter] = attrs.field(repr=False, default=None, converter=c_optional(EmbedFooter.converter))
class-attribute
¶
The footer of the embed
image: Optional[EmbedAttachment]
writable
property
¶
The image of the embed.
Raises:
Type | Description |
---|---|
ValueError | If there are multiple images in the embed. |
images: list[EmbedAttachment] = attrs.field(repr=False, factory=list, converter=list_converter(EmbedAttachment.from_dict))
class-attribute
¶
The images of the embed
provider: Optional[EmbedProvider] = attrs.field(repr=False, default=None, converter=c_optional(EmbedProvider.from_dict), metadata=no_export_meta)
class-attribute
¶
The provider of the embed, only used for system embeds
thumbnail: Optional[EmbedAttachment] = attrs.field(repr=False, default=None, converter=c_optional(EmbedAttachment.from_dict))
class-attribute
¶
The thumbnail of the embed
timestamp: Optional[Timestamp] = attrs.field(default=None, converter=c_optional(timestamp_converter), validator=v_optional(instance_of((datetime, float, int))), repr=True)
class-attribute
¶
Timestamp of embed content
title: Optional[str] = attrs.field(default=None, repr=True)
class-attribute
¶
The title of the embed
url: Optional[str] = attrs.field(default=None, validator=v_optional(instance_of(str)), repr=True)
class-attribute
¶
The url the embed should direct to when clicked
video: Optional[EmbedAttachment] = attrs.field(repr=False, default=None, converter=c_optional(EmbedAttachment.from_dict), metadata=no_export_meta)
class-attribute
¶
The video of the embed, only used by system embeds
add_field(name, value, inline=False)
¶
Add a field to the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The title of this field | required |
value | Any | The value in this field | required |
inline | bool | Should this field be inline with other fields? | False |
Source code in interactions/models/discord/embed.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
add_fields(*fields)
¶
Add multiple fields to the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fields | EmbedField | str | dict | The fields to add | () |
Source code in interactions/models/discord/embed.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
|
add_image(image)
¶
Add an image to the embed.
Note
To use multiple images, you must also set a url for this embed.
Warning
This takes advantage of an undocumented feature of the API, and may be removed at any time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image | str | the image to add | required |
Source code in interactions/models/discord/embed.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
set_author(name, url=None, icon_url=None)
¶
Set the author field of the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The text to go in the title section | required |
url | Optional[str] | A url link to the author | None |
icon_url | Optional[str] | A url of an image to use as the icon | None |
Source code in interactions/models/discord/embed.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
set_footer(text, icon_url=None)
¶
Set the footer field of the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | str | The text to go in the title section | required |
icon_url | Optional[str] | A url of an image to use as the icon | None |
Source code in interactions/models/discord/embed.py
403 404 405 406 407 408 409 410 411 412 413 |
|
set_image(url)
¶
Set the image of the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url | str | the url of the image to use | required |
Source code in interactions/models/discord/embed.py
353 354 355 356 357 358 359 360 361 362 |
|
set_images(*images)
¶
Set multiple images for the embed.
Note
To use multiple images, you must also set a url for this embed.
Warning
This takes advantage of an undocumented feature of the API, and may be removed at any time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images | str | the images to use | () |
Source code in interactions/models/discord/embed.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
set_thumbnail(url)
¶
Set the thumbnail of the embed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url | str | the url of the image to use | required |
Source code in interactions/models/discord/embed.py
342 343 344 345 346 347 348 349 350 351 |
|
EmbedAttachment
¶
Bases: DictSerializationMixin
Representation of an attachment.
Attributes:
Name | Type | Description |
---|---|---|
url | Optional[str] | Attachment url |
proxy_url | Optional[str] | Proxy url |
height | Optional[int] | Attachment height |
width | Optional[int] | Attachment width |
Source code in interactions/models/discord/embed.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
EmbedAuthor
¶
Bases: DictSerializationMixin
Representation of an embed author.
Attributes:
Name | Type | Description |
---|---|---|
name | Optional[str] | Name to show on embed |
url | Optional[str] | Url to go to when name is clicked |
icon_url | Optional[str] | Icon to show next to name |
proxy_icon_url | Optional[str] | Proxy icon url |
Source code in interactions/models/discord/embed.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
EmbedField
¶
Bases: DictSerializationMixin
Representation of an embed field.
Attributes:
Name | Type | Description |
---|---|---|
name | str | Field name |
value | str | Field value |
inline | bool | If the field should be inline |
Source code in interactions/models/discord/embed.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
EmbedFooter
¶
Bases: DictSerializationMixin
Representation of an Embed Footer.
Attributes:
Name | Type | Description |
---|---|---|
text | str | Footer text |
icon_url | Optional[str] | Footer icon url |
proxy_icon_url | Optional[str] | Proxy icon url |
Source code in interactions/models/discord/embed.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
converter(ingest)
classmethod
¶
A converter to handle users passing raw strings or dictionaries as footers to the Embed object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ingest | Union[dict, str, EmbedFooter] | The data to convert | required |
Returns:
Type | Description |
---|---|
EmbedFooter | An EmbedFooter object |
Source code in interactions/models/discord/embed.py
141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
EmbedProvider
¶
Bases: DictSerializationMixin
Represents an embed's provider.
Note
Only used by system embeds, not bots
Attributes:
Name | Type | Description |
---|---|---|
name | Optional[str] | Provider name |
url | Optional[str] | Provider url |
Source code in interactions/models/discord/embed.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
process_embeds(embeds)
¶
Process the passed embeds into a format discord will understand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
embeds | Optional[Union[List[Union[Embed, Dict]], Union[Embed, Dict]]] | List of dict / embeds to process | required |
Returns:
Type | Description |
---|---|
Optional[List[dict]] | formatted list for discord |
Source code in interactions/models/discord/embed.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|
Asset
¶
Represents a discord asset.
Attributes:
Name | Type | Description |
---|---|---|
BASE | str | The |
url | str | The URL of this asset |
hash | Optional[str] | The hash of this asset |
Source code in interactions/models/discord/asset.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
animated: bool
property
¶
True if this asset is animated.
url: str
property
¶
The URL of this asset.
as_url(*, extension=None, size=4096)
¶
Get the url of this asset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extension | str | None | The extension to override the assets default with | None |
size | int | The size of asset to return | 4096 |
Returns:
Type | Description |
---|---|
str | A url for this asset with the given parameters |
Source code in interactions/models/discord/asset.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
fetch(extension=None, size=None)
async
¶
Fetch the asset from the Discord CDN.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extension | Optional[str] | File extension based on the target image format | None |
size | Optional[int] | The image size, can be any power of two between 16 and 4096. | None |
Returns:
Type | Description |
---|---|
bytes | Raw byte array of the file |
Raises:
Type | Description |
---|---|
ValueError | Incorrect file size if not power of 2 between 16 and 4096 |
Source code in interactions/models/discord/asset.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
from_path_hash(client, path, asset_hash)
classmethod
¶
Create an asset from a path and asset's hash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client | Client | The bot instance | required |
path | str | The CDN Endpoints for the type of asset. | required |
asset_hash | str | The hash representation of the target asset. | required |
Returns:
Type | Description |
---|---|
Asset | A new Asset object |
Source code in interactions/models/discord/asset.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
save(fd, extension=None, size=None)
async
¶
Save the asset to a local file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fd | Union[str, bytes, PathLike, int] | Destination path to save the file to. | required |
extension | Optional[str] | File extension based on the target image format. | None |
size | Optional[int] | The image size, can be any power of two between 16 and 4096. | None |
Returns:
Type | Description |
---|---|
int | Status code result of file write |
Source code in interactions/models/discord/asset.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
BrandColors
¶
Bases: Color
, Enum
A collection of colors complying to the Discord Brand specification.
https://discord.com/branding
Source code in interactions/models/discord/color.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
Color
¶
Source code in interactions/models/discord/color.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
b: int
property
¶
Blue color value
g: int
property
¶
Green color value
hex: str
writable
property
¶
Hexadecimal representation of color value
hsv: tuple[float, float, float]
writable
property
¶
The hue, saturation, value color values in a tuple
r: int
property
¶
Red color value
rgb: tuple[int, int, int]
writable
property
¶
The red, green, blue color values in a tuple
rgb_float: tuple[float, float, float]
property
¶
The red, green, blue color values in a tuple
value: int = attrs.field(repr=True)
class-attribute
¶
The color value as an integer.
clamp(x, min_value=0, max_value=255)
staticmethod
¶
Sanitise a value between a minimum and maximum value
Source code in interactions/models/discord/color.py
54 55 56 57 |
|
from_hex(value)
classmethod
¶
Create a Color object from a hexadecimal string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | str | The hexadecimal string. | required |
Returns:
Type | Description |
---|---|
Color | A Color object. |
Source code in interactions/models/discord/color.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
from_hsv(h, s, v)
classmethod
¶
Create a Color object from a hue, saturation and value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
h | int | The hue value. | required |
s | int | The saturation value. | required |
v | int | The value value. | required |
Returns:
Type | Description |
---|---|
Color | A Color object. |
Source code in interactions/models/discord/color.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
from_rgb(r, g, b)
classmethod
¶
Create a Color object from red, green and blue values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
r | int | The red value. | required |
g | int | The green value. | required |
b | int | The blue value. | required |
Returns:
Type | Description |
---|---|
Color | A Color object. |
Source code in interactions/models/discord/color.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
random()
classmethod
¶
Returns random Color instance
Source code in interactions/models/discord/color.py
111 112 113 114 115 |
|
FlatUIColors
¶
Bases: Color
, Enum
A collection of flat ui colours.
https://materialui.co/flatuicolors
Source code in interactions/models/discord/color.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
MaterialColors
¶
Bases: Color
, Enum
A collection of material ui colors.
https://www.materialpalette.com/
Source code in interactions/models/discord/color.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
RoleColors
¶
Bases: Color
, Enum
A collection of the default role colors Discord provides.
Source code in interactions/models/discord/color.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
process_color(color)
¶
Process color to a format that can be used by discord.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color | Color | dict | COLOR_TYPES | None | The color to process. | required |
Returns:
Type | Description |
---|---|
int | None | The processed color value. |
Source code in interactions/models/discord/color.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
File
¶
Representation of a file.
Used for sending files to discord.
Source code in interactions/models/discord/file.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
content_type: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
Override the content type of the file. If you leave this empty, the content type will be guessed from the file's data
description: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
Optional description (ALT text) for the file.
file: Union[IOBase, BinaryIO, Path, str] = attrs.field(repr=True)
class-attribute
¶
Location of file to send or the bytes.
file_name: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
Set a filename that will be displayed when uploaded to discord. If you leave this empty, the file will be called file
by default
open_file()
¶
Opens the file.
Returns:
Type | Description |
---|---|
BinaryIO | IOBase | A file-like BinaryIO object. |
Source code in interactions/models/discord/file.py
35 36 37 38 39 40 41 42 43 44 45 |
|
open_file(file)
¶
Opens the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file | UPLOADABLE_TYPE | The target file or path to file. | required |
Returns:
Type | Description |
---|---|
BinaryIO | IOBase | A file-like BinaryIO object. |
Source code in interactions/models/discord/file.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
Commands¶
BaseCommand
¶
Bases: DictSerializationMixin
, CallbackObject
An object all commands inherit from. Outlines the basic structure of a command, and handles checks.
Attributes:
Name | Type | Description |
---|---|---|
extension | Optional[Extension] | The extension this command belongs to. |
enabled | bool | Whether this command is enabled |
checks | list | Any checks that must be run before this command can be run |
callback | Callable[..., Coroutine] | The coroutine to be called for this command |
error_callback | Callable[..., Coroutine] | The coroutine to be called when an error occurs |
pre_run_callback | Callable[..., Coroutine] | A coroutine to be called before this command is run but after the checks |
post_run_callback | Callable[..., Coroutine] | A coroutine to be called after this command has run |
Source code in interactions/models/internal/command.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
__call__(context, *args, **kwargs)
async
¶
Calls this command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of this command | required |
args | Any | () | |
kwargs | Any | {} |
Source code in interactions/models/internal/command.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
add_check(check)
¶
Adds a check into the command.
Source code in interactions/models/internal/command.py
236 237 238 |
|
error(call)
¶
A decorator to declare a coroutine as one that will be run upon an error.
Source code in interactions/models/internal/command.py
240 241 242 243 244 245 |
|
post_run(call)
¶
A decorator to declare a coroutine as one that will be run after the command has.
Source code in interactions/models/internal/command.py
254 255 256 257 258 259 |
|
pre_run(call)
¶
A decorator to declare a coroutine as one that will be run before the command.
Source code in interactions/models/internal/command.py
247 248 249 250 251 252 |
|
check(check)
¶
Add a check to a command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check | Callable[..., Awaitable[bool]] | A coroutine as a check for this command | required |
Source code in interactions/models/internal/command.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
cooldown(bucket, rate, interval, cooldown_system=None)
¶
Add a cooldown to a command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bucket | Buckets | The bucket used to track cooldowns | required |
rate | int | How many commands may be ran per interval | required |
interval | float | How many seconds to wait for a cooldown | required |
cooldown_system | typing.Type[CooldownSystem] | None | The cooldown system to use | None |
Source code in interactions/models/internal/command.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
max_concurrency(bucket, concurrent)
¶
Add a maximum number of concurrent instances to the command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bucket | Buckets | The bucket to enforce the maximum within | required |
concurrent | int | The maximum number of concurrent instances to allow | required |
Source code in interactions/models/internal/command.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
Application Commands¶
ActionRow
¶
Bases: BaseComponent
Represents an action row.
Attributes:
Name | Type | Description |
---|---|---|
components | list[Dict | BaseComponent] | A sequence of components contained within this action row |
Source code in interactions/models/discord/components.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
add_component(*components)
¶
Add a component to this action row.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*components | dict | BaseComponent | The component(s) to add. | () |
Source code in interactions/models/discord/components.py
145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
split_components(*components, count_per_row=5)
classmethod
¶
Split components into action rows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*components | dict | BaseComponent | The components to split. | () |
count_per_row | int | The amount of components to have per row. | 5 |
Returns:
Type | Description |
---|---|
list[ActionRow] | A list of action rows. |
Source code in interactions/models/discord/components.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
BaseComponent
¶
Bases: DictSerializationMixin
A base component class.
Warning
This should never be directly instantiated.
Source code in interactions/models/discord/components.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
from_dict(data)
classmethod
abstractmethod
¶
Create a component from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | the dictionary to create the component from | required |
Returns:
Type | Description |
---|---|
BaseComponent | The created component. |
Source code in interactions/models/discord/components.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
from_dict_factory(data, *, alternate_mapping=None)
classmethod
¶
Creates a component from a payload.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | the payload from Discord | required |
alternate_mapping | dict[ComponentType, BaseComponent] | None | an optional mapping of component types to classes | None |
Source code in interactions/models/discord/components.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
BaseSelectMenu
¶
Bases: InteractiveComponent
Represents a select menu component
Attributes:
Name | Type | Description |
---|---|---|
custom_id | str | A developer-defined identifier for the button, max 100 characters. |
placeholder | str | The custom placeholder text to show if nothing is selected, max 100 characters. |
min_values | Optional[int] | The minimum number of items that must be chosen. (default 1, min 0, max 25) |
max_values | Optional[int] | The maximum number of items that can be chosen. (default 1, max 25) |
disabled | bool | Disable the select and make it not intractable, default false. |
type | Union[ComponentType, int] | The action role type number defined by discord. This cannot be modified. |
Source code in interactions/models/discord/components.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
Button
¶
Bases: InteractiveComponent
Represents a discord ui button.
Attributes:
Name | Type | Description |
---|---|---|
style | optional[ButtonStyle, int] | Buttons come in a variety of styles to convey different types of actions. |
label | optional[str] | The text that appears on the button, max 80 characters. |
emoji | optional[Union[PartialEmoji, dict, str]] | The emoji that appears on the button. |
custom_id | Optional[str] | A developer-defined identifier for the button, max 100 characters. |
sku_id | Snowflake_Type | None | Optional[Snowflake_Type]: Identifier for a purchasable SKU, only available when using premium-style buttons |
url | Optional[str] | A url for link-style buttons. |
disabled | bool | Disable the button and make it not interactable, default false. |
Source code in interactions/models/discord/components.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
InteractiveComponent
¶
Bases: BaseComponent
A base interactive component class.
Warning
This should never be instantiated.
Source code in interactions/models/discord/components.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
RoleSelectMenu
¶
Bases: DefaultableSelectMenu
Represents a user select component.
Attributes:
Name | Type | Description |
---|---|---|
custom_id | str | A developer-defined identifier for the button, max 100 characters. |
placeholder | str | The custom placeholder text to show if nothing is selected, max 100 characters. |
min_values | Optional[int] | The minimum number of items that must be chosen. (default 1, min 0, max 25) |
max_values | Optional[int] | The maximum number of items that can be chosen. (default 1, max 25) |
disabled | bool | Disable the select and make it not intractable, default false. |
type | Union[ComponentType, int] | The action role type number defined by discord. This cannot be modified. |
Source code in interactions/models/discord/components.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|
SelectDefaultValues
¶
Bases: DiscordObject
Source code in interactions/models/discord/components.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
id: Snowflake
class-attribute
¶
ID of a user, role, or channel
type: str
class-attribute
¶
Type of value that id represents. Either "user", "role", or "channel
from_object(obj)
classmethod
¶
Create a default value from a discord object.
Source code in interactions/models/discord/components.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
StringSelectMenu
¶
Bases: BaseSelectMenu
Represents a string select component.
Attributes:
Name | Type | Description |
---|---|---|
options | List[dict] | The choices in the select, max 25. |
custom_id | str | A developer-defined identifier for the button, max 100 characters. |
placeholder | str | The custom placeholder text to show if nothing is selected, max 100 characters. |
min_values | Optional[int] | The minimum number of items that must be chosen. (default 1, min 0, max 25) |
max_values | Optional[int] | The maximum number of items that can be chosen. (default 1, max 25) |
disabled | bool | Disable the select and make it not intractable, default false. |
type | Union[ComponentType, int] | The action role type number defined by discord. This cannot be modified. |
Source code in interactions/models/discord/components.py
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
StringSelectOption
¶
Bases: BaseComponent
Represents a select option.
Attributes:
Name | Type | Description |
---|---|---|
label | str | The label (max 80 characters) |
value | str | The value of the select, this is whats sent to your bot |
description | Optional[str] | A description of this option |
emoji | Optional[Union[PartialEmoji, dict, str] | An emoji to show in this select option |
default | bool | Is this option selected by default |
Source code in interactions/models/discord/components.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
|
UserSelectMenu
¶
Bases: DefaultableSelectMenu
Represents a user select component.
Attributes:
Name | Type | Description |
---|---|---|
custom_id | str | A developer-defined identifier for the button, max 100 characters. |
placeholder | str | The custom placeholder text to show if nothing is selected, max 100 characters. |
min_values | Optional[int] | The minimum number of items that must be chosen. (default 1, min 0, max 25) |
max_values | Optional[int] | The maximum number of items that can be chosen. (default 1, max 25) |
disabled | bool | Disable the select and make it not intractable, default false. |
type | Union[ComponentType, int] | The action role type number defined by discord. This cannot be modified. |
Source code in interactions/models/discord/components.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
|
get_components_ids(component)
¶
Creates a generator with the custom_id
of a component or list of components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component | Union[str, dict, list, InteractiveComponent] | Objects to get | required |
Returns:
Type | Description |
---|---|
Iterator[str] | Generator with the |
Raises:
Type | Description |
---|---|
ValueError | Unknown component type |
Source code in interactions/models/discord/components.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
|
process_components(components)
¶
Process the passed components into a format discord will understand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
components | Optional[Union[List[List[Union[BaseComponent, Dict]]], List[Union[BaseComponent, Dict]], BaseComponent, Dict]] | List of dict / components to process | required |
Returns:
Type | Description |
---|---|
List[Dict] | formatted dictionary for discord |
Raises:
Type | Description |
---|---|
ValueError | Invalid components |
Source code in interactions/models/discord/components.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
|
spread_to_rows(*components, max_in_row=5)
¶
A helper function that spreads your components into ActionRow
s of a set size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*components | Union[ActionRow, Button, StringSelectMenu] | The components to spread, use | () |
max_in_row | int | The maximum number of components in each row | 5 |
Returns:
Type | Description |
---|---|
List[ActionRow] | List[ActionRow] of components spread to rows |
Raises:
Type | Description |
---|---|
ValueError | Too many or few components or rows |
Source code in interactions/models/discord/components.py
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
|
Modal
¶
Source code in interactions/models/discord/modal.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
add_components(*components)
¶
Add components to the modal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*components | InputText | The components to add. | () |
Source code in interactions/models/discord/modal.py
159 160 161 162 163 164 165 166 167 168 169 |
|
CallbackType
¶
Bases: IntEnum
Types of callback supported by interaction response.
Source code in interactions/models/internal/application_commands.py
195 196 197 198 199 200 201 202 203 204 |
|
ContextMenu
¶
Bases: InteractionCommand
Represents a discord context menu.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedField | The name of this entry. |
type | CommandType | The type of entry (user or message). |
Source code in interactions/models/internal/application_commands.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
InteractionCommand
¶
Bases: BaseCommand
Represents a discord abstract interaction command.
Attributes:
Name | Type | Description |
---|---|---|
scope | Denotes whether its global or for specific guild. | |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. |
dm_permission | bool | Should this command be available in DMs. |
cmd_id | Dict[str, Snowflake_Type] | The id of this command given by discord. |
callback | Callable[..., Coroutine] | The coroutine to callback when this interaction is received. |
Source code in interactions/models/internal/application_commands.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
resolved_name: str
property
¶
A representation of this interaction's name.
is_enabled(ctx)
¶
Check if this command is enabled in the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to check. | required |
Returns:
Type | Description |
---|---|
bool | Whether this command is enabled in the given context. |
Source code in interactions/models/internal/application_commands.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
mention(scope=None)
¶
Returns a string that would mention the interaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope | Optional[Snowflake_Type] | If the command is available in multiple scope, specify which scope to get the mention for. Defaults to the first available one if not specified. | None |
Returns:
Type | Description |
---|---|
str | The markdown mention. |
Source code in interactions/models/internal/application_commands.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
LocalisedDesc
¶
Bases: LocalisedField
A localisation object for descriptions.
Source code in interactions/models/internal/application_commands.py
120 121 122 123 124 125 126 127 128 129 130 |
|
LocalisedName
¶
Bases: LocalisedField
A localisation object for names.
Source code in interactions/models/internal/application_commands.py
107 108 109 110 111 112 113 114 115 116 117 |
|
OptionType
¶
Bases: IntEnum
Option types supported by slash commands.
Source code in interactions/models/internal/application_commands.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
command_types()
classmethod
¶
A tuple of all command types.
Source code in interactions/models/internal/application_commands.py
162 163 164 165 |
|
from_type(t)
classmethod
¶
Convert data types to their corresponding OptionType.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t | type | The datatype to convert | required |
Returns:
Type | Description |
---|---|
OptionType | None | OptionType or None |
Source code in interactions/models/internal/application_commands.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
resolvable_types()
classmethod
¶
A tuple of all resolvable types.
Source code in interactions/models/internal/application_commands.py
152 153 154 155 |
|
static_types()
classmethod
¶
A tuple of all static types.
Source code in interactions/models/internal/application_commands.py
157 158 159 160 |
|
SlashCommand
¶
Bases: InteractionCommand
Source code in interactions/models/internal/application_commands.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
|
autocomplete(option_name)
¶
A decorator to declare a coroutine as an option autocomplete.
Source code in interactions/models/internal/application_commands.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 |
|
SlashCommandChoice
¶
Bases: DictSerializationMixin
Represents a discord slash command choice.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedField | str | The name the user will see |
value | Union[str, int, float] | The data sent to your code when this choice is used |
Source code in interactions/models/internal/application_commands.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
|
SlashCommandOption
¶
Bases: DictSerializationMixin
Represents a discord slash command option.
Attributes:
Name | Type | Description |
---|---|---|
name | LocalisedName | str | The name of this option |
type | Union[OptionType, int] | The type of option |
description | LocalisedDesc | str | str | The description of this option |
required | bool | "This option must be filled to use the command" |
choices | List[Union[SlashCommandChoice, Dict]] | A list of choices the user has to pick between |
channel_types | Optional[list[Union[ChannelType, int]]] | The channel types permitted. The option needs to be a channel |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string |
argument_name | Optional[str] | The name of the argument to be used in the function. If not given, assumed to be the same as the name of the option |
Source code in interactions/models/internal/application_commands.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
|
application_commands_to_dict(commands, client)
¶
Convert the command list into a format that would be accepted by discord.
Client.interactions
should be the variable passed to this
Source code in interactions/models/internal/application_commands.py
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 |
|
auto_defer(enabled=True, ephemeral=False, time_until_defer=0.0)
¶
A decorator to add an auto defer to a application command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled | bool | Should the command be deferred automatically | True |
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in interactions/models/internal/application_commands.py
1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 |
|
component_callback(*custom_id)
¶
Register a coroutine as a component callback.
Component callbacks work the same way as commands, just using components as a way of invoking, instead of messages. Your callback will be given a single argument, ComponentContext
Note
This can optionally take a regex pattern, which will be used to match against the custom ID of the component.
If you do not supply a custom_id
, the name of the coroutine will be used instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*custom_id | str | re.Pattern | The custom ID of the component to wait for | () |
Source code in interactions/models/internal/application_commands.py
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 |
|
context_menu(name=MISSING, *, context_type, scopes=MISSING, default_member_permissions=None, integration_types=None, contexts=None, dm_permission=True)
¶
A decorator to declare a coroutine as a Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
context_type | CommandType | The type of context menu | required |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
integration_types | Optional[List[Union[IntegrationType, int]]] | Installation context(s) where the command is available, only for globally-scoped commands. | None |
contexts | Optional[List[Union[ContextType, int]]] | Interaction context(s) where the command can be used, only for globally-scoped commands. | None |
dm_permission | bool | Should this command be available in DMs (deprecated). | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions/models/internal/application_commands.py
1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
|
contexts(guild=True, bot_dm=True, private_channel=True)
¶
A decorator to set contexts where the command can be used for a application command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild | bool | Should the command be available in guilds | True |
bot_dm | bool | Should the command be available in bot DMs | True |
private_channel | bool | Should the command be available in private channels | True |
Source code in interactions/models/internal/application_commands.py
1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 |
|
global_autocomplete(option_name)
¶
Decorator for global autocomplete functions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
option_name | str | The name of the option to register the autocomplete function for | required |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], GlobalAutoComplete] | The decorator |
Source code in interactions/models/internal/application_commands.py
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
|
integration_types(guild=True, user=False)
¶
A decorator to set integration types for an application command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild | bool | Should the command be available for guilds | True |
user | bool | Should the command be available for individual users | False |
Source code in interactions/models/internal/application_commands.py
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 |
|
message_context_menu(name=MISSING, *, scopes=MISSING, default_member_permissions=None, integration_types=None, contexts=None, dm_permission=True)
¶
A decorator to declare a coroutine as a Message Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
integration_types | Optional[List[Union[IntegrationType, int]]] | Installation context(s) where the command is available, only for globally-scoped commands. | None |
contexts | Optional[List[Union[ContextType, int]]] | Interaction context(s) where the command can be used, only for globally-scoped commands. | None |
dm_permission | bool | Should this command be available in DMs (deprecated). | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions/models/internal/application_commands.py
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
|
modal_callback(*custom_id)
¶
Register a coroutine as a modal callback.
Modal callbacks work the same way as commands, just using modals as a way of invoking, instead of messages. Your callback will be given a single argument, ModalContext
Note
This can optionally take a regex pattern, which will be used to match against the custom ID of the modal.
If you do not supply a custom_id
, the name of the coroutine will be used instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*custom_id | str | re.Pattern | The custom ID of the modal to wait for | () |
Source code in interactions/models/internal/application_commands.py
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
|
slash_command(name=MISSING, *, description=MISSING, scopes=MISSING, options=None, default_member_permissions=None, integration_types=None, contexts=None, dm_permission=True, sub_cmd_name=None, group_name=None, sub_cmd_description='No Description Set', group_description='No Description Set', nsfw=False)
¶
A decorator to declare a coroutine as a slash command.
Note
While the base and group descriptions arent visible in the discord client, currently. We strongly advise defining them anyway, if you're using subcommands, as Discord has said they will be visible in one of the future ui updates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the command, defaults to the name of the coroutine. | MISSING |
description | Absent[str | LocalisedDesc] | 1-100 character description of the command | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
options | Optional[List[Union[SlashCommandOption, Dict]]] | The parameters for the command, max 25 | None |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
integration_types | Optional[List[Union[IntegrationType, int]]] | Installation context(s) where the command is available, only for globally-scoped commands. | None |
contexts | Optional[List[Union[ContextType, int]]] | Interaction context(s) where the command can be used, only for globally-scoped commands. | None |
dm_permission | bool | Should this command be available in DMs (deprecated). | True |
sub_cmd_name | str | LocalisedName | 1-32 character name of the subcommand | None |
sub_cmd_description | str | LocalisedDesc | 1-100 character description of the subcommand | 'No Description Set' |
group_name | str | LocalisedName | 1-32 character name of the group | None |
group_description | str | LocalisedDesc | 1-100 character description of the group | 'No Description Set' |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], SlashCommand] | SlashCommand Object |
Source code in interactions/models/internal/application_commands.py
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 |
|
slash_default_member_permission(permission)
¶
A decorator to permissions members need to have by default to use a command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
permission | Permissions | The permissions to require for to this command | required |
Source code in interactions/models/internal/application_commands.py
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 |
|
slash_option(name, description, opt_type, required=False, autocomplete=False, choices=None, channel_types=None, min_value=None, max_value=None, min_length=None, max_length=None, argument_name=None)
¶
A decorator to add an option to a slash command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | 1-32 lowercase character name matching ^[\w-]{1,32}$ | required |
opt_type | Union[OptionType, int] | The type of option | required |
description | str | 1-100 character description of option | required |
required | bool | If the parameter is required or optional--default false | False |
autocomplete | bool | If autocomplete interactions are enabled for this STRING, INTEGER, or NUMBER type option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | A list of choices the user has to pick between (max 25) | None |
channel_types | Optional[list[Union[ChannelType, int]]] | The channel types permitted. The option needs to be a channel | None |
min_value | Optional[float] | The minimum value permitted. The option needs to be an integer or float | None |
max_value | Optional[float] | The maximum value permitted. The option needs to be an integer or float | None |
min_length | Optional[int] | The minimum length of text a user can input. The option needs to be a string | None |
max_length | Optional[int] | The maximum length of text a user can input. The option needs to be a string | None |
argument_name | Optional[str] | The name of the argument to be used in the function. If not given, assumed to be the same as the name of the option | None |
Source code in interactions/models/internal/application_commands.py
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
|
subcommand(base, *, subcommand_group=None, name=MISSING, description=MISSING, base_description=None, base_desc=None, base_default_member_permissions=None, base_integration_types=None, base_contexts=None, base_dm_permission=True, subcommand_group_description=None, sub_group_desc=None, scopes=None, options=None, nsfw=False)
¶
A decorator specifically tailored for creating subcommands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base | str | LocalisedName | The name of the base command | required |
subcommand_group | Optional[str | LocalisedName] | The name of the subcommand group, if any. | None |
name | Absent[str | LocalisedName] | The name of the subcommand, defaults to the name of the coroutine. | MISSING |
description | Absent[str | LocalisedDesc] | The description of the subcommand | MISSING |
base_description | Optional[str | LocalisedDesc] | The description of the base command | None |
base_desc | Optional[str | LocalisedDesc] | An alias of | None |
base_default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
base_integration_types | Optional[List[Union[IntegrationType, int]]] | Installation context(s) where the command is available, only for globally-scoped commands. | None |
base_contexts | Optional[List[Union[ContextType, int]]] | Interaction context(s) where the command can be used, only for globally-scoped commands. | None |
base_dm_permission | bool | Should this command be available in DMs (deprecated). | True |
subcommand_group_description | Optional[str | LocalisedDesc] | Description of the subcommand group | None |
sub_group_desc | Optional[str | LocalisedDesc] | An alias for | None |
scopes | List[Snowflake_Type] | None | The scopes of which this command is available, defaults to GLOBAL_SCOPE | None |
options | List[dict] | None | The options for this command | None |
nsfw | bool | This command should only work in NSFW channels | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], SlashCommand] | A SlashCommand object |
Source code in interactions/models/internal/application_commands.py
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
|
sync_needed(local_cmd, remote_cmd=None)
¶
Compares a local application command to its remote counterpart to determine if a sync is required.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
local_cmd | dict | The local json representation of the command | required |
remote_cmd | Optional[dict] | The json representation of the command from Discord | None |
Returns:
Type | Description |
---|---|
bool | Boolean indicating if a sync is needed |
Source code in interactions/models/internal/application_commands.py
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 |
|
user_context_menu(name=MISSING, *, scopes=MISSING, default_member_permissions=None, integration_types=None, contexts=None, dm_permission=True)
¶
A decorator to declare a coroutine as a User Context Menu.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Absent[str | LocalisedName] | 1-32 character name of the context menu, defaults to the name of the coroutine. | MISSING |
scopes | Absent[List[Snowflake_Type]] | The scope this command exists within | MISSING |
default_member_permissions | Optional[Permissions] | What permissions members need to have by default to use this command. | None |
integration_types | Optional[List[Union[IntegrationType, int]]] | Installation context(s) where the command is available, only for globally-scoped commands. | None |
contexts | Optional[List[Union[ContextType, int]]] | Interaction context(s) where the command can be used, only for globally-scoped commands. | None |
dm_permission | bool | Should this command be available in DMs (deprecated). | True |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], ContextMenu] | ContextMenu object |
Source code in interactions/models/internal/application_commands.py
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 |
|
Context¶
AutocompleteContext
¶
Bases: BaseInteractionContext[ClientT]
Source code in interactions/models/internal/context.py
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
|
focussed_option: SlashCommandOption
class-attribute
¶
The option the user is currently filling in.
input_text: str
property
¶
The text the user has already filled in.
send(choices)
async
¶
Send your autocomplete choices to discord. Choices must be either a list of strings, or a dictionary following the following format:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
choices | typing.Iterable[str | int | float | dict[str, int | float | str] | SlashCommandChoice] | 25 choices the user can pick | required |
Source code in interactions/models/internal/context.py
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
|
BaseContext
¶
Bases: typing.Generic[ClientT]
Base context class for all contexts.
Define your own context class by inheriting from this class. For compatibility with the library, you must define a from_dict
classmethod that takes a dict and returns an instance of your context class.
Source code in interactions/models/internal/context.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
author: interactions.Member | interactions.User
property
¶
The member or user that invoked this context.
channel: interactions.TYPE_MESSAGEABLE_CHANNEL
property
¶
The channel this context was invoked in.
client: ClientT = client
instance-attribute
¶
The client that created this context.
command: BaseCommand
class-attribute
¶
The command this context invokes.
guild: typing.Optional[interactions.Guild]
property
¶
The guild this context was invoked in.
member: typing.Optional[interactions.Member]
property
¶
The member object that invoked this context.
message: typing.Optional[interactions.Message]
property
¶
The message that invoked this context, if any.
user: interactions.User
property
¶
The user that invoked this context.
voice_state: typing.Optional[interactions.VoiceState]
property
¶
The current voice state of the bot in the guild this context was invoked in, if any.
from_dict(client, payload)
classmethod
abstractmethod
¶
Create a context instance from a dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client | ClientT | The client creating this context. | required |
payload | dict | The dict to create the context from. | required |
Returns:
Type | Description |
---|---|
Self | The context instance. |
Source code in interactions/models/internal/context.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
BaseInteractionContext
¶
Bases: BaseContext[ClientT]
Source code in interactions/models/internal/context.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
app_permissions: Permissions
property
¶
The permissions available to this interaction
args: list[typing.Any]
class-attribute
¶
The arguments passed to the interaction.
author_permissions: Permissions
property
¶
The permissions available to the author of this interaction
authorizing_integration_owners: dict[IntegrationType, Snowflake]
class-attribute
¶
Mapping of installation contexts that the interaction was authorized for to related user or guild IDs
command_id: Snowflake
class-attribute
¶
The command ID of the interaction.
context: typing.Optional[ContextType]
class-attribute
¶
Context where the interaction was triggered from
deferred_ephemeral: bool
property
¶
Whether the interaction has been deferred ephemerally.
entitlements: list[Entitlement]
class-attribute
¶
The entitlements of the invoking user.
expired: bool
property
¶
Whether the interaction has expired.
expires_at: Timestamp
property
¶
The time at which the interaction expires.
guild_locale: str
class-attribute
¶
The selected locale of the invoking user's guild (https://discord.com/developers/docs/reference#locales)
id: Snowflake
class-attribute
¶
The interaction ID.
invoke_target: str
property
¶
The invoke target of the interaction.
kwargs: dict[str, typing.Any]
class-attribute
¶
The keyword arguments passed to the interaction.
locale: str
class-attribute
¶
The selected locale of the invoking user (https://discord.com/developers/docs/reference#locales)
resolved: Resolved
class-attribute
¶
The resolved data for this interaction.
token: str
class-attribute
¶
The interaction token.
option_processing_hook(option)
¶
Hook for extending options processing.
This is called for each option, before the library processes it. If this returns a value, the library will not process the option further.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
option | dict | The option to process. | required |
Returns:
Type | Description |
---|---|
typing.Any | The processed option. |
Source code in interactions/models/internal/context.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
ComponentContext
¶
Bases: InteractionContext[ClientT]
, ModalMixin
Source code in interactions/models/internal/context.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 |
|
component: typing.Optional[BaseComponent]
property
¶
The component that was interacted with.
component_type: int
class-attribute
¶
The type of the component.
custom_id: str
class-attribute
¶
The custom_id of the component.
defer_edit_origin: bool
class-attribute
¶
Whether you have deferred the interaction and are editing the original response.
values: list[str]
class-attribute
¶
The values of the SelectMenu component, if any.
defer(*, ephemeral=False, edit_origin=False, suppress_error=False)
async
¶
Defer the interaction.
Note
This method's ephemeral settings override the ephemeral settings of send()
.
For example, deferring with ephemeral=True
will make the response ephemeral even with send(ephemeral=False)
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ephemeral | bool | Whether the interaction response should be ephemeral. | False |
edit_origin | bool | Whether to edit the original message instead of sending a new one. | False |
suppress_error | bool | Should errors on deferring be suppressed than raised. | False |
Source code in interactions/models/internal/context.py
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
|
edit_origin(*, content=None, embeds=None, embed=None, components=None, allowed_mentions=None, files=None, file=None, tts=False)
async
¶
Edits the original message of the component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | typing.Optional[str] | Message text content. | None |
embeds | typing.Optional[typing.Union[typing.Iterable[typing.Union[Embed, dict]], typing.Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | typing.Optional[typing.Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | typing.Optional[typing.Union[typing.Iterable[typing.Iterable[typing.Union[BaseComponent, dict]]], typing.Iterable[typing.Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
allowed_mentions | typing.Optional[typing.Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
files | typing.Optional[typing.Union[UPLOADABLE_TYPE, typing.Iterable[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | typing.Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
Returns:
Type | Description |
---|---|
Message | The message after it was edited. |
Source code in interactions/models/internal/context.py
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
|
ContextMenuContext
¶
Bases: InteractionContext[ClientT]
, ModalMixin
Source code in interactions/models/internal/context.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 |
|
target: None | Message | User | Member
property
¶
target_id: Snowflake
class-attribute
¶
The id of the target of the context menu.
target_type: None | CommandType
class-attribute
¶
The type of the target of the context menu.
defer(*, ephemeral=False, edit_origin=False, suppress_error=False)
async
¶
Defer the interaction.
Note
This method's ephemeral settings override the ephemeral settings of send()
.
For example, deferring with ephemeral=True
will make the response ephemeral even with send(ephemeral=False)
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ephemeral | bool | Whether the interaction response should be ephemeral. | False |
edit_origin | bool | Whether to edit the original message instead of sending a new one. | False |
suppress_error | bool | Should errors on deferring be suppressed than raised. | False |
Source code in interactions/models/internal/context.py
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
|
InteractionContext
¶
Bases: BaseInteractionContext[ClientT]
, SendMixin
Source code in interactions/models/internal/context.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 |
|
defer(*, ephemeral=False, suppress_error=False)
async
¶
Defer the interaction.
Note
This method's ephemeral settings override the ephemeral settings of send()
.
For example, deferring with ephemeral=True
will make the response ephemeral even with send(ephemeral=False)
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ephemeral | bool | Whether the interaction response should be ephemeral. | False |
suppress_error | bool | Should errors on deferring be suppressed than raised. | False |
Source code in interactions/models/internal/context.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
delete(message='@original')
async
¶
Delete a message sent in response to this interaction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | Snowflake_Type | The message to delete. Defaults to @original which represents the initial response message. | '@original' |
Source code in interactions/models/internal/context.py
606 607 608 609 610 611 612 613 614 615 616 |
|
send(content=None, *, embeds=None, embed=None, components=None, stickers=None, allowed_mentions=None, reply_to=None, files=None, file=None, tts=False, suppress_embeds=False, silent=False, flags=None, poll=None, delete_after=None, ephemeral=False, **kwargs)
async
¶
Send a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content | typing.Optional[str] | Message text content. | None |
embeds | typing.Optional[typing.Union[typing.Iterable[typing.Union[Embed, dict]], typing.Union[Embed, dict]]] | Embedded rich content (up to 6000 characters). | None |
embed | typing.Optional[typing.Union[Embed, dict]] | Embedded rich content (up to 6000 characters). | None |
components | typing.Optional[typing.Union[typing.Iterable[typing.Iterable[typing.Union[BaseComponent, dict]]], typing.Iterable[typing.Union[BaseComponent, dict]], BaseComponent, dict]] | The components to include with the message. | None |
stickers | typing.Optional[typing.Union[typing.Iterable[typing.Union[Sticker, Snowflake_Type]], Sticker, Snowflake_Type]] | IDs of up to 3 stickers in the server to send in the message. | None |
allowed_mentions | typing.Optional[typing.Union[AllowedMentions, dict]] | Allowed mentions for the message. | None |
reply_to | typing.Optional[typing.Union[MessageReference, Message, dict, Snowflake_Type]] | Message to reference, must be from the same channel. | None |
files | typing.Optional[typing.Union[UPLOADABLE_TYPE, typing.Iterable[UPLOADABLE_TYPE]]] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
file | typing.Optional[UPLOADABLE_TYPE] | Files to send, the path, bytes or File() instance, defaults to None. You may have up to 10 files. | None |
tts | bool | Should this message use Text To Speech. | False |
suppress_embeds | bool | Should embeds be suppressed on this send | False |
silent | bool | Should this message be sent without triggering a notification. | False |
flags | typing.Optional[typing.Union[int, MessageFlags]] | Message flags to apply. | None |
poll | Optional[Poll | dict] | A poll. | None |
delete_after | typing.Optional[float] | Delete message after this many seconds. | None |
ephemeral | bool | Whether the response should be ephemeral | False |
Returns:
Type | Description |
---|---|
Message | New message object that was sent. |
Source code in interactions/models/internal/context.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
send_premium_required()
async
¶
Send a premium required response.
Warn
This response has been deprecated by Discord and will be removed in the future. Use a button with the PREMIUM type instead.
When used, the user will be prompted to subscribe to premium to use this feature. Only available for applications with monetization enabled.
Source code in interactions/models/internal/context.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
|
ModalContext
¶
Bases: InteractionContext[ClientT]
Source code in interactions/models/internal/context.py
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
|
custom_id: str
class-attribute
¶
The developer defined custom ID of this modal
edit_origin: bool
class-attribute
¶
Whether to edit the original message instead of sending a new one.
responses: dict[str, str]
class-attribute
¶
The responses of the modal. The key is the custom_id
of the component.
defer(*, ephemeral=False, edit_origin=False, suppress_error=False)
async
¶
Defer the interaction.
Note
This method's ephemeral settings override the ephemeral settings of send()
.
For example, deferring with ephemeral=True
will make the response ephemeral even with send(ephemeral=False)
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ephemeral | bool | Whether the interaction response should be ephemeral. | False |
edit_origin | bool | Whether to edit the original message instead of sending a followup. | False |
suppress_error | bool | Should errors on deferring be suppressed than raised. | False |
Source code in interactions/models/internal/context.py
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
|
Resolved
¶
A class representing the resolved data from an interaction.
Attributes:
Name | Type | Description |
---|---|---|
channels | dict[Snowflake, TYPE_MESSAGEABLE_CHANNEL] | A dictionary of channels resolved from the interaction. |
members | dict[Snowflake, Member] | A dictionary of members resolved from the interaction. |
users | dict[Snowflake, User] | A dictionary of users resolved from the interaction. |
roles | dict[Snowflake, Role] | A dictionary of roles resolved from the interaction. |
messages | dict[Snowflake, Message] | A dictionary of messages resolved from the interaction. |
attachments | dict[Snowflake, Attachment] | A dictionary of attachments resolved from the interaction. |
Source code in interactions/models/internal/context.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
__bool__()
¶
Returns whether any resolved data is present.
Source code in interactions/models/internal/context.py
91 92 93 94 95 96 97 98 99 100 |
|
Presence¶
Activity
¶
Bases: DictSerializationMixin
Represents a discord activity object use for rich presence in discord.
Source code in interactions/models/discord/activity.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
application_id: Snowflake_Type = attrs.field(repr=False, default=None)
class-attribute
¶
Application id for the game
assets: Optional[ActivityAssets] = attrs.field(repr=False, default=None, converter=optional(ActivityAssets.from_dict))
class-attribute
¶
Assets to display on the player's profile
buttons: List[str] = attrs.field(repr=False, factory=list)
class-attribute
¶
The custom buttons shown in the Rich Presence (max 2)
created_at: Optional[Timestamp] = attrs.field(repr=True, default=None, converter=optional(timestamp_converter))
class-attribute
¶
When the activity was added to the user's session
details: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
What the player is currently doing
emoji: Optional[PartialEmoji] = attrs.field(repr=False, default=None, converter=optional(PartialEmoji.from_dict))
class-attribute
¶
The emoji used for a custom status
flags: Optional[ActivityFlag] = attrs.field(repr=False, default=None, converter=optional(ActivityFlag))
class-attribute
¶
Activity flags bitwise OR together, describes what the payload includes
instance: Optional[bool] = attrs.field(repr=False, default=False)
class-attribute
¶
Whether or not the activity is an instanced game session
name: str = attrs.field(repr=True)
class-attribute
¶
The activity's name
party: Optional[ActivityParty] = attrs.field(repr=False, default=None, converter=optional(ActivityParty.from_dict))
class-attribute
¶
Information for the current party of the player
secrets: Optional[ActivitySecrets] = attrs.field(repr=False, default=None, converter=optional(ActivitySecrets.from_dict))
class-attribute
¶
Secrets for Rich Presence joining and spectating
state: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The user's current party status, or text used for a custom status if type is set as CUSTOM
timestamps: Optional[ActivityTimestamps] = attrs.field(repr=False, default=None, converter=optional(ActivityTimestamps.from_dict))
class-attribute
¶
Start and/or end of the game
type: ActivityType = attrs.field(repr=True, default=ActivityType.GAME)
class-attribute
¶
The type of activity
url: Optional[str] = attrs.field(repr=True, default=None)
class-attribute
¶
Stream url, is validated when type is 1
create(name, type=ActivityType.GAME, url=None, state=None)
classmethod
¶
Creates an activity object for the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | The new activity's name | required |
type | ActivityType | Type of activity to create | ActivityType.GAME |
url | Optional[str] | Stream link for the activity | None |
state | Optional[str] | Current party status, or text used for a custom status if type is set as CUSTOM | None |
Returns:
Type | Description |
---|---|
Activity | The new activity object |
Source code in interactions/models/discord/activity.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
ActivityAssets
¶
Bases: DictSerializationMixin
Source code in interactions/models/discord/activity.py
38 39 40 41 42 43 44 45 46 47 |
|
large_image: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The large image for this activity. Uses discord's asset image url format.
large_text: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
Hover text for the large image
small_image: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The large image for this activity. Uses discord's asset image url format.
small_text: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
Hover text for the small image
ActivityParty
¶
Bases: DictSerializationMixin
Source code in interactions/models/discord/activity.py
30 31 32 33 34 35 |
|
ActivitySecrets
¶
Bases: DictSerializationMixin
Source code in interactions/models/discord/activity.py
50 51 52 53 54 55 56 57 |
|
join: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The secret for joining a party
match: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The secret for a specific instanced match
spectate: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The secret for spectating a party
ActivityTimestamps
¶
Bases: DictSerializationMixin
Source code in interactions/models/discord/activity.py
22 23 24 25 26 27 |
|
end: Optional[Timestamp] = attrs.field(repr=False, default=None, converter=optional(timestamp_converter))
class-attribute
¶
The end time of the activity. Shows "remaining" timer on discord client.
start: Optional[Timestamp] = attrs.field(repr=False, default=None, converter=optional(timestamp_converter))
class-attribute
¶
The start time of the activity. Shows "elapsed" timer on discord client.
Data¶
Application
¶
Bases: DiscordObject
Represents a discord application.
Source code in interactions/models/discord/application.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
bot_public: bool = attrs.field(repr=False, default=True)
class-attribute
¶
When false only app owner can join the app's bot to guilds
bot_require_code_grant: bool = attrs.field(repr=False, default=False)
class-attribute
¶
When true the app's bot will only join upon completion of the full oauth2 code grant flow
cover_image: Optional[Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
The application's default rich presence invite cover
custom_install_url: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The application's custom authorization link for invitation to a guild
description: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The description of the application
flags: Optional[ApplicationFlags] = attrs.field(repr=False, default=None, converter=optional(ApplicationFlags))
class-attribute
¶
The application's public flags
guild_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
If this application is a game sold on Discord, this field will be the guild to which it has been linked
icon: Optional[Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
The icon of the application
install_params: Optional[dict] = attrs.field(repr=False, default=None)
class-attribute
¶
The application's settings for in-app invitation to guilds
integration_types_config: Optional[dict] = attrs.field(repr=False, default=None)
class-attribute
¶
Default scopes and permissions for each supported installation context. Value for each key is an integration type configuration object
name: str = attrs.field(repr=True)
class-attribute
¶
The name of the application
owner: User
property
¶
The user object for the owner of this application
owner_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None, converter=optional(to_snowflake))
class-attribute
¶
The id of the owner of the application
primary_sku_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists
privacy_policy_url: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The url of the app's privacy policy
rpc_origins: Optional[List[str]] = attrs.field(repr=False, default=None)
class-attribute
¶
An array of rpc origin urls, if rpc is enabled
slug: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
If this application is a game sold on Discord, this field will be the URL slug that links to the store page
summary: str = attrs.field(repr=False)
class-attribute
¶
If this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku
tags: Optional[List[str]] = attrs.field(repr=False, default=None)
class-attribute
¶
The application's tags describing its functionality and content
team: Optional[Team] = attrs.field(repr=False, default=None)
class-attribute
¶
If the application belongs to a team, this will be a list of the members of that team
terms_of_service_url: Optional[str] = attrs.field(repr=False, default=None)
class-attribute
¶
The url of the app's terms of service
verify_key: Optional[str] = attrs.field(repr=False, default=MISSING)
class-attribute
¶
The hex encoded key for verification in interactions and the GameSDK's GetTicket
Team
¶
Bases: DiscordObject
Source code in interactions/models/discord/team.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
icon: Optional[Asset] = attrs.field(repr=False, default=None)
class-attribute
¶
A hash of the image of the team's icon
members: List[TeamMember] = attrs.field(repr=False, factory=list)
class-attribute
¶
The members of the team
name: str = attrs.field(repr=True)
class-attribute
¶
The name of the team
owner: User
property
¶
The owner of the team
owner_user_id: Snowflake_Type = attrs.field(repr=False, converter=to_snowflake)
class-attribute
¶
The user id of the current team owner
is_in_team(user)
¶
Returns True if the passed user or ID is a member within the team.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user | Union[SnowflakeObject, Snowflake_Type] | The user or user ID to check | required |
Returns:
Type | Description |
---|---|
bool | Boolean indicating whether the user is in the team |
Source code in interactions/models/discord/team.py
60 61 62 63 64 65 66 67 68 69 70 71 |
|
TeamMember
¶
Bases: DiscordObject
Source code in interactions/models/discord/team.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
membership_state: TeamMembershipState = attrs.field(repr=False, converter=TeamMembershipState)
class-attribute
¶
Rhe user's membership state on the team
team_id: Snowflake_Type = attrs.field(repr=True)
class-attribute
¶
Rhe id of the parent team of which they are a member
user: User = attrs.field(repr=False)
class-attribute
¶
Rhe avatar, discriminator, id, and username of the user
ActivityType
¶
Bases: CursedIntEnum
The types of presence activity that can be used in presences.
Note
Only GAME
STREAMING
LISTENING
WATCHING
and COMPETING
are usable by bots
Source code in interactions/models/discord/enums.py
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
|
COMPETING = 5
class-attribute
¶
Competing in {name}; Example: Competing in Arena World Champions
CUSTOM = 4
class-attribute
¶
{emoji} {name}; Example: :smiley: I am cool
GAME = 0
class-attribute
¶
Playing {name}; Example: Playing Rocket League
LISTENING = 2
class-attribute
¶
Listening to {name}; Example: Listening to Spotify
PLAYING = GAME
class-attribute
¶
Alias for GAME
STREAMING = 1
class-attribute
¶
Streaming {details}; Example: Streaming Rocket League
WATCHING = 3
class-attribute
¶
Watching {name}; Example: Watching YouTube Together
ApplicationFlags
¶
Bases: DiscordIntFlag
Flags an application can have.
Source code in interactions/models/discord/enums.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
|
EMBEDDED = 1 << 17
class-attribute
¶
Application is a voice channel activity (ie YouTube Together)
GATEWAY_GUILD_MEMBERS = 1 << 14
class-attribute
¶
Verified to use guild members intent
GATEWAY_GUILD_MEMBERS_LIMITED = 1 << 15
class-attribute
¶
Using members intent, without verification
GATEWAY_PRESENCE = 1 << 12
class-attribute
¶
Verified to use presence intent
GATEWAY_PRESENCE_LIMITED = 1 << 13
class-attribute
¶
Using presence intent, without verification
VERIFICATION_PENDING_GUILD_LIMIT = 1 << 16
class-attribute
¶
Bot has hit guild limit, and has not been successfully verified
AuditLogEventType
¶
Bases: CursedIntEnum
The type of audit log entry type
ref: https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
Source code in interactions/models/discord/enums.py
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
|
AutoArchiveDuration
¶
Bases: CursedIntEnum
Thread archive duration, in minutes.
Source code in interactions/models/discord/enums.py
885 886 887 888 889 890 891 |
|
ButtonStyle
¶
Bases: CursedIntEnum
The styles of buttons supported.
Source code in interactions/models/discord/enums.py
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
|
ChannelFlags
¶
Bases: DiscordIntFlag
Source code in interactions/models/discord/enums.py
864 865 866 867 868 869 870 871 872 873 874 875 |
|
CLYDE_THREAD = 1 << 8
class-attribute
¶
This thread was created by Clyde
HIDE_MEDIA_DOWNLOAD_OPTIONS = 1 << 15
class-attribute
¶
when set hides the embedded media download options. Available only for media channels
PINNED = 1 << 1
class-attribute
¶
Thread is pinned to the top of its parent forum channel
REQUIRE_TAG = 1 << 4
class-attribute
¶
Whether a tag is required to be specified when creating a thread in a Guild Forum or Media channel.
ChannelType
¶
Bases: CursedIntEnum
Types of channel.
Source code in interactions/models/discord/enums.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 |
|
DM = 1
class-attribute
¶
Direct message between users
GROUP_DM = 3
class-attribute
¶
Direct message between multiple users
GUILD_CATEGORY = 4
class-attribute
¶
Organizational category that contains up to 50 channels
GUILD_FORUM = 15
class-attribute
¶
A Forum channel
GUILD_MEDIA = 16
class-attribute
¶
Channel that can only contain threads, similar to GUILD_FORUM
channels
GUILD_NEWS = 5
class-attribute
¶
Channel that users can follow and crosspost into their own server
GUILD_NEWS_THREAD = 10
class-attribute
¶
Temporary sub-channel within a GUILD_NEWS channel
GUILD_PRIVATE_THREAD = 12
class-attribute
¶
Temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission
GUILD_PUBLIC_THREAD = 11
class-attribute
¶
Temporary sub-channel within a GUILD_TEXT channel
GUILD_STAGE_VOICE = 13
class-attribute
¶
Voice channel for hosting events with an audience
GUILD_TEXT = 0
class-attribute
¶
Text channel within a server
GUILD_VOICE = 2
class-attribute
¶
Voice channel within a server
guild: bool
property
¶
Whether this channel is a guild channel.
voice: bool
property
¶
Whether this channel is a voice channel.
CommandType
¶
Bases: CursedIntEnum
The interaction commands supported by discord.
Source code in interactions/models/discord/enums.py
701 702 703 704 705 706 707 708 709 |
|
CHAT_INPUT = 1
class-attribute
¶
Slash commands; a text-based command that shows up when a user types /
MESSAGE = 3
class-attribute
¶
A UI-based command that shows up when you right click or tap on a message
USER = 2
class-attribute
¶
A UI-based command that shows up when you right click or tap on a user
ComponentType
¶
Bases: CursedIntEnum
The types of components supported by discord.
Source code in interactions/models/discord/enums.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
ACTION_ROW = 1
class-attribute
¶
Container for other components
BUTTON = 2
class-attribute
¶
Button object
CHANNEL_SELECT = 8
class-attribute
¶
Select menu for picking from channels
INPUT_TEXT = 4
class-attribute
¶
Text input object
MENTIONABLE_SELECT = 7
class-attribute
¶
Select menu for picking from mentionable objects
ROLE_SELECT = 6
class-attribute
¶
Select menu for picking from roles
STRING_SELECT = 3
class-attribute
¶
Select menu for picking from text choices
USER_SELECT = 5
class-attribute
¶
Select menu for picking from users
ContextType
¶
Bases: CursedIntEnum
The context of where an interaction can be used.
Source code in interactions/models/discord/enums.py
693 694 695 696 697 698 |
|
CursedIntEnum
¶
Bases: IntEnum
Source code in interactions/models/discord/enums.py
144 145 146 147 148 |
|
DefaultNotificationLevel
¶
Bases: CursedIntEnum
Default Notification levels for dms and guilds.
Source code in interactions/models/discord/enums.py
788 789 790 791 792 |
|
EmbedType
¶
Bases: Enum
Types of embed.
Source code in interactions/models/discord/enums.py
440 441 442 443 444 445 446 447 448 449 450 451 |
|
EntitlementType
¶
Bases: CursedIntEnum
The type of entitlement.
Source code in interactions/models/discord/enums.py
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
APPLICATION_SUBSCRIPTION = 8
class-attribute
¶
Entitlement was purchased as an app subscription
DEVELOPER_GIFT = 3
class-attribute
¶
Entitlement was gifted by developer
FREE_PURCHASE = 5
class-attribute
¶
Entitlement was granted when the SKU was free
PREMIUM_PURCHASE = 7
class-attribute
¶
Entitlement was claimed by user for free as a Nitro Subscriber
PREMIUM_SUBSCRIPTION = 2
class-attribute
¶
Entitlement for Discord Nitro subscription
PURCHASE = 1
class-attribute
¶
Entitlement was purchased by user
TEST_MODE_PURCHASE = 4
class-attribute
¶
Entitlement was purchased by a dev in application test mode
USER_GIFT = 6
class-attribute
¶
Entitlement was gifted by another user
ExplicitContentFilterLevel
¶
Bases: CursedIntEnum
Automatic filtering of explicit content.
Source code in interactions/models/discord/enums.py
795 796 797 798 799 800 |
|
ForumLayoutType
¶
Bases: CursedIntEnum
The layout of a forum channel.
Source code in interactions/models/discord/enums.py
1121 1122 1123 1124 1125 1126 |
|
ForumSortOrder
¶
Bases: CursedIntEnum
The order of a forum channel.
Source code in interactions/models/discord/enums.py
1129 1130 1131 1132 1133 1134 1135 1136 1137 |
|
IntegrationType
¶
Bases: CursedIntEnum
The types of installation contexts supported by discord.
Source code in interactions/models/discord/enums.py
686 687 688 689 690 |
|
Intents
¶
Bases: DiscordIntFlag
When identifying to the gateway, you can specify an intents parameter which allows you to conditionally subscribe to pre-defined "intents", groups of events defined by Discord.
info
For details about what intents do, or which intents you'll want, please read the Discord API Documentation
Source code in interactions/models/discord/enums.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
new(guilds=False, guild_members=False, guild_moderation=False, guild_emojis_and_stickers=False, guild_integrations=False, guild_webhooks=False, guild_invites=False, guild_voice_states=False, guild_presences=False, guild_messages=False, guild_message_polls=False, guild_message_reactions=False, guild_message_typing=False, direct_messages=False, direct_message_polls=False, direct_message_reactions=False, direct_message_typing=False, message_content=False, guild_scheduled_events=False, messages=False, polls=False, reactions=False, typing=False, privileged=False, non_privileged=False, default=False, all=False)
classmethod
¶
Set your desired intents.
Source code in interactions/models/discord/enums.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
InteractionPermissionTypes
¶
Bases: CursedIntEnum
The type of interaction permission received by discord.
Source code in interactions/models/discord/enums.py
722 723 724 725 726 727 |
|
InteractionType
¶
Bases: CursedIntEnum
The type of interaction received by discord.
Source code in interactions/models/discord/enums.py
712 713 714 715 716 717 718 719 |
|
MFALevel
¶
Bases: CursedIntEnum
Does the user use 2FA.
Source code in interactions/models/discord/enums.py
803 804 805 806 807 |
|
MentionType
¶
Bases: str
, Enum
Types of mention.
Source code in interactions/models/discord/enums.py
757 758 759 760 761 762 |
|
MessageActivityType
¶
Bases: CursedIntEnum
An activity object, similar to an embed.
Source code in interactions/models/discord/enums.py
454 455 456 457 458 459 460 461 462 463 464 |
|
MessageFlags
¶
Bases: DiscordIntFlag
Message flags.
Source code in interactions/models/discord/enums.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
CROSSPOSTED = 1 << 0
class-attribute
¶
This message has been published to subscribed channels (via Channel Following)
EPHEMERAL = 1 << 6
class-attribute
¶
This message is only visible to the user who invoked the Interaction
FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8
class-attribute
¶
This message failed to mention some roles and add their members to the thread
HAS_THREAD = 1 << 5
class-attribute
¶
This message has an associated thread, with the same id as the message
IS_CROSSPOST = 1 << 1
class-attribute
¶
This message originated from a message in another channel (via Channel Following)
LOADING = 1 << 7
class-attribute
¶
This message is an Interaction Response and the bot is "thinking
SHOULD_SHOW_LINK_NOT_DISCORD_WARNING = 1 << 10
class-attribute
¶
This message contains a abusive website link, pops up a warning when clicked
SILENT = 1 << 12
class-attribute
¶
This message should not trigger push or desktop notifications
SOURCE_MESSAGE_DELETED = 1 << 3
class-attribute
¶
The source message for this crosspost has been deleted (via Channel Following)
SUPPRESS_EMBEDS = 1 << 2
class-attribute
¶
Do not include any embeds when serializing this message
SUPPRESS_NOTIFICATIONS = SILENT
class-attribute
¶
Alias for :attr:SILENT
URGENT = 1 << 4
class-attribute
¶
This message came from the urgent message system
VOICE_MESSAGE = 1 << 13
class-attribute
¶
This message is a voice message
MessageType
¶
Bases: CursedIntEnum
Types of message.
Ref: https://discord.com/developers/docs/resources/channel#message-object-message-types
Source code in interactions/models/discord/enums.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
deletable()
classmethod
¶
Return a tuple of message types that can be deleted.
Source code in interactions/models/discord/enums.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
NSFWLevel
¶
Bases: CursedIntEnum
A guilds NSFW Level.
Source code in interactions/models/discord/enums.py
825 826 827 828 829 830 831 |
|
OnboardingMode
¶
Bases: CursedIntEnum
Defines the criteria used to satisfy Onboarding constraints that are required for enabling.
Source code in interactions/models/discord/enums.py
765 766 767 768 769 770 771 |
|
OnboardingPromptType
¶
Bases: CursedIntEnum
Types of Onboarding prompts.
Source code in interactions/models/discord/enums.py
774 775 776 777 778 |
|
OverwriteType
¶
Bases: CursedIntEnum
Types of permission overwrite.
Source code in interactions/models/discord/enums.py
781 782 783 784 785 |
|
Permissions
¶
Bases: DiscordIntFlag
Permissions a user or role may have.
Source code in interactions/models/discord/enums.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
|
ADD_REACTIONS = 1 << 6
class-attribute
¶
Allows for the addition of reactions to messages
ADMINISTRATOR = 1 << 3
class-attribute
¶
Allows all permissions and bypasses channel permission overwrites
ATTACH_FILES = 1 << 15
class-attribute
¶
Allows for uploading images and files
BAN_MEMBERS = 1 << 2
class-attribute
¶
Allows banning members
CHANGE_NICKNAME = 1 << 26
class-attribute
¶
Allows for modification of own nickname
CONNECT = 1 << 20
class-attribute
¶
Allows for joining of a voice channel
CREATE_GUILD_EXPRESSIONS = 1 << 43
class-attribute
¶
Allows for creating emojis, stickers, and soundboard sounds
CREATE_INSTANT_INVITE = 1 << 0
class-attribute
¶
Allows creation of instant invites
CREATE_POSTS = 1 << 11
class-attribute
¶
Allow members to create posts in this channel. Alias to SEND_MESSAGES
DEAFEN_MEMBERS = 1 << 23
class-attribute
¶
Allows for deafening of members in a voice channel
EMBED_LINKS = 1 << 14
class-attribute
¶
Links sent by users with this permission will be auto-embedded
KICK_MEMBERS = 1 << 1
class-attribute
¶
Allows kicking members
MANAGE_CHANNELS = 1 << 4
class-attribute
¶
Allows management and editing of channels
MANAGE_EMOJIS_AND_STICKERS = 1 << 30
class-attribute
¶
Allows management and editing of emojis and stickers
MANAGE_EVENTS = 1 << 33
class-attribute
¶
Allows for creating, editing, and deleting scheduled events
MANAGE_GUILD = 1 << 5
class-attribute
¶
Allows management and editing of the guild
MANAGE_MESSAGES = 1 << 13
class-attribute
¶
Allows for deletion of other users messages
MANAGE_NICKNAMES = 1 << 27
class-attribute
¶
Allows for modification of other users nicknames
MANAGE_ROLES = 1 << 28
class-attribute
¶
Allows management and editing of roles
MANAGE_THREADS = 1 << 34
class-attribute
¶
Allows for deleting and archiving threads, and viewing all private threads
MANAGE_WEBHOOKS = 1 << 29
class-attribute
¶
Allows management and editing of webhooks
MENTION_EVERYONE = 1 << 17
class-attribute
¶
Allows for using the @everyone
tag to notify all users in a channel, and the @here
tag to notify all online users in a channel
MODERATE_MEMBERS = 1 << 40
class-attribute
¶
Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels
MOVE_MEMBERS = 1 << 24
class-attribute
¶
Allows for moving of members between voice channels
MUTE_MEMBERS = 1 << 22
class-attribute
¶
Allows for muting members in a voice channel
PRIORITY_SPEAKER = 1 << 8
class-attribute
¶
Allows for using priority speaker in a voice channel
READ_MESSAGE_HISTORY = 1 << 16
class-attribute
¶
Allows for reading of message history
REQUEST_TO_SPEAK = 1 << 32
class-attribute
¶
Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.)
SEND_MESSAGES = 1 << 11
class-attribute
¶
Allows for sending messages in a channel (does not allow sending messages in threads)
SEND_MESSAGES_IN_THREADS = 1 << 38
class-attribute
¶
Allows for sending messages in threads
SEND_POLLS = 1 << 49
class-attribute
¶
Allows sending polls
SEND_TTS_MESSAGES = 1 << 12
class-attribute
¶
Allows for sending of /tts
messages
SEND_VOICE_MESSAGES = 1 << 46
class-attribute
¶
Allows for sending audio messages
SPEAK = 1 << 21
class-attribute
¶
Allows for speaking in a voice channel
START_EMBEDDED_ACTIVITIES = 1 << 39
class-attribute
¶
Allows for using Activities (applications with the EMBEDDED
flag) in a voice channel
STREAM = 1 << 9
class-attribute
¶
Allows the user to go live
USE_APPLICATION_COMMANDS = 1 << 31
class-attribute
¶
Allows members to use application commands, including slash commands and context menu commands
USE_EXTERNAL_EMOJIS = 1 << 18
class-attribute
¶
Allows the usage of custom emojis from other servers
USE_EXTERNAL_SOUNDS = 1 << 45
class-attribute
¶
Allows the usage of custom sounds from other servers
USE_EXTERNAL_STICKERS = 1 << 37
class-attribute
¶
Allows the usage of custom stickers from other servers
USE_PRIVATE_THREADS = 1 << 36
class-attribute
¶
Allows for creating private threads
USE_PUBLIC_THREADS = 1 << 35
class-attribute
¶
Allows for creating public and announcement threads
USE_SLASH_COMMANDS = USE_APPLICATION_COMMANDS
class-attribute
¶
Legacy alias for :attr:USE_APPLICATION_COMMANDS
USE_SOUNDBOARD = 1 << 42
class-attribute
¶
Allows for using the soundboard in a voice channel
USE_VAD = 1 << 25
class-attribute
¶
Allows for using voice-activity-detection in a voice channel
VIEW_AUDIT_LOG = 1 << 7
class-attribute
¶
Allows for viewing of audit logs
VIEW_CHANNEL = 1 << 10
class-attribute
¶
Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels
VIEW_CREATOR_MONETIZATION_ANALYTICS = 1 << 41
class-attribute
¶
Allows for viewing guild monetization insights
VIEW_GUILD_INSIGHTS = 1 << 19
class-attribute
¶
Allows for viewing guild insights
PollLayoutType
¶
Bases: CursedIntEnum
The layout of a poll.
Source code in interactions/models/discord/enums.py
1161 1162 1163 1164 |
|
PremiumTier
¶
Bases: CursedIntEnum
The boost level of a server.
Source code in interactions/models/discord/enums.py
834 835 836 837 838 839 840 841 842 843 844 |
|
PremiumType
¶
Bases: CursedIntEnum
Types of premium membership.
Source code in interactions/models/discord/enums.py
346 347 348 349 350 351 352 353 354 355 356 |
|
ScheduledEventPrivacyLevel
¶
Bases: CursedIntEnum
The privacy level of the scheduled event.
Source code in interactions/models/discord/enums.py
960 961 962 963 |
|
ScheduledEventStatus
¶
Bases: CursedIntEnum
The status of the scheduled event.
Source code in interactions/models/discord/enums.py
977 978 979 980 981 982 983 |
|
ScheduledEventType
¶
Bases: CursedIntEnum
The type of entity that the scheduled event is attached to.
Source code in interactions/models/discord/enums.py
966 967 968 969 970 971 972 973 974 |
|
Status
¶
Bases: str
, Enum
Represents the statuses a user may have.
Source code in interactions/models/discord/enums.py
932 933 934 935 936 937 938 939 940 941 942 |
|
StickerFormatType
¶
Bases: CursedIntEnum
File formats for stickers.
Source code in interactions/models/discord/enums.py
1112 1113 1114 1115 1116 1117 1118 |
|
StickerTypes
¶
Bases: CursedIntEnum
Types of sticker.
Source code in interactions/models/discord/enums.py
1103 1104 1105 1106 1107 1108 1109 |
|
SystemChannelFlags
¶
Bases: DiscordIntFlag
System channel settings.
Source code in interactions/models/discord/enums.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
|
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2
class-attribute
¶
Suppress server setup tips
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0
class-attribute
¶
Suppress member join notifications
SUPPRESS_JOIN_NOTIFICATION_REPLIES = 1 << 3
class-attribute
¶
Hide member join sticker reply buttons
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1
class-attribute
¶
Suppress server boost notifications
TeamMembershipState
¶
Bases: CursedIntEnum
Status of membership in the team.
Source code in interactions/models/discord/enums.py
339 340 341 342 343 |
|
UserFlags
¶
Bases: DiscordIntFlag
Flags a user can have.
Source code in interactions/models/discord/enums.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
ACTIVE_DEVELOPER = 1 << 22
class-attribute
¶
This user is an active developer
BOT_HTTP_INTERACTIONS = 1 << 19
class-attribute
¶
Bot uses only HTTP interactions and is shown in the online member list
BUG_HUNTER_LEVEL_1 = 1 << 3
class-attribute
¶
User has passed the bug hunters quiz
BUG_HUNTER_LEVEL_2 = 1 << 14
class-attribute
¶
User is a bug hunter level 2
DISABLE_PREMIUM = 1 << 21
class-attribute
¶
Nitro features disabled for this user. Only used by Discord Staff for testing
DISCORD_CERTIFIED_MODERATOR = 1 << 18
class-attribute
¶
This user is a certified moderator
DISCORD_EMPLOYEE = 1 << 0
class-attribute
¶
This person works for Discord
EARLY_SUPPORTER = 1 << 9
class-attribute
¶
This person had Nitro prior to Wednesday, October 10th, 2018
EARLY_VERIFIED_BOT_DEVELOPER = 1 << 17
class-attribute
¶
This user was one of the first to be verified
HOUSE_BALANCE = 1 << 8
class-attribute
¶
User belongs to the balance
house
HOUSE_BRAVERY = 1 << 6
class-attribute
¶
User belongs to the bravery
house
HOUSE_BRILLIANCE = 1 << 7
class-attribute
¶
User belongs to the brilliance
house
HYPESQUAD_EVENTS = 1 << 2
class-attribute
¶
User has helped with a hypesquad event
PARTNERED_SERVER_OWNER = 1 << 1
class-attribute
¶
User owns a partnered server
SPAMMER = 1 << 20
class-attribute
¶
A user who is suspected of spamming
TEAM_USER = 1 << 10
class-attribute
¶
A team user
VERIFIED_BOT = 1 << 16
class-attribute
¶
This bot has been verified by Discord
VerificationLevel
¶
Bases: CursedIntEnum
Levels of verification needed by a guild.
Source code in interactions/models/discord/enums.py
810 811 812 813 814 815 816 817 818 819 820 821 822 |
|
HIGH = 3
class-attribute
¶
Must also be a member of this server for longer than 10 minutes
LOW = 1
class-attribute
¶
Must have a verified email on their Discord Account
MEDIUM = 2
class-attribute
¶
Must also be registered on Discord for longer than 5 minutes
NONE = 0
class-attribute
¶
No verification needed
VERY_HIGH = 4
class-attribute
¶
Must have a verified phone number on their Discord Account
VideoQualityMode
¶
Bases: CursedIntEnum
Video quality settings.
Source code in interactions/models/discord/enums.py
878 879 880 881 882 |
|
WebSocketOPCode
¶
Bases: CursedIntEnum
Codes used by the Gateway to signify events.
Source code in interactions/models/discord/enums.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
DISPATCH = 0
class-attribute
¶
An event was dispatched
HEARTBEAT = 1
class-attribute
¶
Fired periodically by the client to keep the connection alive
HEARTBEAT_ACK = 11
class-attribute
¶
Sent in response to receiving a heartbeat to acknowledge that it has been received.
HELLO = 10
class-attribute
¶
Sent immediately after connecting, contains the heartbeat_interval
to use.
IDENTIFY = 2
class-attribute
¶
Starts a new session during the initial handshake.
INVALIDATE_SESSION = 9
class-attribute
¶
The session has been invalidated. You should reconnect and identify/resume accordingly.
PRESENCE = 3
class-attribute
¶
Update the client's presence.
RECONNECT = 7
class-attribute
¶
You should attempt to reconnect and resume immediately.
REQUEST_MEMBERS = 8
class-attribute
¶
Request information about offline guild members in a large guild.
RESUME = 6
class-attribute
¶
Resume a previous session that was disconnected.
VOICE_STATE = 4
class-attribute
¶
Used to join/leave or move between voice channels.
Timestamp
¶
Bases: datetime
A special class that represents Discord timestamps.
Assumes that all naive datetimes are based on local timezone.
Source code in interactions/models/discord/timestamp.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
format(style=None)
¶
Format the timestamp for discord client to display.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style | Optional[Union[TimestampStyles, str]] | The style to format the timestamp with. | None |
Returns:
Type | Description |
---|---|
str | The formatted timestamp. |
Source code in interactions/models/discord/timestamp.py
151 152 153 154 155 156 157 158 159 160 161 162 |
|
from_snowflake(snowflake)
classmethod
¶
Construct a timezone-aware UTC datetime from a snowflake.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snowflake | Snowflake_Type | The snowflake to convert. | required |
Returns:
Type | Description |
---|---|
Timestamp | A timezone-aware UTC datetime. |
Info
https://discord.com/developers/docs/reference#convert-snowflake-to-datetime
Source code in interactions/models/discord/timestamp.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
fromdatetime(dt)
classmethod
¶
Construct a timezone-aware UTC datetime from a datetime object.
Source code in interactions/models/discord/timestamp.py
36 37 38 39 40 41 |
|
now(tz=None)
classmethod
¶
Construct a datetime from time.time() and optional time zone info.
If no timezone is provided, the time is assumed to be from the computer's local timezone.
Source code in interactions/models/discord/timestamp.py
75 76 77 78 79 80 81 82 83 84 |
|
to_snowflake(high=False)
¶
Returns a numeric snowflake pretending to be created at the given date.
When using as the lower end of a range, use tosnowflake(high=False) - 1
to be inclusive, high=True
to be exclusive. When using as the higher end of a range, use tosnowflake(high=True) + 1
to be inclusive, high=False
to be exclusive
Source code in interactions/models/discord/timestamp.py
117 118 119 120 121 122 123 124 125 126 127 128 |
|
utcfromtimestamp(t)
classmethod
¶
Construct a timezone-aware UTC datetime from a POSIX timestamp.
Source code in interactions/models/discord/timestamp.py
43 44 45 46 |
|
utcnow()
classmethod
¶
Construct a timezone-aware UTC datetime from time.time().
Source code in interactions/models/discord/timestamp.py
86 87 88 89 90 |
|
Internal Models¶
Extension
¶
A class that allows you to separate your commands and listeners into separate files. Extensions require an entrypoint in the same file called setup
, this function allows client to load the Extension.
Example Usage:
1 2 3 4 5 6 7 |
|
Attributes:
Name | Type | Description |
---|---|---|
bot | Client | A reference to the client |
name | str | The name of this Extension ( |
description | str | A description of this Extension |
extension_checks | str | A list of checks to be ran on any command in this extension |
extension_prerun | List | A list of coroutines to be run before any command in this extension |
extension_postrun | List | A list of coroutines to be run after any command in this extension |
interaction_tree | Dict | A dictionary of registered application commands in a tree |
Source code in interactions/models/internal/extension.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
commands: List[BaseCommand]
property
¶
Get the commands from this Extension.
listeners: List[Listener]
property
¶
Get the listeners from this Extension.
Metadata
¶
Info about the Extension
Source code in interactions/models/internal/extension.py
63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
description: str
class-attribute
¶
A description of this Extension
name: str
class-attribute
¶
The name of this Extension
requirements: List[str]
class-attribute
¶
A list of requirements for this Extension
url: str
class-attribute
¶
The repository url of this Extension
version: str
class-attribute
¶
The version of this Extension
add_ext_auto_defer(enabled=True, ephemeral=False, time_until_defer=0.0)
¶
Add a auto defer for all commands in this extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled | bool | Should the command be deferred automatically | True |
ephemeral | bool | Should the command be deferred as ephemeral | False |
time_until_defer | float | How long to wait before deferring automatically | 0.0 |
Source code in interactions/models/internal/extension.py
183 184 185 186 187 188 189 190 191 192 193 |
|
add_ext_check(coroutine)
¶
Add a coroutine as a check for all commands in this extension to run. This coroutine must take only the parameter context
.
Example Usage:
1 2 3 4 5 6 7 8 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coroutine | Callable[[BaseContext], Awaitable[bool]] | The coroutine to use as a check | required |
Source code in interactions/models/internal/extension.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
add_extension_postrun(coroutine)
¶
Add a coroutine to be run after all commands in this Extension.
Example Usage:
1 2 3 4 5 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coroutine | Callable[..., Coroutine] | The coroutine to run | required |
Source code in interactions/models/internal/extension.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
add_extension_prerun(coroutine)
¶
Add a coroutine to be run before all commands in this Extension.
Note
Pre-runs will only be run if the commands checks pass
Example Usage:
1 2 3 4 5 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coroutine | Callable[..., Coroutine] | The coroutine to run | required |
Source code in interactions/models/internal/extension.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
drop()
¶
Called when this Extension is being removed.
Source code in interactions/models/internal/extension.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
set_extension_error(coroutine)
¶
Add a coroutine to handle any exceptions raised in this extension.
Example Usage:
```python def init(self, bot): self.set_extension_error(self.example)
Args: coroutine: The coroutine to run
Source code in interactions/models/internal/extension.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
Buckets
¶
Bases: IntEnum
Outlines the cooldown buckets that may be used. Should a bucket for guilds exist, and the command is invoked in a DM, a sane default will be used.
Note
To add your own, override this
Source code in interactions/models/internal/cooldowns.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
CATEGORY = 5
class-attribute
¶
Per category cooldowns
CHANNEL = 3
class-attribute
¶
Per channel cooldowns
DEFAULT = 0
class-attribute
¶
Default is the same as user
GUILD = 2
class-attribute
¶
Per guild cooldowns
MEMBER = 4
class-attribute
¶
Per guild member cooldowns
ROLE = 6
class-attribute
¶
Per role cooldowns
USER = 1
class-attribute
¶
Per user cooldowns
Cooldown
¶
Manages cooldowns and their respective buckets for a command.
There are two pre-defined cooldown systems, a sliding window and a standard cooldown system (default); you can specify which one to use by passing in the cooldown_system parameter.
Attributes:
Name | Type | Description |
---|---|---|
bucket | Buckets | The bucket to use for this cooldown |
cooldown_repositories | A dictionary of cooldowns for each bucket | |
rate | int | How many commands may be ran per interval |
interval | float | How many seconds to wait for a cooldown |
cooldown_system | Type[CooldownSystem] | The cooldown system to use for this cooldown |
Source code in interactions/models/internal/cooldowns.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
acquire_token(context)
async
¶
Attempt to acquire a token for a command to run. Uses the context of the command to use the correct CooldownStrategy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Returns:
Type | Description |
---|---|
bool | True if a token was acquired, False if not |
Source code in interactions/models/internal/cooldowns.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
get_cooldown_time(context)
async
¶
Get the remaining cooldown time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Returns:
Type | Description |
---|---|
float | remaining cooldown time, will return 0 if the cooldown has not been reached |
Source code in interactions/models/internal/cooldowns.py
385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
get_cooldown_time_with_key(key, *, create=False)
¶
Get the remaining cooldown time with a key instead of the context.
Note
The preferred way to get the cooldown system is to use get_cooldown
as it will use the context to get the correct key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | Any | The key to get the cooldown system for | required |
create | bool | Whether to create a new cooldown system if one does not exist | False |
Source code in interactions/models/internal/cooldowns.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
get_cooldown_with_key(key, *, create=False)
¶
Get the cooldown system for the command.
Note
The preferred way to get the cooldown system is to use get_cooldown
as it will use the context to get the correct key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | Any | The key to get the cooldown system for | required |
create | bool | Whether to create a new cooldown system if one does not exist | False |
Source code in interactions/models/internal/cooldowns.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
on_cooldown(context)
async
¶
Returns the cooldown state of the command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Returns:
Type | Description |
---|---|
bool | boolean state if the command is on cooldown or not |
Source code in interactions/models/internal/cooldowns.py
416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
reset(context)
async
¶
Resets the cooldown for the bucket of which invoked this command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Source code in interactions/models/internal/cooldowns.py
441 442 443 444 445 446 447 448 449 450 |
|
reset_all()
async
¶
Resets this cooldown system to its initial state.
!!! warning To be clear, this will reset all cooldowns for this command to their initial states
Source code in interactions/models/internal/cooldowns.py
430 431 432 433 434 435 436 437 438 439 |
|
reset_with_key(key)
¶
Resets the cooldown for the bucket associated with the provided key.
Note
The preferred way to reset the cooldown system is to use reset_cooldown
as it will use the context to reset the correct cooldown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | Any | The key to reset the cooldown system for | required |
Returns:
Type | Description |
---|---|
bool | True if the key existed and was reset successfully, False if the key didn't exist. |
Source code in interactions/models/internal/cooldowns.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
CooldownSystem
¶
A basic cooldown strategy that allows a specific number of commands to be executed within a given interval. Once the rate is reached, no more tokens can be acquired until the interval has passed.
Attributes:
Name | Type | Description |
---|---|---|
rate | int | The number of commands allowed per interval. |
interval | float | The time window (in seconds) within which the allowed number of commands can be executed. |
Example Use-case
This strategy is useful for scenarios where you want to limit the number of times a command can be executed within a fixed time frame, such as preventing command spamming or limiting API calls.
Source code in interactions/models/internal/cooldowns.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
acquire_token()
¶
Attempt to acquire a token for a command to run.
Returns:
Type | Description |
---|---|
bool | True if a token was acquired, False if not |
Source code in interactions/models/internal/cooldowns.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
determine_cooldown()
¶
Determines the state of the cooldown system.
Source code in interactions/models/internal/cooldowns.py
139 140 141 142 143 144 145 |
|
get_cooldown_time()
¶
Returns how long until the cooldown will reset.
Returns:
Type | Description |
---|---|
float | remaining cooldown time, will return 0 if the cooldown has not been reached |
Source code in interactions/models/internal/cooldowns.py
128 129 130 131 132 133 134 135 136 137 |
|
on_cooldown()
¶
Returns the cooldown state of the command.
Returns:
Type | Description |
---|---|
bool | boolean state if the command is on cooldown or not |
Source code in interactions/models/internal/cooldowns.py
98 99 100 101 102 103 104 105 106 107 108 |
|
reset()
¶
Resets the tokens for this cooldown.
Source code in interactions/models/internal/cooldowns.py
93 94 95 96 |
|
ExponentialBackoffSystem
¶
Bases: CooldownSystem
An exponential backoff cooldown strategy that doubles the interval between allowed commands after each failed attempt, up to a maximum interval.
Attributes:
Name | Type | Description |
---|---|---|
rate | The number of commands allowed per interval. | |
interval | The initial time window (in seconds) within which the allowed number of commands can be executed. | |
max_interval | The maximum time window (in seconds) between allowed commands. | |
multiplier | The multiplier to apply to the interval after each failed attempt. |
Example Use-case
This strategy is useful for scenarios where you want to progressively slow down repeated attempts at a command, such as preventing brute force attacks or limiting retries on failed operations.
Source code in interactions/models/internal/cooldowns.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
LeakyBucketSystem
¶
Bases: CooldownSystem
A leaky bucket cooldown strategy that gradually replenishes tokens over time, allowing commands to be executed as long as there are available tokens in the bucket.
Attributes:
Name | Type | Description |
---|---|---|
rate | The number of tokens generated per interval. | |
interval | The time window (in seconds) within which the tokens are generated. |
Example Use-case
This strategy is useful for scenarios where you want to allow a steady flow of commands to be executed while preventing sudden bursts, such as rate limiting API calls or managing user interactions in a chatbot.
Source code in interactions/models/internal/cooldowns.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
MaxConcurrency
¶
Limits how many instances of a command may be running concurrently.
Attributes:
Name | Type | Description |
---|---|---|
bucket | Buckets | The bucket this concurrency applies to |
concurrent | int | The maximum number of concurrent instances permitted to |
wait | bool | Should we wait until a instance is available |
Source code in interactions/models/internal/cooldowns.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
acquire(context)
async
¶
Acquire an instance of the semaphore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Returns:
Type | Description |
---|---|
bool | If the semaphore was successfully acquired |
Source code in interactions/models/internal/cooldowns.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
|
get_semaphore(context)
async
¶
Get the semaphore associated with the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The commands context | required |
Returns:
Type | Description |
---|---|
asyncio.Semaphore | A semaphore object |
Source code in interactions/models/internal/cooldowns.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
release(context)
async
¶
Release the semaphore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context | BaseContext | The context of the command | required |
Source code in interactions/models/internal/cooldowns.py
525 526 527 528 529 530 531 532 533 534 535 |
|
SlidingWindowSystem
¶
Bases: CooldownSystem
A sliding window cooldown strategy that allows a specific number of commands to be executed within a rolling time window.
The cooldown incrementally resets as commands fall outside of the window.
Attributes:
Name | Type | Description |
---|---|---|
rate | int | The number of commands allowed per interval. |
interval | float | The time window (in seconds) within which the allowed number of commands can be executed. |
Example Use-case
This strategy is useful for scenarios where you want to limit the rate of commands executed over a continuous time window, such as ensuring consistent usage of resources or controlling chat bot response frequency.
Source code in interactions/models/internal/cooldowns.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
acquire_token()
¶
Attempt to acquire a token for a command to run.
Returns:
Type | Description |
---|---|
bool | True if a token was acquired, False if not |
Source code in interactions/models/internal/cooldowns.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
get_cooldown_time()
¶
Returns how long until the cooldown will reset.
Returns:
Type | Description |
---|---|
float | remaining cooldown time, will return 0 if the cooldown has not been reached |
Source code in interactions/models/internal/cooldowns.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
on_cooldown()
¶
Returns the cooldown state of the command.
Returns:
Type | Description |
---|---|
bool | boolean state if the command is on cooldown or not |
Source code in interactions/models/internal/cooldowns.py
176 177 178 179 180 181 182 183 184 185 186 |
|
reset()
¶
Resets the timestamps for this cooldown.
Source code in interactions/models/internal/cooldowns.py
220 221 222 |
|
TokenBucketSystem
¶
Bases: CooldownSystem
A token bucket cooldown strategy that generates tokens at a specific rate up to a burst rate, allowing commands to be executed as long as there are available tokens in the bucket.
Attributes:
Name | Type | Description |
---|---|---|
rate | The number of tokens generated per interval. | |
interval | The time window (in seconds) within which the tokens are generated. | |
burst_rate | The maximum number of tokens that can be held in the bucket at any given time. |
Example Use-case
This strategy is useful for scenarios where you want to allow a burst of commands to be executed while limiting the overall rate, such as handling peak traffic in an API or permitting rapid user interactions in a game.
Source code in interactions/models/internal/cooldowns.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
dm_only()
¶
This command may only be ran in a dm.
Source code in interactions/models/internal/checks.py
86 87 88 89 90 91 92 |
|
guild_only()
¶
This command may only be ran in a guild.
Source code in interactions/models/internal/checks.py
77 78 79 80 81 82 83 |
|
has_any_role(*roles)
¶
Checks if the user has any of the given roles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*roles | Snowflake_Type | Role | The Role(s) or role id(s) to check for | () |
Source code in interactions/models/internal/checks.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
has_id(user_id)
¶
Checks if the author has the desired ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user_id | int | id of the user to check for | required |
Source code in interactions/models/internal/checks.py
50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
has_role(role)
¶
Check if the user has the given role.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role | Snowflake_Type | Role | The Role or role id to check for | required |
Source code in interactions/models/internal/checks.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
is_owner()
¶
Checks if the author is the owner of the bot. This respects the client.owner_ids
list.
Source code in interactions/models/internal/checks.py
65 66 67 68 69 70 71 72 73 74 |
|
AutoDefer
¶
Automatically defer application commands for you!
Source code in interactions/models/internal/auto_defer.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
enabled: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Whether or not auto-defer is enabled
ephemeral: bool = attrs.field(repr=False, default=False)
class-attribute
¶
Should the command be deferred as ephemeral or not
time_until_defer: float = attrs.field(repr=False, default=1.5)
class-attribute
¶
How long to wait before automatically deferring
defer(ctx)
async
¶
Defer the command
Source code in interactions/models/internal/auto_defer.py
36 37 38 39 40 |
|
slash_attachment_option(description, required=False, name=None)
¶
Annotates an argument as an attachment type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
slash_bool_option(description, required=False, name=None)
¶
Annotates an argument as a boolean type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
slash_channel_option(description, required=False, autocomplete=False, choices=None, channel_types=None, name=None)
¶
Annotates an argument as a channel type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
channel_types | Optional[list[Union[ChannelType, int]]] | The types of channel allowed by this option | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
slash_float_option(description, required=False, autocomplete=False, choices=None, min_value=None, max_value=None, name=None)
¶
Annotates an argument as a float type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
min_value | Optional[float] | The minimum number allowed | None |
max_value | Optional[float] | The maximum number allowed | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
slash_int_option(description, required=False, autocomplete=False, choices=None, min_value=None, max_value=None, name=None)
¶
Annotates an argument as a integer type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
min_value | Optional[float] | The minimum number allowed | None |
max_value | Optional[float] | The maximum number allowed | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
slash_mentionable_option(description, required=False, autocomplete=False, choices=None, name=None)
¶
Annotates an argument as a mentionable type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
slash_role_option(description, required=False, autocomplete=False, choices=None, name=None)
¶
Annotates an argument as a role type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
slash_str_option(description, required=False, autocomplete=False, choices=None, min_length=None, max_length=None, name=None)
¶
Annotates an argument as a string type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
choices | List[Union[SlashCommandChoice, dict]] | None | The choices allowed by this command | None |
min_length | Optional[int] | The minimum length of text a user can input. | None |
max_length | Optional[int] | The maximum length of text a user can input. | None |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
slash_user_option(description, required=False, autocomplete=False, name=None)
¶
Annotates an argument as a user type slash command option.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
description | str | The description of your option | required |
required | bool | Is this option required? | False |
autocomplete | bool | Use autocomplete for this option | False |
name | Optional[str] | The name of the option. Defaults to the name of the argument | None |
Source code in interactions/models/internal/annotations/slash.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
ConsumeRest = Annotated[T, CONSUME_REST_MARKER]
module-attribute
¶
A special marker type alias to mark an argument in a prefixed command to consume the rest of the arguments.
MODEL_TO_CONVERTER: dict[type, type[Converter]] = {SnowflakeObject: SnowflakeConverter, BaseChannel: BaseChannelConverter, DMChannel: DMChannelConverter, DM: DMConverter, DMGroup: DMGroupConverter, GuildChannel: GuildChannelConverter, GuildNews: GuildNewsConverter, GuildCategory: GuildCategoryConverter, GuildText: GuildTextConverter, ThreadChannel: ThreadChannelConverter, GuildNewsThread: GuildNewsThreadConverter, GuildPublicThread: GuildPublicThreadConverter, GuildPrivateThread: GuildPrivateThreadConverter, VoiceChannel: VoiceChannelConverter, GuildVoice: GuildVoiceConverter, GuildStageVoice: GuildStageVoiceConverter, TYPE_ALL_CHANNEL: BaseChannelConverter, TYPE_DM_CHANNEL: DMChannelConverter, TYPE_GUILD_CHANNEL: GuildChannelConverter, TYPE_THREAD_CHANNEL: ThreadChannelConverter, TYPE_VOICE_CHANNEL: VoiceChannelConverter, TYPE_MESSAGEABLE_CHANNEL: MessageableChannelConverter, User: UserConverter, Member: MemberConverter, Message: MessageConverter, Guild: GuildConverter, Role: RoleConverter, PartialEmoji: PartialEmojiConverter, CustomEmoji: CustomEmojiConverter}
module-attribute
¶
A dictionary mapping of interactions objects to their corresponding converters.
ChannelConverter
¶
Bases: IDConverter[T_co]
The base converter for channel objects.
Source code in interactions/models/internal/converters.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
convert(ctx, argument)
async
¶
Converts a given string to a Channel object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By channel mention.
-
By name - the bot will search in a guild if the context has it, otherwise it will search globally.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
BaseChannel | T_co | The converted object. |
T_co | The channel type will be of the type the converter represents. |
Source code in interactions/models/internal/converters.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
CustomEmojiConverter
¶
Bases: IDConverter[CustomEmoji]
Converts a string argument to a CustomEmoji object.
Source code in interactions/models/internal/converters.py
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
convert(ctx, argument)
async
¶
Converts a given string to a CustomEmoji object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By the emoji string format.
-
By name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
CustomEmoji | CustomEmoji | The converted object. |
Source code in interactions/models/internal/converters.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
Greedy
¶
Bases: List[T]
A special marker class to mark an argument in a prefixed command to repeatedly convert until it fails to convert an argument.
Source code in interactions/models/internal/converters.py
581 582 |
|
GuildConverter
¶
Bases: IDConverter[Guild]
Converts a string argument to a Guild object.
Source code in interactions/models/internal/converters.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
convert(ctx, argument)
async
¶
Converts a given string to a Guild object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
Guild | Guild | The converted object. |
Source code in interactions/models/internal/converters.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
IDConverter
¶
Bases: Converter[T_co]
The base converter for objects that have snowflake IDs.
Source code in interactions/models/internal/converters.py
104 105 106 107 108 109 |
|
MemberConverter
¶
Bases: IDConverter[Member]
Converts a string argument to a Member object.
Source code in interactions/models/internal/converters.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
convert(ctx, argument)
async
¶
Converts a given string to a Member object. This will only work in guilds.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By username + tag (ex User#1234).
-
By nickname.
-
By username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
Member | Member | The converted object. |
Source code in interactions/models/internal/converters.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
MessageConverter
¶
Converts a string argument to a Message object.
Source code in interactions/models/internal/converters.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
convert(ctx, argument)
async
¶
Converts a given string to a Message object.
The lookup strategy is as follows:
-
By raw snowflake ID. The message must be in the same channel as the context.
-
By message + channel ID in the format of "{Channel ID}-{Message ID}". This can be obtained by shift clicking "Copy ID" when Developer Mode is enabled.
-
By message link.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
Message | Message | The converted object. |
Source code in interactions/models/internal/converters.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
|
NoArgumentConverter
¶
Bases: Converter[T_co]
An indicator class for special type of converters that only uses the Context.
This is mainly needed for prefixed commands, as arguments will be "eaten up" by converters otherwise.
Source code in interactions/models/internal/converters.py
74 75 76 77 78 79 |
|
PartialEmojiConverter
¶
Bases: IDConverter[PartialEmoji]
Converts a string argument to a PartialEmoji object.
Source code in interactions/models/internal/converters.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
convert(ctx, argument)
async
¶
Converts a given string to a PartialEmoji object.
This converter only accepts emoji strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
PartialEmoji | PartialEmoji | The converted object. |
Source code in interactions/models/internal/converters.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
RoleConverter
¶
Bases: IDConverter[Role]
Converts a string argument to a Role object.
Source code in interactions/models/internal/converters.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
convert(ctx, argument)
async
¶
Converts a given string to a Role object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
Role | Role | The converted object. |
Source code in interactions/models/internal/converters.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
SnowflakeConverter
¶
Bases: IDConverter[SnowflakeObject]
Converts a string argument to a SnowflakeObject.
Source code in interactions/models/internal/converters.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
convert(ctx, argument)
async
¶
Converts a given string to a SnowflakeObject.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By role or channel mention.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
SnowflakeObject | SnowflakeObject | The converted object. |
Source code in interactions/models/internal/converters.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
UserConverter
¶
Bases: IDConverter[User]
Converts a string argument to a User object.
Source code in interactions/models/internal/converters.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
convert(ctx, argument)
async
¶
Converts a given string to a User object.
The lookup strategy is as follows:
-
By raw snowflake ID.
-
By mention.
-
By username + tag (ex User#1234).
-
By username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx | BaseContext | The context to use for the conversion. | required |
argument | str | The argument to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
User | User | The converted object. |
Source code in interactions/models/internal/converters.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
Listener
¶
Bases: CallbackObject
Source code in interactions/models/internal/listener.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
create(event_name=MISSING, *, delay_until_ready=False, is_default_listener=False, disable_default_listeners=False)
classmethod
¶
Decorator for creating an event listener.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name | Absent[str | BaseEvent] | The name of the event to listen to. If left blank, event name will be inferred from the function name or parameter. | MISSING |
delay_until_ready | bool | Whether to delay the listener until the client is ready. | False |
is_default_listener | bool | Whether this listener is provided automatically by the library, and might be unwanted by users. | False |
disable_default_listeners | bool | Whether this listener supersedes default listeners. If true, any default listeners will be unregistered. | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], Listener] | A listener object. |
Source code in interactions/models/internal/listener.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
lazy_parse_params()
¶
Process the parameters of this listener.
Source code in interactions/models/internal/listener.py
106 107 108 109 110 111 112 113 114 115 |
|
listen(event_name=MISSING, *, delay_until_ready=False, is_default_listener=False, disable_default_listeners=False)
¶
Decorator to make a function an event listener.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name | Absent[str | type[BaseEvent]] | The name of the event to listen to. If left blank, event name will be inferred from the function name or parameter. | MISSING |
delay_until_ready | bool | Whether to delay the listener until the client is ready. | False |
is_default_listener | bool | Whether this listener is provided automatically by the library, and might be unwanted by users. | False |
disable_default_listeners | bool | Whether this listener supersedes default listeners. If true, any default listeners will be unregistered. | False |
Returns:
Type | Description |
---|---|
Callable[[AsyncCallable], Listener] | A listener object. |
Source code in interactions/models/internal/listener.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
LocalisedField
¶
An object that enables support for localising fields.
Supported locales: https://discord.com/developers/docs/reference#locales
Source code in interactions/models/internal/localisation.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
default: str
property
¶
The default value based on the CONST default_locale
get_locale(locale)
¶
Get the value for the specified locale. Supports locale-codes and locale names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
locale | str | The locale to fetch | required |
Returns:
Type | Description |
---|---|
str | The localised string, or the default value |
Source code in interactions/models/internal/localisation.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
BaseTrigger
¶
Bases: ABC
Source code in interactions/models/internal/tasks/triggers.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
next_fire()
abstractmethod
¶
Return the next datetime to fire on.
Returns:
Type | Description |
---|---|
datetime | None | Datetime if one can be determined. If no datetime can be determined, return None |
Source code in interactions/models/internal/tasks/triggers.py
31 32 33 34 35 36 37 38 39 40 |
|
reschedule()
¶
Update the last call time to now
Source code in interactions/models/internal/tasks/triggers.py
24 25 26 |
|
CronTrigger
¶
Bases: BaseTrigger
Trigger the task based on a cron schedule.
Attributes:
Name | Type | Description |
---|---|---|
cron | str | The cron schedule, use https://crontab.guru for help |
tz | datetime | Whether or not to use UTC for the time (uses timezone information) |
Source code in interactions/models/internal/tasks/triggers.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
DateTrigger
¶
Bases: BaseTrigger
Trigger the task once, when the specified datetime is reached.
Attributes:
Name | Type | Description |
---|---|---|
target_datetime | datetime | A datetime representing the date/time to run this task |
Source code in interactions/models/internal/tasks/triggers.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
IntervalTrigger
¶
Bases: BaseTrigger
Trigger the task every set interval.
Attributes:
Name | Type | Description |
---|---|---|
seconds | Union[int, float] | How many seconds between intervals |
minutes | Union[int, float] | How many minutes between intervals |
hours | Union[int, float] | How many hours between intervals |
days | Union[int, float] | How many days between intervals |
weeks | Union[int, float] | How many weeks between intervals |
Source code in interactions/models/internal/tasks/triggers.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
OrTrigger
¶
Bases: BaseTrigger
Trigger a task when any sub-trigger is fulfilled.
Source code in interactions/models/internal/tasks/triggers.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
Task
¶
Create an asynchronous background tasks. Tasks allow you to run code according to a trigger object.
A task's trigger must inherit from BaseTrigger
.
Attributes:
Name | Type | Description |
---|---|---|
callback | Callable | The function to be called when the trigger is triggered. |
trigger | BaseTrigger | The trigger object that determines when the task should run. |
task | Optional[_Task] | The task object that is running the trigger loop. |
iteration | int | The number of times the task has run. |
Source code in interactions/models/internal/tasks/task.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
delta_until_run: timedelta | None
property
¶
Get the time until the next run of this task.
done: bool
property
¶
Whether the task is done/finished
next_run: datetime | None
property
¶
Get the next datetime this task will run.
running: bool
property
¶
Whether the task is running
started: bool
property
¶
Whether the task is started
create(trigger)
classmethod
¶
A decorator to create a task.
Example
1 2 3 4 5 6 7 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trigger | BaseTrigger | The trigger to use for this task | required |
Source code in interactions/models/internal/tasks/task.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
on_error(error)
¶
Error handler for this task. Called when an exception is raised during execution of the task.
Source code in interactions/models/internal/tasks/task.py
73 74 75 76 |
|
on_error_sentry_hook(error)
¶
A dummy method for interactions.ext.sentry to hook
Source code in interactions/models/internal/tasks/task.py
70 71 |
|
reschedule(trigger)
¶
Change the trigger being used by this task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trigger | BaseTrigger | The new Trigger to use | required |
Source code in interactions/models/internal/tasks/task.py
134 135 136 137 138 139 140 141 142 143 |
|
restart(*args, **kwargs)
¶
Restart this task.
Source code in interactions/models/internal/tasks/task.py
129 130 131 132 |
|
start(*args, **kwargs)
¶
Start this task.
Source code in interactions/models/internal/tasks/task.py
112 113 114 115 116 117 118 119 120 121 |
|
stop()
¶
End this task.
Source code in interactions/models/internal/tasks/task.py
123 124 125 126 127 |
|
TimeTrigger
¶
Bases: BaseTrigger
Trigger the task every day, at a specified (24 hour clock) time.
Attributes:
Name | Type | Description |
---|---|---|
hour | int | The hour of the day (24 hour clock) |
minute | int | The minute of the hour |
seconds | int | The seconds of the minute |
utc | bool | If this time is in UTC |
Source code in interactions/models/internal/tasks/triggers.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
Wait
¶
Class for waiting for a future event to happen. Internally used by wait_for.
Source code in interactions/models/internal/wait.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
AsyncIterator
¶
Bases: _AsyncIterator
, ABC
Source code in interactions/models/misc/iterator.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
get_limit: int
property
¶
Get how the maximum number of items that should be retrieved.
last: Absent[Any] = MISSING
instance-attribute
¶
The last item retrieved
total_retrieved: int
property
¶
Get the total number of objects this iterator has retrieved.
add_object(obj)
async
¶
Add an object to iterator's queue.
Source code in interactions/models/misc/iterator.py
42 43 44 |
|
fetch()
abstractmethod
async
¶
Fetch additional objects.
Your implementation of this method must return a list of objects. If no more objects are available, raise QueueEmpty
Returns:
Type | Description |
---|---|
list | List of objects |
Raises:
Type | Description |
---|---|
QueueEmpty | when no more objects are available. |
Source code in interactions/models/misc/iterator.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
flatten()
async
¶
Flatten this iterator into a list of objects.
Source code in interactions/models/misc/iterator.py
83 84 85 |
|
search(target_id)
async
¶
Search the iterator for an object with the given ID.
Source code in interactions/models/misc/iterator.py
87 88 89 90 91 92 93 94 95 96 97 |
|
API¶
ConnectionState
¶
Source code in interactions/api/gateway/state.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
average_latency: float
property
¶
Returns the average latency of the websocket connection (seconds).
client: Client
class-attribute
¶
The bot's client
gateway: Absent[GatewayClient] = MISSING
class-attribute
¶
The websocket connection for the Discord Gateway.
gateway_started: asyncio.Event = asyncio.Event()
class-attribute
¶
Event to check if the gateway has been started.
gateway_url: str = MISSING
class-attribute
¶
The URL that the gateway should connect to.
intents: Intents
class-attribute
¶
The event intents in use
latency: float
property
¶
Returns the latency of the websocket connection (seconds).
presence: dict
property
¶
Returns the presence of the bot.
shard_id: int
class-attribute
¶
The shard ID of this state
start_time: Absent[datetime] = MISSING
class-attribute
¶
The DateTime the bot started at
change_presence(status=Status.ONLINE, activity=MISSING)
async
¶
Change the bots presence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status | Optional[Union[str, Status]] | The status for the bot to be. i.e. online, afk, etc. | Status.ONLINE |
activity | Absent[Union[Activity, str]] | The activity for the bot to be displayed as doing. | MISSING |
Note
Bots may only be playing
streaming
listening
watching
or competing
, other activity types are likely to fail.
Source code in interactions/api/gateway/state.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
clear_ready()
¶
Clear the ready event.
Source code in interactions/api/gateway/state.py
99 100 101 102 |
|
get_voice_state(guild_id)
¶
Get the bot's voice state for a guild.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | The target guild's id. | required |
Returns:
Type | Description |
---|---|
Optional[ActiveVoiceState] | The bot's voice state for the guild if connected, otherwise None. |
Source code in interactions/api/gateway/state.py
203 204 205 206 207 208 209 210 211 212 213 214 |
|
start()
async
¶
Connect to the Discord Gateway.
Source code in interactions/api/gateway/state.py
72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
stop()
async
¶
Disconnect from the Discord Gateway.
Source code in interactions/api/gateway/state.py
86 87 88 89 90 91 92 93 94 95 96 97 |
|
voice_connect(guild_id, channel_id, muted=False, deafened=False)
async
¶
Connect to a voice channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guild_id | Snowflake_Type | id of the guild the voice channel is in. | required |
channel_id | Snowflake_Type | id of the voice channel client wants to join. | required |
muted | bool | Whether the bot should be muted when connected. | False |
deafened | bool | Whether the bot should be deafened when connected. | False |
Returns:
Type | Description |
---|---|
ActiveVoiceState | The new active voice state on successfully connection. |
Source code in interactions/api/gateway/state.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
wrapped_logger(level, message, **kwargs)
¶
A logging wrapper that adds shard information to the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level | int | The logging level | required |
message | str | The message to log | required |
**kwargs | Any additional keyword arguments that Logger.log accepts | {} |
Source code in interactions/api/gateway/state.py
133 134 135 136 137 138 139 140 141 142 143 |
|
Outlines the interaction between interactions and Discord's Gateway API.
GatewayClient
¶
Bases: WebsocketClient
Abstraction over one gateway connection.
Multiple WebsocketClient
instances can be used to implement same-process sharding.
Attributes:
Name | Type | Description |
---|---|---|
sequence | The sequence of this connection | |
session_id | The session ID of this connection |
Source code in interactions/api/gateway/gateway.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
change_presence(activity=None, status=Status.ONLINE, since=None)
async
¶
Update the bot's presence status.
Source code in interactions/api/gateway/gateway.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
close()
¶
Shutdown the websocket connection.
Source code in interactions/api/gateway/gateway.py
246 247 248 |
|
run()
async
¶
Start receiving events from the websocket.
Source code in interactions/api/gateway/gateway.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
voice_state_update(guild_id, channel_id, muted=False, deafened=False)
async
¶
Update the bot's voice state.
Source code in interactions/api/gateway/gateway.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
VoiceGateway
¶
Bases: WebsocketClient
Source code in interactions/api/voice/voice_gateway.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
|
establish_voice_socket()
async
¶
Establish the socket connection to discord
Source code in interactions/api/voice/voice_gateway.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
generate_packet(data)
¶
Generate a packet to be sent to the voice socket.
Source code in interactions/api/voice/voice_gateway.py
318 319 320 321 322 323 324 325 326 327 328 |
|
run()
async
¶
Start receiving events from the websocket.
Source code in interactions/api/voice/voice_gateway.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
send_packet(data, encoder, needs_encode=True)
¶
Send a packet to the voice socket
Source code in interactions/api/voice/voice_gateway.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
set_new_voice_server(payload)
¶
Set a new voice server to connect to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload | dict | New voice server connection data | required |
Source code in interactions/api/voice/voice_gateway.py
401 402 403 404 405 406 407 408 409 410 411 412 |
|
speaking(is_speaking=True)
async
¶
Tell the gateway if we're sending audio or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_speaking | bool | If we're sending audio or not | True |
Source code in interactions/api/voice/voice_gateway.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
This file handles the interaction with discords http endpoints.
BucketLock
¶
Manages the rate limit for each bucket.
Source code in interactions/api/http/http_client.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
locked: bool
property
¶
Returns whether the bucket is locked.
acquire()
async
¶
Acquires the semaphore.
Source code in interactions/api/http/http_client.py
153 154 155 156 157 158 159 160 161 162 163 |
|
ingest_ratelimit_header(header)
¶
Ingests the rate limit header.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
header | CIMultiDictProxy | The header to ingest, containing rate limit information. | required |
Updates the bucket_hash, limit, remaining, and delta attributes with the information from the header.
Source code in interactions/api/http/http_client.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
lock_for_duration(duration, block=False)
async
¶
Locks the bucket for a given duration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
duration | float | The duration to lock the bucket for. | required |
block | bool | Whether to block until the bucket is unlocked. | False |
Raises:
Type | Description |
---|---|
RuntimeError | If the bucket is already locked. |
Source code in interactions/api/http/http_client.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
release()
¶
Releases the semaphore.
Note: If the bucket has been locked with lock_for_duration, this will not release the lock.
Source code in interactions/api/http/http_client.py
165 166 167 168 169 170 171 172 173 |
|
GlobalLock
¶
Source code in interactions/api/http/http_client.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
calls_remaining: int
property
¶
Returns the amount of calls remaining.
reset_calls()
¶
Resets the calls to the max amount.
Source code in interactions/api/http/http_client.py
71 72 73 74 |
|
set_reset_time(delta)
¶
Sets the reset time to the current time + delta.
To be called if a 429 is received.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delta | float | The time to wait before resetting the calls. | required |
Source code in interactions/api/http/http_client.py
76 77 78 79 80 81 82 83 84 85 86 87 |
|
wait()
async
¶
Throttles calls to prevent hitting the global rate limit.
Source code in interactions/api/http/http_client.py
89 90 91 92 93 94 95 96 97 |
|
HTTPClient
¶
Bases: BotRequests
, ChannelRequests
, EmojiRequests
, EntitlementRequests
, GuildRequests
, InteractionRequests
, MemberRequests
, MessageRequests
, ReactionRequests
, StickerRequests
, ThreadRequests
, UserRequests
, WebhookRequests
, ScheduledEventsRequests
A http client for sending requests to the Discord API.
Source code in interactions/api/http/http_client.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
close()
async
¶
Close the session.
Source code in interactions/api/http/http_client.py
558 559 560 561 |
|
get_gateway()
async
¶
Gets the gateway url.
Returns:
Type | Description |
---|---|
str | The gateway url |
Source code in interactions/api/http/http_client.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
|
get_ratelimit(route)
¶
Get a route's rate limit bucket.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
route | Route | The route to fetch the ratelimit bucket for | required |
Returns:
Type | Description |
---|---|
BucketLock | The BucketLock object for this route |
Source code in interactions/api/http/http_client.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
ingest_ratelimit(route, header, bucket_lock)
¶
Ingests a ratelimit header from discord to determine ratelimit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
route | Route | The route we're ingesting ratelimit for | required |
header | CIMultiDictProxy | The rate limit header in question | required |
bucket_lock | BucketLock | The rate limit bucket for this route | required |
Source code in interactions/api/http/http_client.py
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
log_ratelimit(log_func, message)
¶
Logs a ratelimit message, optionally with a traceback if show_ratelimit_traceback is True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_func | Callable | The logging function to use | required |
message | str | The message to log | required |
Source code in interactions/api/http/http_client.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
|
login(token)
async
¶
"Login" to the gateway, basically validates the token and grabs user data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token | str | the token to use | required |
Returns:
Type | Description |
---|---|
dict[str, Any] | The currently logged in bot's data |
Source code in interactions/api/http/http_client.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
request(route, payload=None, files=None, reason=None, params=None, **kwargs)
async
¶
Make a request to discord.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
route | Route | The route to take | required |
payload | list | dict | None | The payload for this request | None |
files | list[UPLOADABLE_TYPE] | None | The files to send with this request | None |
reason | str | None | Attach a reason to this request, used for audit logs | None |
params | dict | None | Query string parameters | None |
Source code in interactions/api/http/http_client.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
websocket_connect(url)
async
¶
Connect to the websocket.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url | str | the url to connect to | required |
Source code in interactions/api/http/http_client.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
Voice¶
Audio
¶
Bases: BaseAudio
Audio for playing from file or URL.
Source code in interactions/api/voice/audio.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
audio_complete: bool
property
¶
Uses the state of the subprocess to determine if more audio is coming
cleanup()
¶
Cleans up after this audio object.
Source code in interactions/api/voice/audio.py
345 346 347 348 349 |
|
pre_buffer(duration=None)
¶
Start pre-buffering the audio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
duration | None | float | The duration of audio to pre-buffer. | None |
Source code in interactions/api/voice/audio.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
read(frame_size)
¶
Reads frame_size bytes of audio from the buffer.
Returns:
Type | Description |
---|---|
bytes | bytes of audio |
Source code in interactions/api/voice/audio.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
AudioBuffer
¶
Source code in interactions/api/voice/audio.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
extend(data)
¶
Extend the buffer with additional data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | bytes | The data to add | required |
Source code in interactions/api/voice/audio.py
82 83 84 85 86 87 88 89 90 91 |
|
read(total_bytes, *, pad=True)
¶
Read total_bytes
bytes of audio from the buffer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
total_bytes | int | Amount of bytes to read. | required |
pad | bool | Whether to pad incomplete frames with 0's. | True |
Returns:
Type | Description |
---|---|
bytearray | Desired amount of bytes |
Raises:
Type | Description |
---|---|
ValueError | If |
Source code in interactions/api/voice/audio.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
read_max(total_bytes)
¶
Read up to total_bytes
bytes of audio from the buffer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
total_bytes | int | Maximum amount of bytes to read. | required |
Returns:
Type | Description |
---|---|
bytearray | Desired amount of bytes |
Raises:
Type | Description |
---|---|
EOFError | If the buffer is empty. |
Source code in interactions/api/voice/audio.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
AudioVolume
¶
Bases: Audio
An audio object with volume control
Source code in interactions/api/voice/audio.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
|
volume: float
writable
property
¶
The volume of the audio
read(frame_size)
¶
Reads frame_size ms of audio from source.
Returns:
Type | Description |
---|---|
bytes | bytes of audio |
Source code in interactions/api/voice/audio.py
372 373 374 375 376 377 378 379 380 381 |
|
BaseAudio
¶
Bases: ABC
Base structure of the audio.
Source code in interactions/api/voice/audio.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
audio_complete: bool
property
¶
A property to tell the player if more audio is expected.
bitrate: Optional[int]
class-attribute
¶
Optionally specify a specific bitrate to encode this audio data with
encoder: Optional[Encoder]
class-attribute
¶
The encoder to use for this audio data
locked_stream: bool
class-attribute
¶
Prevents the audio task from closing automatically when no data is received.
needs_encode: bool
class-attribute
¶
Does this audio data need encoding with opus?
cleanup()
abstractmethod
¶
A method to optionally cleanup after this object is no longer required.
Source code in interactions/api/voice/audio.py
159 160 161 162 |
|
read(frame_size)
abstractmethod
¶
Reads frame_size ms of audio from source.
Returns:
Type | Description |
---|---|
bytes | bytes of audio |
Source code in interactions/api/voice/audio.py
169 170 171 172 173 174 175 176 177 178 |
|
RawInputAudio
¶
Source code in interactions/api/voice/audio.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
Player
¶
Bases: threading.Thread
Source code in interactions/api/voice/player.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
elapsed_time: float
property
¶
How many seconds of audio the player has sent.
paused: bool
property
¶
Is the player paused
stopped: bool
property
¶
Is the player currently stopped?
pause()
¶
Pause the player.
Source code in interactions/api/voice/player.py
73 74 75 |
|
play()
¶
Start playing.
Source code in interactions/api/voice/player.py
87 88 89 90 91 |
|
resume()
¶
Resume playing.
Source code in interactions/api/voice/player.py
62 63 64 65 66 |
|
run()
¶
The main player loop to send audio to the voice websocket.
Source code in interactions/api/voice/player.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
stop()
¶
Stop playing completely.
Source code in interactions/api/voice/player.py
56 57 58 59 60 |
|
Errors¶
AlreadyDeferred
¶
Bases: InteractionException
An interaction was already deferred, and you attempted to defer it again.
Source code in interactions/client/errors.py
389 390 |
|
AlreadyResponded
¶
Bases: AlreadyDeferred
An interaction was already responded to, and you attempted to defer it
Source code in interactions/client/errors.py
393 394 |
|
BadArgument
¶
Bases: CommandException
A prefixed command encountered an invalid argument.
Source code in interactions/client/errors.py
323 324 325 326 327 328 329 330 331 |
|
BadRequest
¶
Bases: HTTPException
A bad request was made.
Source code in interactions/client/errors.py
180 181 |
|
BotException
¶
Bases: LibraryException
An issue occurred in the client, likely user error.
Source code in interactions/client/errors.py
57 58 |
|
CommandCheckFailure
¶
Bases: CommandException
A command check failed.
Attributes:
Name | Type | Description |
---|---|---|
command | BaseCommand | The command that's check failed |
check | Callable[..., Coroutine] | The check that failed |
Source code in interactions/client/errors.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
CommandException
¶
Bases: BotException
An error occurred trying to execute a command.
Source code in interactions/client/errors.py
276 277 |
|
CommandOnCooldown
¶
Bases: CommandException
A command is on cooldown, and was attempted to be executed.
Attributes:
Name | Type | Description |
---|---|---|
command | BaseCommand | The command that is on cooldown |
cooldown | CooldownSystem | The cooldown system |
Source code in interactions/client/errors.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
DiscordError
¶
Bases: HTTPException
A discord-side error.
Source code in interactions/client/errors.py
176 177 |
|
EmptyMessageException
¶
Bases: MessageException
You have attempted to send a message without any content or embeds
Source code in interactions/client/errors.py
338 339 |
|
EphemeralEditException
¶
Bases: MessageException
Your bot attempted to edit an ephemeral message. This is not possible.
Its worth noting you can edit an ephemeral message with component's edit_origin
method.
Source code in interactions/client/errors.py
342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
EventLocationNotProvided
¶
Bases: BotException
Raised when you have entity_type external and no location is provided.
Source code in interactions/client/errors.py
401 402 |
|
ExtensionException
¶
Bases: BotException
An error occurred with an extension.
Source code in interactions/client/errors.py
264 265 |
|
ExtensionLoadException
¶
Bases: ExtensionException
An error occurred loading an extension.
Source code in interactions/client/errors.py
272 273 |
|
ExtensionNotFound
¶
Bases: ExtensionException
The desired extension was not found.
Source code in interactions/client/errors.py
268 269 |
|
Forbidden
¶
Bases: HTTPException
You do not have access to this.
Source code in interactions/client/errors.py
184 185 |
|
ForeignWebhookException
¶
Bases: LibraryException
Raised when you attempt to send using a webhook you did not create.
Source code in interactions/client/errors.py
397 398 |
|
GatewayNotFound
¶
Bases: LibraryException
An exception that is raised when the gateway for Discord could not be found.
Source code in interactions/client/errors.py
61 62 63 64 65 |
|
HTTPException
¶
Bases: LibraryException
A HTTP request resulted in an exception.
Attributes:
Name | Type | Description |
---|---|---|
response | aiohttp.ClientResponse | The response of the HTTP request |
text | str | The text of the exception, could be None |
status | int | The HTTP status code |
code | int | The discord error code, if one is provided |
route | Route | The HTTP route that was used |
Source code in interactions/client/errors.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
search_for_message(errors, lookup=None)
staticmethod
¶
Search the exceptions error dictionary for a message explaining the issue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
errors | dict | The error dictionary of the http exception | required |
lookup | Optional[dict] | A lookup dictionary to use to convert indexes into named items | None |
Returns:
Type | Description |
---|---|
list[str] | A list of parsed error strings found |
Source code in interactions/client/errors.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
InteractionException
¶
Bases: BotException
An error occurred with an interaction.
Source code in interactions/client/errors.py
368 369 |
|
InteractionMissingAccess
¶
Bases: InteractionException
The bot does not have access to the specified scope.
Source code in interactions/client/errors.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
LibraryException
¶
Bases: Exception
Base Exception of i.py.
Source code in interactions/client/errors.py
53 54 |
|
LoginError
¶
Bases: BotException
The bot failed to login, check your token.
Source code in interactions/client/errors.py
68 69 |
|
MaxConcurrencyReached
¶
Bases: CommandException
A command has exhausted the max concurrent requests.
Source code in interactions/client/errors.py
297 298 299 300 301 302 303 304 |
|
MessageException
¶
Bases: BotException
A message operation encountered an exception.
Source code in interactions/client/errors.py
334 335 |
|
NotFound
¶
Bases: HTTPException
This resource could not be found.
Source code in interactions/client/errors.py
188 189 |
|
RateLimited
¶
Bases: HTTPException
Discord is rate limiting this application.
Source code in interactions/client/errors.py
192 193 |
|
ThreadException
¶
Bases: BotException
A thread operation encountered an exception.
Source code in interactions/client/errors.py
357 358 |
|
ThreadOutsideOfGuild
¶
Bases: ThreadException
A thread was attempted to be created outside of a guild.
Source code in interactions/client/errors.py
361 362 363 364 365 |
|
TooManyChanges
¶
Bases: LibraryException
You have changed something too frequently.
Source code in interactions/client/errors.py
196 197 |
|
VoiceAlreadyConnected
¶
Bases: BotException
Raised when you attempt to connect a voice channel that is already connected.
Source code in interactions/client/errors.py
405 406 407 408 409 |
|
VoiceConnectionTimeout
¶
Bases: LibraryException
Raised when the bot fails to connect to a voice channel.
Source code in interactions/client/errors.py
419 420 421 422 423 |
|
VoiceNotConnected
¶
Bases: BotException
Raised when you attempt to connect a voice channel that is not connected.
Source code in interactions/client/errors.py
412 413 414 415 416 |
|
VoiceWebSocketClosed
¶
Bases: LibraryException
The voice websocket was closed.
Source code in interactions/client/errors.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
WebSocketClosed
¶
Bases: LibraryException
The websocket was closed.
Source code in interactions/client/errors.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
WebSocketRestart
¶
Bases: LibraryException
The websocket closed, and is safe to restart.
Source code in interactions/client/errors.py
254 255 256 257 258 259 260 261 |
|
Events¶
These are events dispatched by Discord. This is intended as a reference so you know what data to expect for each event.
Example Usage
To listen to an event, use the listen
decorator:
1 2 3 4 5 6 |
|
For more information, including other ways to listen to events, see the events guide.
Warning
While all of these events are documented, not all of them are used, currently.
AutoModCreated
¶
Bases: BaseEvent
Dispatched when an auto mod rule is created
Source code in interactions/api/events/discord.py
141 142 143 144 145 146 |
|
AutoModDeleted
¶
Bases: AutoModCreated
Dispatched when an auto mod rule is deleted
Source code in interactions/api/events/discord.py
156 157 158 159 160 |
|
AutoModExec
¶
Bases: BaseEvent
Dispatched when an auto modation action is executed
Source code in interactions/api/events/discord.py
132 133 134 135 136 137 138 |
|
AutoModUpdated
¶
Bases: AutoModCreated
Dispatched when an auto mod rule is modified
Source code in interactions/api/events/discord.py
149 150 151 152 153 |
|
BanCreate
¶
Bases: GuildEvent
Dispatched when someone was banned from a guild.
Source code in interactions/api/events/discord.py
338 339 340 341 342 |
|
BanRemove
¶
Bases: BanCreate
Dispatched when a users ban is removed.
Source code in interactions/api/events/discord.py
345 346 347 |
|
BaseMessagePollEvent
¶
Bases: BaseEvent
Source code in interactions/api/events/discord.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
|
answer_id: int = attrs.field(repr=False)
class-attribute
¶
The ID of the answer the user voted for
channel_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The ID of the channel the poll is in
guild_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
class-attribute
¶
The ID of the guild the poll is in
message_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The ID of the message the poll is in
user_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The ID of the user that voted
fetch_channel()
async
¶
Fetch the channel the poll is in
Source code in interactions/api/events/discord.py
636 637 638 |
|
fetch_guild()
async
¶
Fetch the guild the poll is in
Source code in interactions/api/events/discord.py
640 641 642 |
|
fetch_message()
async
¶
Fetch the message the poll is in
Source code in interactions/api/events/discord.py
628 629 630 |
|
fetch_poll()
async
¶
Fetch the poll object
Source code in interactions/api/events/discord.py
644 645 646 647 |
|
fetch_user()
async
¶
Fetch the user that voted
Source code in interactions/api/events/discord.py
632 633 634 |
|
get_channel()
¶
Get the channel object if it is cached
Source code in interactions/api/events/discord.py
615 616 617 |
|
get_guild()
¶
Get the guild object if it is cached
Source code in interactions/api/events/discord.py
619 620 621 |
|
get_message()
¶
Get the message object if it is cached
Source code in interactions/api/events/discord.py
607 608 609 |
|
get_poll()
¶
Get the poll object if it is cached
Source code in interactions/api/events/discord.py
623 624 625 626 |
|
get_user()
¶
Get the user object if it is cached
Source code in interactions/api/events/discord.py
611 612 613 |
|
BaseVoiceEvent
¶
Bases: BaseEvent
Source code in interactions/api/events/discord.py
759 760 761 762 763 764 |
|
state: VoiceState = attrs.field(repr=False)
class-attribute
¶
The current voice state of the user
ChannelCreate
¶
Bases: BaseEvent
Dispatched when a channel is created.
Source code in interactions/api/events/discord.py
177 178 179 180 181 |
|
ChannelDelete
¶
Bases: ChannelCreate
Dispatched when a channel is deleted.
Source code in interactions/api/events/discord.py
198 199 200 |
|
ChannelPinsUpdate
¶
Bases: ChannelCreate
Dispatched when a channel's pins are updated.
Source code in interactions/api/events/discord.py
203 204 205 206 207 208 209 210 |
|
last_pin_timestamp: Timestamp = attrs.field(repr=False)
class-attribute
¶
The time at which the most recent pinned message was pinned
ChannelUpdate
¶
Bases: BaseEvent
Dispatched when a channel is updated.
Source code in interactions/api/events/discord.py
184 185 186 187 188 189 190 191 192 193 194 195 |
|
EntitlementCreate
¶
Bases: BaseEntitlementEvent
Dispatched when a user subscribes to a SKU.
Source code in interactions/api/events/discord.py
915 916 917 |
|
EntitlementDelete
¶
Bases: BaseEntitlementEvent
Dispatched when a user's entitlement is deleted.
Notably, this event is not dispatched when a user's subscription is cancelled. Instead, you simply won't receive an EntitlementUpdate event for the next billing period.
Source code in interactions/api/events/discord.py
925 926 927 928 929 930 931 932 |
|
EntitlementUpdate
¶
Bases: BaseEntitlementEvent
Dispatched when a user's subscription renews for the next billing period.
Source code in interactions/api/events/discord.py
920 921 922 |
|
GuildAuditLogEntryCreate
¶
Bases: GuildEvent
Dispatched when audit log entry is created
Source code in interactions/api/events/discord.py
849 850 851 852 853 854 |
|
audit_log_entry: interactions.models.AuditLogEntry = attrs.field(repr=False)
class-attribute
¶
The audit log entry object
GuildAvailable
¶
Bases: GuildEvent
Dispatched when a guild becomes available.
Source code in interactions/api/events/discord.py
328 329 330 |
|
GuildEmojisUpdate
¶
Bases: GuildEvent
Dispatched when a guild's emojis are updated.
Source code in interactions/api/events/discord.py
350 351 352 353 354 355 356 357 |
|
after: List[CustomEmoji] = attrs.field(repr=False, factory=list)
class-attribute
¶
List of emoji after this event
before: List[CustomEmoji] = attrs.field(repr=False, factory=list)
class-attribute
¶
List of emoji before this event. Only includes emojis that were cached. To enable the emoji cache (and this field), start your bot with Client(enable_emoji_cache=True)
GuildJoin
¶
Bases: GuildEvent
Dispatched when a guild is joined, created, or becomes available.
Note
This is called multiple times during startup, check the bot is ready before responding to this.
Source code in interactions/api/events/discord.py
292 293 294 295 296 297 298 299 300 |
|
GuildLeft
¶
Bases: BaseEvent
Dispatched when a guild is left.
Source code in interactions/api/events/discord.py
317 318 319 320 321 322 323 324 325 |
|
GuildMembersChunk
¶
Bases: GuildEvent
Sent in response to Guild Request Members.
You can use the chunk_index
and chunk_count
to calculate how many chunks are left for your request.
Source code in interactions/api/events/discord.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
chunk_count: int = attrs.field(repr=False)
class-attribute
¶
the total number of expected chunks for this response
chunk_index: int = attrs.field(repr=False)
class-attribute
¶
The chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count)
members: List[Member] = attrs.field(repr=False, factory=list)
class-attribute
¶
A list of members
nonce: str = attrs.field(repr=False)
class-attribute
¶
The nonce used in the request, if any
presences: List = attrs.field(repr=False)
class-attribute
¶
if passing true to REQUEST_GUILD_MEMBERS
, presences of the returned members will be here
GuildScheduledEventCreate
¶
Bases: BaseEvent
Dispatched when scheduled event is created
Source code in interactions/api/events/discord.py
857 858 859 860 861 862 |
|
scheduled_event: ScheduledEvent = attrs.field(repr=True)
class-attribute
¶
The scheduled event object
GuildScheduledEventDelete
¶
Bases: GuildScheduledEventCreate
Dispatched when scheduled event is deleted
Source code in interactions/api/events/discord.py
875 876 877 |
|
GuildScheduledEventUpdate
¶
Bases: BaseEvent
Dispatched when scheduled event is updated
Source code in interactions/api/events/discord.py
865 866 867 868 869 870 871 872 |
|
GuildScheduledEventUserAdd
¶
Bases: GuildEvent
Dispatched when scheduled event is created
Source code in interactions/api/events/discord.py
880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
|
member: Optional[Member]
property
¶
The guild member that has been added/removed from scheduled event if cached
scheduled_event: Optional[ScheduledEvent]
property
¶
The scheduled event object if cached
scheduled_event_id: Snowflake_Type = attrs.field(repr=True)
class-attribute
¶
The ID of the scheduled event
user: Optional[User]
property
¶
The user that has been added/removed from scheduled event if cached
user_id: Snowflake_Type = attrs.field(repr=True)
class-attribute
¶
The ID of the user that has been added/removed from scheduled event
GuildScheduledEventUserRemove
¶
Bases: GuildScheduledEventUserAdd
Dispatched when scheduled event is removed
Source code in interactions/api/events/discord.py
905 906 907 |
|
GuildStickersUpdate
¶
Bases: GuildEvent
Dispatched when a guild's stickers are updated.
Source code in interactions/api/events/discord.py
360 361 362 363 364 365 |
|
stickers: List[Sticker] = attrs.field(repr=False, factory=list)
class-attribute
¶
List of stickers from after this event
GuildUnavailable
¶
Bases: GuildEvent
Dispatched when a guild is not available.
Source code in interactions/api/events/discord.py
333 334 335 |
|
GuildUpdate
¶
Bases: BaseEvent
Dispatched when a guild is updated.
Source code in interactions/api/events/discord.py
303 304 305 306 307 308 309 310 311 312 313 314 |
|
IntegrationCreate
¶
Bases: BaseEvent
Dispatched when a guild integration is created.
Source code in interactions/api/events/discord.py
467 468 469 470 471 472 473 |
|
IntegrationDelete
¶
Bases: GuildEvent
Dispatched when a guild integration is deleted.
Source code in interactions/api/events/discord.py
481 482 483 484 485 486 487 488 489 490 |
|
IntegrationUpdate
¶
Bases: IntegrationCreate
Dispatched when a guild integration is updated.
Source code in interactions/api/events/discord.py
476 477 478 |
|
InteractionCreate
¶
Bases: BaseEvent
Dispatched when a user uses an Application Command.
Source code in interactions/api/events/discord.py
736 737 738 739 740 741 742 |
|
InviteCreate
¶
Bases: BaseEvent
Dispatched when a guild invite is created.
Source code in interactions/api/events/discord.py
493 494 495 496 497 498 499 |
|
InviteDelete
¶
Bases: InviteCreate
Dispatched when an invite is deleted.
Source code in interactions/api/events/discord.py
502 503 504 |
|
MemberAdd
¶
Bases: GuildEvent
Dispatched when a member is added to a guild.
Source code in interactions/api/events/discord.py
368 369 370 371 372 |
|
MemberRemove
¶
Bases: MemberAdd
Dispatched when a member is removed from a guild.
Source code in interactions/api/events/discord.py
375 376 377 378 379 380 381 382 |
|
MemberUpdate
¶
Bases: GuildEvent
Dispatched when a member is updated.
Source code in interactions/api/events/discord.py
385 386 387 388 389 390 391 392 393 394 395 396 |
|
MessageCreate
¶
Bases: BaseEvent
Dispatched when a message is created.
Source code in interactions/api/events/discord.py
507 508 509 510 511 512 513 |
|
MessageDelete
¶
Bases: BaseEvent
Dispatched when a message is deleted.
Source code in interactions/api/events/discord.py
530 531 532 533 534 535 536 |
|
MessageDeleteBulk
¶
Bases: GuildEvent
Dispatched when multiple messages are deleted at once.
Source code in interactions/api/events/discord.py
539 540 541 542 543 544 545 546 547 548 |
|
MessagePollVoteAdd
¶
Bases: BaseMessagePollEvent
Dispatched when a user votes in a poll
Source code in interactions/api/events/discord.py
650 651 652 |
|
MessagePollVoteRemove
¶
Bases: BaseMessagePollEvent
Dispatched when a user remotes a votes in a poll
Source code in interactions/api/events/discord.py
655 656 657 |
|
MessageReactionAdd
¶
Bases: BaseEvent
Dispatched when a reaction is added to a message.
Source code in interactions/api/events/discord.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
reaction_count: int
property
¶
Times the emoji in the event has been used to react
MessageReactionRemove
¶
Bases: MessageReactionAdd
Dispatched when a reaction is removed.
Source code in interactions/api/events/discord.py
569 570 571 |
|
MessageReactionRemoveAll
¶
Bases: GuildEvent
Dispatched when all reactions are removed from a message.
Source code in interactions/api/events/discord.py
574 575 576 577 578 579 580 581 |
|
message: Message = attrs.field(repr=False)
class-attribute
¶
The message that was reacted to
MessageReactionRemoveEmoji
¶
Bases: MessageReactionRemoveAll
Dispatched when all reactions of a specifc emoji are removed from a message.
Source code in interactions/api/events/discord.py
584 585 586 587 588 589 590 591 |
|
emoji: PartialEmoji = attrs.field(repr=False)
class-attribute
¶
The emoji that was removed
MessageUpdate
¶
Bases: BaseEvent
Dispatched when a message is edited.
Source code in interactions/api/events/discord.py
516 517 518 519 520 521 522 523 524 525 526 527 |
|
NewThreadCreate
¶
Bases: ThreadCreate
Dispatched when a thread is newly created.
Source code in interactions/api/events/discord.py
220 221 222 |
|
PresenceUpdate
¶
Bases: BaseEvent
A user's presence has changed.
Source code in interactions/api/events/discord.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
activities: List[Activity] = attrs.field(repr=False)
class-attribute
¶
The users current activities
client_status: dict = attrs.field(repr=False)
class-attribute
¶
What platform the user is reported as being on
guild_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The guild this presence update was dispatched from
status: str = attrs.field(repr=False)
class-attribute
¶
'Either idle
, dnd
, online
, or offline
'
user: User = attrs.field(repr=False)
class-attribute
¶
The user in question
RoleCreate
¶
Bases: GuildEvent
Dispatched when a role is created.
Source code in interactions/api/events/discord.py
399 400 401 402 403 404 405 406 |
|
role: Role = attrs.field(repr=False)
class-attribute
¶
The created role
RoleDelete
¶
Bases: GuildEvent
Dispatched when a guild role is deleted.
Source code in interactions/api/events/discord.py
423 424 425 426 427 428 429 430 431 432 433 434 |
|
RoleUpdate
¶
Bases: GuildEvent
Dispatched when a role is updated.
Source code in interactions/api/events/discord.py
409 410 411 412 413 414 415 416 417 418 419 420 |
|
StageInstanceCreate
¶
Bases: BaseEvent
Dispatched when a stage instance is created.
Source code in interactions/api/events/discord.py
686 687 688 689 690 |
|
StageInstanceDelete
¶
Bases: StageInstanceCreate
Dispatched when a stage instance is deleted.
Source code in interactions/api/events/discord.py
693 694 695 |
|
StageInstanceUpdate
¶
Bases: StageInstanceCreate
Dispatched when a stage instance is updated.
Source code in interactions/api/events/discord.py
698 699 700 |
|
ThreadCreate
¶
Bases: BaseEvent
Dispatched when a thread is created, or a thread is new to the client
Source code in interactions/api/events/discord.py
213 214 215 216 217 |
|
ThreadDelete
¶
Bases: ThreadCreate
Dispatched when a thread is deleted.
Source code in interactions/api/events/discord.py
230 231 232 |
|
ThreadListSync
¶
Bases: BaseEvent
Dispatched when gaining access to a channel, contains all active threads in that channel.
Source code in interactions/api/events/discord.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
channel_ids: Sequence[Snowflake_Type] = attrs.field(repr=False)
class-attribute
¶
The parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild. This array may contain channel_ids that have no active threads as well, so you know to clear that data.
members: List[Member] = attrs.field(repr=False)
class-attribute
¶
all thread member objects from the synced threads for the current user, indicating which threads the current user has been added to
threads: List[TYPE_ALL_CHANNEL] = attrs.field(repr=False)
class-attribute
¶
all active threads in the given channels that the current user can access
ThreadMemberUpdate
¶
Bases: ThreadCreate
Dispatched when the thread member object for the current user is updated.
??? info "Note from Discord" This event is documented for completeness, but unlikely to be used by most bots. For bots, this event largely is just a signal that you are a member of the thread
Source code in interactions/api/events/discord.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
member: Member = attrs.field(repr=False)
class-attribute
¶
The member who was added
ThreadMembersUpdate
¶
Bases: GuildEvent
Dispatched when anyone is added or removed from a thread.
Source code in interactions/api/events/discord.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
added_members: List[Member] = attrs.field(repr=False, factory=list)
class-attribute
¶
Users added to the thread
channel: Optional[TYPE_THREAD_CHANNEL]
property
¶
The thread channel this event is dispatched from
id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The ID of the thread
member_count: int = attrs.field(repr=False, default=50)
class-attribute
¶
the approximate number of members in the thread, capped at 50
removed_member_ids: List[Snowflake_Type] = attrs.field(repr=False, factory=list)
class-attribute
¶
Users removed from the thread
ThreadUpdate
¶
Bases: ThreadCreate
Dispatched when a thread is updated.
Source code in interactions/api/events/discord.py
225 226 227 |
|
TypingStart
¶
Bases: BaseEvent
Dispatched when a user starts typing.
Source code in interactions/api/events/discord.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
|
author: Union[User, Member] = attrs.field(repr=False)
class-attribute
¶
The user who started typing
channel: TYPE_ALL_CHANNEL = attrs.field(repr=False)
class-attribute
¶
The channel typing is in
guild: Guild = attrs.field(repr=False)
class-attribute
¶
The ID of the guild this typing is in
timestamp: Timestamp = attrs.field(repr=False)
class-attribute
¶
unix time (in seconds) of when the user started typing
VoiceStateUpdate
¶
Bases: BaseEvent
Dispatched when a user's voice state changes.
Source code in interactions/api/events/discord.py
745 746 747 748 749 750 751 752 753 754 755 756 |
|
after: Optional[VoiceState] = attrs.field(repr=False)
class-attribute
¶
The voice state after this event was created or None if the user is no longer in a voice channel
before: Optional[VoiceState] = attrs.field(repr=False)
class-attribute
¶
The voice state before this event was created or None if the user was not in a voice channel
VoiceUserDeafen
¶
Bases: BaseVoiceEvent
Dispatched when a user is deafened or undeafened.
Source code in interactions/api/events/discord.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
|
author: Union[User, Member] = attrs.field(repr=False)
class-attribute
¶
The user who was deafened or undeafened
channel: VoiceChannel = attrs.field(repr=False)
class-attribute
¶
The voice channel the user was deafened or undeafened in
deaf: bool = attrs.field(repr=False)
class-attribute
¶
The new deaf state of the user
VoiceUserJoin
¶
Bases: BaseVoiceEvent
Dispatched when a user joins a voice channel.
Source code in interactions/api/events/discord.py
821 822 823 824 825 826 827 828 829 830 831 832 |
|
VoiceUserLeave
¶
Bases: BaseVoiceEvent
Dispatched when a user leaves a voice channel.
Source code in interactions/api/events/discord.py
835 836 837 838 839 840 841 842 843 844 845 846 |
|
VoiceUserMove
¶
Bases: BaseVoiceEvent
Dispatched when a user moves voice channels.
Source code in interactions/api/events/discord.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
|
VoiceUserMute
¶
Bases: BaseVoiceEvent
Dispatched when a user is muted or unmuted.
Source code in interactions/api/events/discord.py
785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
|
author: Union[User, Member] = attrs.field(repr=False)
class-attribute
¶
The user who was muted or unmuted
channel: VoiceChannel = attrs.field(repr=False)
class-attribute
¶
The voice channel the user was muted or unmuted in
mute: bool = attrs.field(repr=False)
class-attribute
¶
The new mute state of the user
WebhooksUpdate
¶
Bases: GuildEvent
Dispatched when a guild channel webhook is created, updated, or deleted.
Source code in interactions/api/events/discord.py
725 726 727 728 729 730 731 732 733 |
|
channel_id: Snowflake_Type = attrs.field(repr=False)
class-attribute
¶
The ID of the webhook was updated
These are events dispatched by the client. This is intended as a reference so you know what data to expect for each event.
Example Usage
To listen to an event, use the listen
decorator:
1 2 3 4 5 6 |
|
For more information, including other ways to listen to events, see the events guide.
Warning
While all of these events are documented, not all of them are used, currently.
AutocompleteCompletion
¶
Bases: BaseEvent
Dispatched after the library ran any autocomplete callback.
Source code in interactions/api/events/internal.py
170 171 172 173 174 |
|
AutocompleteError
¶
Bases: _Error
Dispatched when the library encounters an error in an autocomplete.
Source code in interactions/api/events/internal.py
215 216 217 218 219 |
|
ButtonPressed
¶
Bases: Component
Dispatched when a user uses a Button.
Source code in interactions/api/events/internal.py
146 147 148 |
|
CallbackAdded
¶
Bases: BaseEvent
Dispatched when a callback is added to the client.
Source code in interactions/api/events/internal.py
257 258 259 260 261 262 263 264 |
|
CommandCompletion
¶
Bases: BaseEvent
Dispatched after the library ran any command callback.
Source code in interactions/api/events/internal.py
156 157 158 159 160 |
|
CommandError
¶
Bases: _Error
Dispatched when the library encounters an error in a command.
Source code in interactions/api/events/internal.py
201 202 203 204 205 |
|
Component
¶
Bases: BaseEvent
Dispatched when a user uses a Component.
Source code in interactions/api/events/internal.py
139 140 141 142 143 |
|
ComponentCompletion
¶
Bases: BaseEvent
Dispatched after the library ran any component callback.
Source code in interactions/api/events/internal.py
163 164 165 166 167 |
|
ComponentError
¶
Bases: _Error
Dispatched when the library encounters an error in a component.
Source code in interactions/api/events/internal.py
208 209 210 211 212 |
|
Connect
¶
Bases: BaseEvent
The bot is now connected to the discord Gateway.
Source code in interactions/api/events/internal.py
80 81 82 |
|
Disconnect
¶
Bases: BaseEvent
The bot has just disconnected.
Source code in interactions/api/events/internal.py
90 91 92 |
|
Error
¶
Bases: _Error
Dispatched when the library encounters an error.
Source code in interactions/api/events/internal.py
191 192 193 194 195 196 197 198 |
|
ExtensionCommandParse
¶
Bases: ExtensionLoad
Dispatched when an extension is parsed for commands.
Source code in interactions/api/events/internal.py
249 250 251 252 253 254 |
|
callables: list[tuple[str, typing.Callable]] = attrs.field(repr=False, default=None)
class-attribute
¶
The callables that were parsed for commands
ExtensionLoad
¶
Bases: BaseEvent
Dispatched when an extension is loaded.
Source code in interactions/api/events/internal.py
229 230 231 232 233 234 235 236 237 238 239 |
|
ExtensionUnload
¶
Bases: ExtensionLoad
Dispatched when an extension is unloaded.
Source code in interactions/api/events/internal.py
242 243 244 245 246 |
|
Login
¶
Bases: BaseEvent
The bot has just logged in.
Source code in interactions/api/events/internal.py
75 76 77 |
|
ModalCompletion
¶
Bases: BaseEvent
Dispatched after the library ran any modal callback.
Source code in interactions/api/events/internal.py
177 178 179 180 181 |
|
ModalError
¶
Bases: _Error
Dispatched when the library encounters an error in a modal.
Source code in interactions/api/events/internal.py
222 223 224 225 226 |
|
Ready
¶
Bases: BaseEvent
The client is now ready.
Note
Don't use this event for things that must only happen once, on startup, as this event may be called multiple times. Instead, use the Startup
event
Source code in interactions/api/events/internal.py
120 121 122 123 124 125 126 127 128 129 |
|
Resume
¶
Bases: BaseEvent
The bot has resumed its connection to the discord Gateway.
Source code in interactions/api/events/internal.py
85 86 87 |
|
Select
¶
Bases: Component
Dispatched when a user uses a Select.
Source code in interactions/api/events/internal.py
151 152 153 |
|
ShardConnect
¶
Bases: Connect
A shard just connected to the discord Gateway.
Source code in interactions/api/events/internal.py
95 96 97 98 99 |
|
ShardDisconnect
¶
Bases: Disconnect
A shard just disconnected.
Source code in interactions/api/events/internal.py
102 103 104 105 106 |
|
Startup
¶
Bases: BaseEvent
The client is now ready for the first time.
Use this for tasks you want to do upon login, instead of ready, as this will only be called once.
Source code in interactions/api/events/internal.py
109 110 111 112 113 114 115 116 117 |
|
WebsocketReady
¶
Bases: RawGatewayEvent
The gateway has reported that it is ready.
Source code in interactions/api/events/internal.py
132 133 134 135 136 |
|