mirror of
https://github.com/zoriya/Nemo.git
synced 2026-05-30 17:18:08 +00:00
Creating the basics of the architecture and the setup command
This commit is contained in:
+2
-1
@@ -1,2 +1,3 @@
|
||||
.idea/
|
||||
venv/
|
||||
venv/
|
||||
__pycache__/
|
||||
@@ -0,0 +1,40 @@
|
||||
TOKEN = "ENTER YOUR DISCORD TOKEN HERE"
|
||||
|
||||
CATEGORY_NAME = "EVENTS"
|
||||
ORGANIZATION_NAME = "organization"
|
||||
|
||||
|
||||
|
||||
HELP_MSG = """Blop... Blop... Bonjour, je suis Nemo, le poisson qui a plus de mémoire que toi. Voici les actions que je peut faire :
|
||||
|
||||
__**Actions pour les utilisateurs:**__
|
||||
|
||||
Je peux aussi créer des votes aux réponse Oui ou Non pour vos message. Pour cela, ajouter a la fin de vos message```:vote:```
|
||||
Ca fonctionne aussi pour des votes a 4 choix. Pour cela, ajouter a la fin de vos message```:vote-4:```
|
||||
|
||||
__**Actions pour tous les events:**__
|
||||
|
||||
Ouvrir l'event a tous le monde```!open [message]```
|
||||
Rendre l'event privé et inviter les personnes individuellement```!private```
|
||||
Renomer le channel de l'event```!name [nom-sans-espace]```
|
||||
Stopper l'event```!stop```
|
||||
|
||||
__**Actions pour les events privée:**__
|
||||
|
||||
Ajouter quelqu'un sur la liste des participants ```!invite @username [@username ...]```
|
||||
Enlever un joueur de la liste des participants```!kick @username [@username ...]```
|
||||
Ajouter un organisateur : ```!colab @username [@username ...]```
|
||||
|
||||
@username correspond a un utilisateur, par exemple @Me et ce qui se trouve entre crochets est optionel.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
EVENT_LIST = """**Liste des events ouverts:**
|
||||
|
||||
**Aucun event ouvert.**
|
||||
"""
|
||||
|
||||
CREATE_MSG = """**Créer un event: **
|
||||
Pour créer un event, click sur ✅
|
||||
"""
|
||||
@@ -0,0 +1,8 @@
|
||||
def auto_delete(f):
|
||||
async def wrapper(*args, **kwargs):
|
||||
ret = await f(*args, **kwargs)
|
||||
await kwargs["message"].delete()
|
||||
return ret
|
||||
|
||||
return wrapper
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
import nemo
|
||||
import helper
|
||||
import config
|
||||
import discord
|
||||
from discord.ext.commands import has_permissions
|
||||
|
||||
nemo = nemo.Nemo()
|
||||
|
||||
|
||||
@nemo.command("!")
|
||||
@has_permissions(administrator=True)
|
||||
async def setup(_, message: discord.Message, guild: discord.Guild, **kwargs):
|
||||
if any(x.name == config.CATEGORY_NAME and x.type == discord.ChannelType.category for x in guild.channels):
|
||||
return
|
||||
category = await guild.create_category(config.CATEGORY_NAME)
|
||||
organization = await guild.create_text_channel(config.ORGANIZATION_NAME, overwrites={
|
||||
guild.default_role: discord.PermissionOverwrite(send_messages=False),
|
||||
guild.me: discord.PermissionOverwrite(send_messages=True)
|
||||
}, category=category)
|
||||
await help_msg(organization)
|
||||
await message.delete()
|
||||
|
||||
|
||||
@nemo.command("!help")
|
||||
@has_permissions(administrator=True)
|
||||
@helper.auto_delete
|
||||
async def help_command(_, message: discord.Message, **kwargs):
|
||||
await help_msg(message.channel)
|
||||
|
||||
|
||||
async def help_msg(channel: discord.TextChannel):
|
||||
await channel.send(config.HELP_MSG.replace("@Me", f"<@{nemo.user.id}>"))
|
||||
msg = await channel.send(config.EVENT_LIST)
|
||||
await msg.add_reaction("🔢")
|
||||
msg = await channel.send(config.CREATE_MSG)
|
||||
await msg.add_reaction("✅")
|
||||
|
||||
if __name__ == "__main__":
|
||||
nemo.run(config.TOKEN)
|
||||
@@ -1,16 +1,29 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import traceback
|
||||
import discord
|
||||
import os
|
||||
|
||||
|
||||
class Client(discord.Client):
|
||||
class Nemo(discord.Client):
|
||||
def __init__(self, **options):
|
||||
super().__init__(**options)
|
||||
self.commands = {}
|
||||
|
||||
async def on_ready(self):
|
||||
print(f"Logged in as {self.user}.")
|
||||
|
||||
async def on_message(self):
|
||||
pass
|
||||
async def on_message(self, message: discord.Message):
|
||||
cmd = message.content.split()
|
||||
f = self.commands.get(cmd[0])
|
||||
if f is None:
|
||||
return
|
||||
print(f"{message.author.display_name} used the command: '{cmd[0]}'")
|
||||
try:
|
||||
await f(cmd[1::], message=message, guild=message.guild)
|
||||
except Exception:
|
||||
await message.channel.send(f"Fatal error: {traceback.format_exc()}")
|
||||
raise
|
||||
|
||||
|
||||
client = Client()
|
||||
client.login(os.environ["NEMO_TOKEN"])
|
||||
def command(self, cmd):
|
||||
def wrapper(f):
|
||||
self.commands[cmd] = f
|
||||
return f
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user