jardiscordengine 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. jardiscordengine/__init__.py +300 -0
  2. jardiscordengine/__init__.pyi +91 -0
  3. jardiscordengine/bots/__init__.py +40 -0
  4. jardiscordengine/bots/__init__.pyi +13 -0
  5. jardiscordengine/bots/bot.py +379 -0
  6. jardiscordengine/bots/bot.pyi +196 -0
  7. jardiscordengine/commands/__init__.py +56 -0
  8. jardiscordengine/commands/__init__.pyi +29 -0
  9. jardiscordengine/commands/decorators.py +258 -0
  10. jardiscordengine/commands/decorators.pyi +181 -0
  11. jardiscordengine/constants.py +64 -0
  12. jardiscordengine/constants.pyi +25 -0
  13. jardiscordengine/entities/__init__.py +122 -0
  14. jardiscordengine/entities/__init__.pyi +93 -0
  15. jardiscordengine/entities/assets.py +151 -0
  16. jardiscordengine/entities/assets.pyi +136 -0
  17. jardiscordengine/entities/bots.py +306 -0
  18. jardiscordengine/entities/categories.py +106 -0
  19. jardiscordengine/entities/categories.pyi +69 -0
  20. jardiscordengine/entities/channels.py +149 -0
  21. jardiscordengine/entities/channels.pyi +135 -0
  22. jardiscordengine/entities/commands.py +242 -0
  23. jardiscordengine/entities/enums.py +69 -0
  24. jardiscordengine/entities/enums.pyi +54 -0
  25. jardiscordengine/entities/guilds.py +70 -0
  26. jardiscordengine/entities/guilds.pyi +40 -0
  27. jardiscordengine/entities/messages.py +101 -0
  28. jardiscordengine/entities/messages.pyi +50 -0
  29. jardiscordengine/entities/roles.py +70 -0
  30. jardiscordengine/entities/roles.pyi +40 -0
  31. jardiscordengine/entities/users.py +131 -0
  32. jardiscordengine/entities/users.pyi +100 -0
  33. jardiscordengine/entities/webhook.py +666 -0
  34. jardiscordengine/events/__init__.py +37 -0
  35. jardiscordengine/events/__init__.pyi +10 -0
  36. jardiscordengine/interns/__init__.py +56 -0
  37. jardiscordengine/interns/__init__.pyi +27 -0
  38. jardiscordengine/interns/base_classe.py +244 -0
  39. jardiscordengine/interns/base_classe.pyi +50 -0
  40. jardiscordengine/interns/config.py +391 -0
  41. jardiscordengine/interns/config.pyi +112 -0
  42. jardiscordengine/interns/debug.py +664 -0
  43. jardiscordengine/interns/debug.pyi +94 -0
  44. jardiscordengine/interns/decorators.py +691 -0
  45. jardiscordengine/interns/decorators.pyi +296 -0
  46. jardiscordengine/interns/enums.py +51 -0
  47. jardiscordengine/interns/enums.pyi +24 -0
  48. jardiscordengine/interns/extern.py +54 -0
  49. jardiscordengine/interns/extern.pyi +17 -0
  50. jardiscordengine/interns/final_classes.py +34 -0
  51. jardiscordengine/interns/final_classes.pyi +0 -0
  52. jardiscordengine/interns/helpers.py +197 -0
  53. jardiscordengine/interns/helpers.pyi +153 -0
  54. jardiscordengine/interns/high_classes.py +136 -0
  55. jardiscordengine/interns/high_classes.pyi +124 -0
  56. jardiscordengine/interns/log.py +162 -0
  57. jardiscordengine/interns/log.pyi +84 -0
  58. jardiscordengine/interns/low_classes.py +66 -0
  59. jardiscordengine/interns/low_classes.pyi +21 -0
  60. jardiscordengine/managers/__init__.py +42 -0
  61. jardiscordengine/managers/__init__.pyi +15 -0
  62. jardiscordengine/managers/command_manager.py +605 -0
  63. jardiscordengine/managers/command_manager.pyi +109 -0
  64. jardiscordengine/managers/guild_manager.py +432 -0
  65. jardiscordengine/managers/guild_manager.pyi +270 -0
  66. jardiscordengine/systems/__init__.py +50 -0
  67. jardiscordengine/systems/__init__.pyi +21 -0
  68. jardiscordengine/systems/bool.py +94 -0
  69. jardiscordengine/systems/bool.pyi +30 -0
  70. jardiscordengine/systems/color.py +161 -0
  71. jardiscordengine/systems/color.pyi +53 -0
  72. jardiscordengine/systems/enums.py +50 -0
  73. jardiscordengine/systems/enums.pyi +22 -0
  74. jardiscordengine/systems/env.py +71 -0
  75. jardiscordengine/systems/env.pyi +66 -0
  76. jardiscordengine/systems/version.py +126 -0
  77. jardiscordengine/systems/version.pyi +64 -0
  78. jardiscordengine/terminal/__init__.py +48 -0
  79. jardiscordengine/terminal/__init__.pyi +21 -0
  80. jardiscordengine/terminal/decorator.py +54 -0
  81. jardiscordengine/terminal/decorator.pyi +18 -0
  82. jardiscordengine/terminal/terminal.py +489 -0
  83. jardiscordengine/terminal/terminal.pyi +74 -0
  84. jardiscordengine-0.1.0.dist-info/METADATA +27 -0
  85. jardiscordengine-0.1.0.dist-info/RECORD +88 -0
  86. jardiscordengine-0.1.0.dist-info/WHEEL +5 -0
  87. jardiscordengine-0.1.0.dist-info/licenses/LICENSE +674 -0
  88. jardiscordengine-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,300 @@
1
+ # =============================================================================
2
+ # JarDiscordEngine - Python Discord Bot Engine (pycord-based)
3
+ # =============================================================================
4
+ #
5
+ # JarDiscordEngine is a lightweight bot framework built on top of pycord
6
+ # that simplifies Discord bot development while providing higher-level
7
+ # abstractions for command management, event handling, and extensibility.
8
+ #
9
+ # =============================================================================
10
+ # Version: jardiscordengine-v1
11
+ # Author: Jarjarbin Studio
12
+ # License: GPL v3
13
+ # =============================================================================
14
+ #
15
+ # This engine is inspired by pycord, modern bot framework design patterns,
16
+ # and modular software architecture.
17
+ #
18
+ # It is designed for educational purposes and small-to-medium Discord bot
19
+ # projects.
20
+ #
21
+ # It provides structured systems such as automatic command discovery,
22
+ # command registration, event handling, extension management, and shared
23
+ # services for logging, configuration, and permissions.
24
+ #
25
+ # =============================================================================
26
+ # WARNING:
27
+ # =============================================================================
28
+ #
29
+ # This is NOT pycord itself.
30
+ # It is a custom abstraction layer built on top of pycord.
31
+ #
32
+ # =============================================================================
33
+
34
+ from __future__ import annotations
35
+
36
+ import asyncio as _asyncio
37
+ import os as _os
38
+ import sys as _sys
39
+ from datetime import datetime as _datetime
40
+ from uuid import uuid4 as _uuid4
41
+
42
+ ##Metadata##
43
+ __author__ = "Nathan Jarjarbin"
44
+ __email__ = "nathan.amaraggi@epitech.eu"
45
+ __version__ = "0.1.0"
46
+ __config_version__ = "0.1.0"
47
+ __license__ = "GPL"
48
+
49
+ ##Imports##
50
+ import jardiscordengine.bots as Bots
51
+ import jardiscordengine.commands as Commands
52
+ import jardiscordengine.entities as Entities
53
+ import jardiscordengine.events as Events
54
+ import jardiscordengine.interns as Interns
55
+ import jardiscordengine.managers as Managers
56
+ import jardiscordengine.systems as Systems
57
+ import jardiscordengine.terminal as Terminals
58
+ from jardiscordengine.constants import *
59
+
60
+ ##Lifetime##
61
+ _start_time = None
62
+ _session = None
63
+
64
+ def init(project_path):
65
+ global _start_time, _session
66
+
67
+ Text = Interns.Externs.JTKExternConsole.Text
68
+
69
+ _start_time = _datetime.now()
70
+ _session = _uuid4().hex
71
+
72
+ project_path = project_path.removesuffix("/")
73
+
74
+ Systems.JDEEnv.load(f"{project_path}/.env")
75
+
76
+ Interns.Config.JDEInternConfig.project_path = f"{project_path}"
77
+ Interns.Config.JDEInternConfig.config_path = f"{project_path}/.jde-config"
78
+ Interns.Config.JDEInternConfig.state_path = f"{project_path}/.jde-state"
79
+
80
+ Interns.Log.JDEInternLog.project_path = f"{project_path}"
81
+ Interns.Log.JDEInternLog.log_path = f"{project_path}/.jde-log"
82
+
83
+ Interns.Config.init_all()
84
+
85
+ Interns.Log.JDEInternLog("jde-log", _session=_session) # pyright: ignore[reportCallIssue]
86
+
87
+ name = Interns.Config.get("project", "PROJECT", "name", str, "Unnamed project")
88
+ description = Interns.Config.get(
89
+ "project", "PROJECT", "description", str, "No description"
90
+ )
91
+ version = Interns.Config.get("project", "PROJECT", "version", str, "0.0.0")
92
+ author = Interns.Config.get("project", "AUTHOR", "name", str, None)
93
+ organization = Interns.Config.get("project", "AUTHOR", "organization", str, None)
94
+
95
+ width = (Interns.Externs.JTKExternConsole.Console.Console.width() or 85) - 5
96
+
97
+ sep = Text("───").f_layout_pad_center(width)
98
+
99
+ top = Text(f"{_title_color(name)} {_version_color(version)}").f_layout_align_center(
100
+ width
101
+ )
102
+
103
+ center = Text(f"{description}").f_layout_align_center(width)
104
+
105
+ bottom = Text(
106
+ f"Made by: {author}" + (f" ({organization})" if organization else "")
107
+ ).f_layout_align_center(width)
108
+
109
+ Interns.Externs.JTKExternConsole.Console.Console.print(
110
+ Text(f"{top}\n{sep}\n{center}\n{sep}\n{bottom}").f_border_box(
111
+ border=Interns.Externs.JTKExternConsole.PresetBorder.ROUND, padding=0
112
+ ),
113
+ end="\n\n",
114
+ )
115
+
116
+ if not Interns.Config.get("state", "LAST_RUN", "clean_exit", bool, True):
117
+ Interns.Helpers.warning(
118
+ Interns.Externs.JTKExternError.JErrorRuntime("Previous run crashed")
119
+ )
120
+
121
+ Interns.Config.set("state", "LAST_RUN", "start", _start_time)
122
+ Interns.Config.set("state", "LAST_RUN", "clean_exit", False)
123
+ Interns.Config.set(
124
+ "state",
125
+ "SESSION",
126
+ "launches",
127
+ Interns.Config.get("state", "SESSION", "launches", int, 0) + 1,
128
+ )
129
+ Interns.Config.set("state", "SESSION", "id", _session)
130
+ Interns.Config.check_compatibility()
131
+
132
+ Interns.Log.log(
133
+ "INFO",
134
+ "ENGINE",
135
+ f"JarDiscordEngine version {JDEVersion_JarDiscordEngine} initialized",
136
+ )
137
+ Interns.Log.log("INFO", "ENGINE", f"Current session: {_session}")
138
+
139
+ Interns.Log.save()
140
+
141
+ @Interns.Decorators.requires_init
142
+ def quit():
143
+ global _session, _start_time
144
+
145
+ if _start_time is None or _session is None:
146
+ return
147
+
148
+ _end = _datetime.now()
149
+ duration = (_end - _start_time).total_seconds()
150
+
151
+ Interns.Config.set("state", "LAST_RUN", "end", _end)
152
+ Interns.Config.set("state", "LAST_RUN", "duration", duration)
153
+
154
+ total_runtime = Interns.Config.get(
155
+ "state", "STATISTICS", "total_runtime", float, 0.0
156
+ )
157
+ launches = Interns.Config.get("state", "SESSION", "launches", int, 1)
158
+ longest_session = Interns.Config.get(
159
+ "state", "STATISTICS", "longest_session", float, 0.0
160
+ )
161
+ shortest_session = Interns.Config.get(
162
+ "state", "STATISTICS", "shortest_session", float, 0.0
163
+ )
164
+
165
+ new_total_runtime = total_runtime + duration # pyright: ignore[reportOperatorIssue]
166
+ average_session = new_total_runtime / launches
167
+
168
+ longest_session = max(longest_session, duration)
169
+
170
+ if shortest_session == 0 or duration < shortest_session: # pyright: ignore[reportOperatorIssue]
171
+ shortest_session = duration
172
+
173
+ Interns.Config.set("state", "STATISTICS", "total_runtime", new_total_runtime)
174
+ Interns.Config.set("state", "STATISTICS", "average_session", average_session)
175
+ Interns.Config.set("state", "STATISTICS", "longest_session", longest_session)
176
+ Interns.Config.set("state", "STATISTICS", "shortest_session", shortest_session)
177
+
178
+ Interns.Log.log("INFO", "ENGINE", "Engine quit")
179
+ Interns.Log.save()
180
+ Interns.Log.close()
181
+
182
+ Interns.Config.set("state", "LAST_RUN", "clean_exit", True)
183
+
184
+ _start_time = None
185
+ _session = None
186
+
187
+ @Interns.Decorators.requires_init
188
+ @Interns.Decorators.logged(title="Run call")
189
+ @Interns.Decorators.timed(title="Run timing")
190
+ @Interns.Decorators.handle_errors(reraise=True)
191
+ def run(main):
192
+ while True:
193
+ try:
194
+ _asyncio.run(main())
195
+ return
196
+
197
+ except Terminals.JDETerminalRestart:
198
+ Interns.Log.log("INFO", "ENGINE", "Restart requested")
199
+
200
+ except Exception as error: # noqa: BLE001
201
+ Interns.Helpers.critical(error)
202
+ return
203
+
204
+ Interns.Log.log("INFO", "ENGINE", "Quitting engine for restart")
205
+ Interns.Log.log("INFO", "ENGINE", "Restarting application process")
206
+
207
+ Interns.Externs.JTKExternConsole.ANSI.Screen.ScreenErase.erase_display()
208
+
209
+ quit()
210
+
211
+ _os.execv(
212
+ _sys.executable,
213
+ [_sys.executable, *_sys.argv],
214
+ )
215
+
216
+ ##Special##
217
+ def _title_color(title):
218
+
219
+ return Interns.Externs.JTKExternConsole.Text(title).f_color_foreground(
220
+ Interns.Externs.JTKExternConsole.ColorRGB(70, 160, 255)
221
+ )
222
+
223
+ def _subtitle_color(title):
224
+
225
+ return Interns.Externs.JTKExternConsole.Text(title).f_color_foreground(
226
+ Interns.Externs.JTKExternConsole.ColorRGB(47, 107, 170)
227
+ )
228
+
229
+ def _version_color(version):
230
+
231
+ return Interns.Externs.JTKExternConsole.Text(version).f_color_foreground(
232
+ Interns.Externs.JTKExternConsole.ColorRGB(150, 150, 150)
233
+ )
234
+
235
+ def _banner():
236
+ Text = Interns.Externs.JTKExternConsole.Text
237
+ Cursor = Interns.Externs.JTKExternConsole.ANSI.Cursor.CursorPosition
238
+ Screen = Interns.Externs.JTKExternConsole.ANSI.Screen.ScreenErase
239
+
240
+ width = (Interns.Externs.JTKExternConsole.Console.Console.width() or 85) - 5
241
+
242
+ sep = Text("───").f_layout_pad_center(width)
243
+
244
+ top = Text(
245
+ f"{_title_color('JarDiscordEngine (JDE)')} {_version_color(__version__)}"
246
+ ).f_layout_align_center(width)
247
+
248
+ center = Text(
249
+ f"{_subtitle_color('Config')} {_version_color(JDEVersion_Config)} ─ "
250
+ f"{_subtitle_color('Py-Cord')} {_version_color(JDEVersion_Discord)} ─ "
251
+ f"{_subtitle_color('Python')} {_version_color(JDEVersion_Python)}"
252
+ ).f_layout_align_center(width)
253
+
254
+ bottom = Text("Discord bot development framework").f_layout_align_center(width)
255
+
256
+ Interns.Externs.JTKExternConsole.ANSI.Screen.ScreenErase.erase_display()
257
+ Interns.Externs.JTKExternConsole.Console.Console.print(
258
+ (f"{Cursor.previous_line() + Screen.erase_line()}" * 2)
259
+ + Text(f"{top}\n{sep}\n{center}\n{sep}\n{bottom}").f_border_box(
260
+ border=Interns.Externs.JTKExternConsole.PresetBorder.ROUND, padding=0
261
+ ),
262
+ end="\n\n",
263
+ )
264
+
265
+ def _validate_all_instance_policies() -> None:
266
+ for subclass in Interns.JDEInternBaseClass.__subclasses__():
267
+ subclass.validate_instance_policies() # pyright: ignore[reportAttributeAccessIssue]
268
+
269
+ __all__ = [ # noqa: RUF022
270
+ ## Special ##
271
+ "__author__",
272
+ "__email__",
273
+ "__version__",
274
+ "__license__",
275
+ ## Imports ##
276
+ "Bots",
277
+ "Commands",
278
+ "Entities",
279
+ "Events",
280
+ "Interns",
281
+ "Managers",
282
+ "Systems",
283
+ "Terminals",
284
+ ## Constants ##
285
+ # Versions #
286
+ "JDEVersion_JarDiscordEngine",
287
+ "JDEVersion_Config",
288
+ "JDEVersion_Discord",
289
+ "JDEVersion_Python",
290
+ # Booleans #
291
+ "JDEFalse",
292
+ "JDETrue",
293
+ ## Lifetime ##
294
+ "init",
295
+ "run",
296
+ "quit",
297
+ ]
298
+
299
+ _banner()
300
+ _validate_all_instance_policies()
@@ -0,0 +1,91 @@
1
+ """
2
+ JarDiscordEngine - Python Discord Bot Engine
3
+
4
+ Main public API for JarDiscordEngine.
5
+
6
+ Provides the core interfaces and utilities used
7
+ to develop Discord bots with JarDiscordEngine.
8
+
9
+ Built on top of Pycord, JDE provides higher-level abstractions for
10
+ bot management, commands, events, entities.
11
+
12
+ This package exposes the framework's public API and serves as the
13
+ main entry point for bot development.
14
+ """
15
+
16
+ ##Metadata##
17
+ __author__: str
18
+ __email__: str
19
+ __version__: str
20
+ __config_version__: str
21
+ __license__: str
22
+
23
+ ##Imports##
24
+ from collections.abc import Awaitable, Callable
25
+
26
+ from . import bots as Bots
27
+ from . import commands as Commands
28
+ from . import entities as Entities
29
+ from . import events as Events
30
+ from . import interns as Interns
31
+ from . import managers as Managers
32
+ from . import systems as Systems
33
+ from . import terminal as Terminals
34
+ from .constants import *
35
+
36
+ ##Lifetime##
37
+ def init(
38
+ project_path: str
39
+ ) -> None:
40
+ """
41
+ Initialize engine and its internal components.
42
+
43
+ Args:
44
+ project_path (str): Path to project root.
45
+ """
46
+
47
+ @Interns.Decorators.requires_init
48
+ def quit() -> None:
49
+ """Quit/uninitialize the engine."""
50
+
51
+ @Interns.Decorators.requires_init
52
+ @Interns.Decorators.handle_errors
53
+ def run(
54
+ main: Callable[[], Awaitable[None]]
55
+ ) -> None:
56
+ """
57
+ Run a main within engine handling capacity.
58
+
59
+ Args:
60
+ main (Callable[[], None]): Main to run.
61
+ """
62
+
63
+ __all__ = [ # noqa: RUF022
64
+ ## Special ##
65
+ "__author__",
66
+ "__email__",
67
+ "__version__",
68
+ "__license__",
69
+ ## Imports ##
70
+ "Bots",
71
+ "Commands",
72
+ "Entities",
73
+ "Events",
74
+ "Interns",
75
+ "Managers",
76
+ "Systems",
77
+ "Terminals",
78
+ ## Constants ##
79
+ # Versions #
80
+ "JDEVersion_JarDiscordEngine",
81
+ "JDEVersion_Config",
82
+ "JDEVersion_Discord",
83
+ "JDEVersion_Python",
84
+ # Booleans #
85
+ "JDEFalse",
86
+ "JDETrue",
87
+ ## Lifetime ##
88
+ "init",
89
+ "run",
90
+ "quit",
91
+ ]
@@ -0,0 +1,40 @@
1
+ # =============================================================================
2
+ # JarDiscordEngine - Python Discord Bot Engine (pycord-based)
3
+ # =============================================================================
4
+ #
5
+ # JarDiscordEngine is a lightweight bot framework built on top of pycord
6
+ # that simplifies Discord bot development while providing higher-level
7
+ # abstractions for command management, event handling, and extensibility.
8
+ #
9
+ # =============================================================================
10
+ # Version: jardiscordengine-v1
11
+ # Author: Jarjarbin Studio
12
+ # License: GPL v3
13
+ # =============================================================================
14
+ #
15
+ # This engine is inspired by pycord, modern bot framework design patterns,
16
+ # and modular software architecture.
17
+ #
18
+ # It is designed for educational purposes and small-to-medium Discord bot
19
+ # projects.
20
+ #
21
+ # It provides structured systems such as automatic command discovery,
22
+ # command registration, event handling, extension management, and shared
23
+ # services for logging, configuration, and permissions.
24
+ #
25
+ # =============================================================================
26
+ # WARNING:
27
+ # =============================================================================
28
+ #
29
+ # This is NOT pycord itself.
30
+ # It is a custom abstraction layer built on top of pycord.
31
+ #
32
+ # =============================================================================
33
+
34
+ from __future__ import annotations
35
+
36
+ from jardiscordengine.bots.bot import JDEBot
37
+
38
+ __all__ = [
39
+ "JDEBot",
40
+ ]
@@ -0,0 +1,13 @@
1
+ """
2
+ JarDiscordEngine - Bots
3
+
4
+ Bot creation and bot-related handling.
5
+ """
6
+
7
+ from collections.abc import Sequence
8
+
9
+ from .bot import JDEBot as JDEBot
10
+
11
+ __all_: Sequence[str] = [
12
+ "JDEBot",
13
+ ]