diff --git a/.gitignore b/.gitignore
index a20dcb2..20f8f40 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
.env
launch.sh
-src/bot/__pycache__
-src/commands/__pycache__
\ No newline at end of file
+src/**/__pycache__
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/CompteurElectrique.iml b/.idea/CompteurElectrique.iml
deleted file mode 100644
index 92f6064..0000000
--- a/.idea/CompteurElectrique.iml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index f99f665..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index d04c501..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/bot/__init__.py b/src/bot/__init__.py
index 3c32b91..79edeb6 100644
--- a/src/bot/__init__.py
+++ b/src/bot/__init__.py
@@ -1,7 +1,3 @@
"""
Bot package - Discord bot manager
"""
-
-__all__ = ["setup_bot", "start_bot"]
-
-from .bot import *
diff --git a/src/bot/bot.py b/src/bot/bot.py
index 9b1b4af..482d77e 100644
--- a/src/bot/bot.py
+++ b/src/bot/bot.py
@@ -1,34 +1,40 @@
import discord
from discord.ext import commands
+# Dotenv managing
from dotenv import load_dotenv
from os import getenv
-from commands.discord_commands import *
+# Import managers
-def setup_bot() -> commands.Bot:
- print("Configuring bot...")
- load_dotenv()
+# Bot main class
+class Bot:
+ def __init__(self):
+ self.client = commands.Bot(command_prefix="/", intents=discord.Intents.all())
+ from todos_manager import TodosManager
+ self.todos_manager = TodosManager()
- bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())
+ def setup_bot(self) -> None:
+ print("Configuring bot...")
- @bot.event
- async def on_ready():
- try:
- synced = await bot.tree.sync()
- print(f"Successfully synced {len(synced)} commands")
- except Exception as e:
- print(e)
- print("Bot ready !")
+ load_dotenv()
- setup_commands(bot)
+ @self.client.event
+ async def on_ready() -> None:
+ try:
+ synced = await self.client.tree.sync()
+ print(f"Successfully synced {len(synced)} commands")
+ except Exception as e:
+ print(e)
+ print("Bot ready !")
- return bot
+ from commands_manager import setup_commands
+ setup_commands(self)
-def start_bot(bot: commands.Bot) -> None:
- print("Starting bot...")
- token = getenv("DISCORD_TOKEN")
- if token:
- bot.run(token)
- else:
- print("token error")
+ def start_bot(self) -> None:
+ print("Starting bot...")
+ token = getenv("DISCORD_TOKEN")
+ if token:
+ self.client.run(token)
+ else:
+ print("token error")
diff --git a/src/commands/__init__.py b/src/commands/__init__.py
deleted file mode 100644
index 0f8fbac..0000000
--- a/src/commands/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""
-Commands package - Discord commands manager
-"""
-
-__all__ = ["setup_commands"]
-
-from .discord_commands import *
diff --git a/src/commands/discord_commands.py b/src/commands/discord_commands.py
deleted file mode 100644
index 1c76e76..0000000
--- a/src/commands/discord_commands.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import discord
-from discord.ext import commands
-
-def setup_commands(bot: commands.Bot) -> None:
- @bot.tree.command(name="trustme", description="Come on, shake your body baby.")
- async def trustme(interaction: discord.Interaction):
- await interaction.response.send_message("https://matias.ma/nsfw/")
diff --git a/src/commands_manager/__init__.py b/src/commands_manager/__init__.py
new file mode 100644
index 0000000..44bfec9
--- /dev/null
+++ b/src/commands_manager/__init__.py
@@ -0,0 +1,7 @@
+"""
+Commands package - Discord commands_manager manager
+"""
+
+__all__ = ["setup_commands"]
+
+from .commands_manager import *
diff --git a/src/commands_manager/commands_manager.py b/src/commands_manager/commands_manager.py
new file mode 100644
index 0000000..4bd69b5
--- /dev/null
+++ b/src/commands_manager/commands_manager.py
@@ -0,0 +1,12 @@
+import discord
+from bot.bot import Bot
+
+# Import specifics commands
+from todos_manager.todos_commands import *
+
+def setup_commands(bot: Bot) -> None:
+ @bot.client.tree.command(name="trustme", description="Come on, shake your body baby.")
+ async def trustme(interaction: discord.Interaction):
+ await interaction.response.send_message("https://matias.ma/nsfw/")
+
+ setup_todos_manager_commands(bot)
diff --git a/src/main.py b/src/main.py
index 09b1d5d..230f715 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,13 +1,10 @@
import discord
-from bot import *
+from bot.bot import Bot
-bot = setup_bot()
+bot = Bot()
+bot.setup_bot()
-#bot = discord.Client(intents=discord.Intents.all())
-
-#bot_channel = bot.get_channel(1424301304225857667)
-
-@bot.event
+@bot.client.event
async def on_message(message: discord.Message):
if message.author.bot:
return
@@ -31,7 +28,7 @@ async def on_message(message: discord.Message):
await channel.send("le C++ c'est trow coool ╰(°ㅂ°)╯")
def main():
- start_bot(bot)
+ bot.start_bot()
if __name__ == "__main__":
main()
\ No newline at end of file
diff --git a/src/todos_manager/__init__.py b/src/todos_manager/__init__.py
new file mode 100644
index 0000000..d494736
--- /dev/null
+++ b/src/todos_manager/__init__.py
@@ -0,0 +1,7 @@
+"""
+Todos manager package - Todos manager
+"""
+
+__all__ = ["TodosManager"]
+
+from .todos_manager import *
diff --git a/src/todos_manager/todos_commands.py b/src/todos_manager/todos_commands.py
new file mode 100644
index 0000000..3d90859
--- /dev/null
+++ b/src/todos_manager/todos_commands.py
@@ -0,0 +1,7 @@
+from bot.bot import Bot
+
+# Manager controlled by
+from todos_manager import *
+
+def setup_todos_manager_commands(bot: Bot):
+ pass
diff --git a/src/todos_manager/todos_manager.py b/src/todos_manager/todos_manager.py
new file mode 100644
index 0000000..4bcb207
--- /dev/null
+++ b/src/todos_manager/todos_manager.py
@@ -0,0 +1,10 @@
+import os
+
+class TodosManager:
+ def __init__(self, data_dir="compteur_electrique_data/todos/"):
+ try:
+ os.makedirs(data_dir, exist_ok=True)
+ except OSError as error:
+ print(f"Error during creation of \"{data_dir}\" directory")
+ exit(1)
+ self.data_dir=data_dir