Pārlūkot izejas kodu

modifying commands list

tenessy0570 3 gadi atpakaļ
vecāks
revīzija
87513e3d0b
3 mainītis faili ar 11 papildinājumiem un 3 dzēšanām
  1. 2 3
      __init__.py
  2. 2 0
      commands_list_divided_with_newline
  3. 7 0
      utils.py

+ 2 - 3
__init__.py

@@ -3,11 +3,11 @@ from os import environ
 import environment_vars
 from decorators import author_is_not_bot
 from img_urls import good_face_url
-from utils import on_ready_print, receive_message_then_send
+from utils import on_ready_print, receive_message_then_send, get_commands_from_file
 
 
 class MyClient(discord.Client):
-    _help_commands = ['face', 'ping']
+    _help_commands = get_commands_from_file("commands_list_divided_with_newline")
     _help_commands_for_output = ('~ ' + command for command in _help_commands)
     _help_commands_for_output = '\n'.join(_help_commands_for_output)
 
@@ -16,7 +16,6 @@ class MyClient(discord.Client):
 
     @author_is_not_bot
     async def on_message(self, message):
-
         if await receive_message_then_send(message, "ping", "pong"):
             return
 

+ 2 - 0
commands_list_divided_with_newline

@@ -0,0 +1,2 @@
+face
+ping

+ 7 - 0
utils.py

@@ -11,3 +11,10 @@ async def receive_message_then_send(message, received: str, to_send="") -> None:
         if to_send:
             await message.channel.send(to_send)
         return True
+
+
+def get_commands_from_file(filename: str) -> tuple:
+    _help_commands: tuple
+    with open(filename, 'r') as file:
+        _help_commands = tuple((command.split('\n')[0] for command in file))
+    return _help_commands