diff --git a/config/config.py b/config/config.py index 9f838b3..e531c56 100644 --- a/config/config.py +++ b/config/config.py @@ -6,7 +6,8 @@ SPOTIFY_ID = dotenv_values('.env')['SPOTIFY_ID'] SPOTIFY_SECRET = dotenv_values('.env')['SPOTIFY_SECRET'] BOT_PREFIX = '!' -INITIAL_EXTENSIONS = {'cogs'} +INITIAL_EXTENSIONS = {'vulkan.commands.Phrases', 'vulkan.commands.Warframe', + 'vulkan.general.Filter', 'vulkan.general.Control', 'vulkan.music.Music'} VC_TIMEOUT = 600 # seconds VC_TIMEOUT_DEFAULT = True diff --git a/requirements.txt b/config/requirements.txt similarity index 85% rename from requirements.txt rename to config/requirements.txt index 821e985..595d4e8 100644 --- a/requirements.txt +++ b/config/requirements.txt @@ -1,4 +1,4 @@ discord.py discord.py[voice] youtube_dl -PyNaCl +spotipy \ No newline at end of file diff --git a/extensions/commands/Talk.py b/extensions/commands/Talk.py deleted file mode 100644 index 2468478..0000000 --- a/extensions/commands/Talk.py +++ /dev/null @@ -1,20 +0,0 @@ -from discord.ext import commands - - -class Talks(commands.Cog): - """Deal with talks to users""" - - def __init__(self, bot): - self.__bot = bot - - @property - def bot(self): - return self.__bot - - @bot.setter - def bot(self, newBot): - self.__bot = newBot - - -def setup(bot): - bot.add_cog(Talks(bot)) diff --git a/main.py b/main.py index 0dbf4f2..5eacf38 100644 --- a/main.py +++ b/main.py @@ -1,23 +1,30 @@ import os import discord -from dotenv import dotenv_values + +from config import config from discord.ext import commands -TOKEN_BOT = dotenv_values('.env')['TOKEN_BOT'] intents = discord.Intents.default() intents.members = True -client = commands.Bot(command_prefix="!", - case_insensitive=True, intents=intents) -client.remove_command('help') +bot = commands.Bot(command_prefix=config.BOT_PREFIX, pm_help=True, + case_insensitive=True, intents=intents) +bot.remove_command('help') + +if __name__ == '__main__': + config.ABSOLUTE_PATH = os.path.dirname(os.path.abspath(__file__)) + config.COOKIE_PATH = config.ABSOLUTE_PATH + config.COOKIE_PATH + + if config.BOT_TOKEN == "": + print("Error: No bot token!") + exit() + + for extension in config.INITIAL_EXTENSIONS: + try: + bot.load_extension(extension) + except Exception as e: + print(e) -def load_cogs(bot): - for filename in os.listdir('cogs'): - if filename.endswith('.py'): - bot.load_extension(f'cogs.{filename[:-3]}') - - -load_cogs(client) -client.run(TOKEN_BOT) +bot.run(config.BOT_TOKEN, bot=True, reconnect=True) diff --git a/extensions/general/ErrorHandler.py b/vulkan/ErrorHandler.py similarity index 100% rename from extensions/general/ErrorHandler.py rename to vulkan/ErrorHandler.py diff --git a/extensions/commands/Phrases.py b/vulkan/commands/Phrases.py similarity index 86% rename from extensions/commands/Phrases.py rename to vulkan/commands/Phrases.py index 6900427..b9513b9 100644 --- a/extensions/commands/Phrases.py +++ b/vulkan/commands/Phrases.py @@ -40,10 +40,6 @@ class Phrases(commands.Cog): break except json.decoder.JSONDecodeError: continue - except discord.errors.Forbidden as e: - print(e) - await ctx.channel.send('Não posso te enviar a frase, habilite para receber mensagens de qualquer pessoa no servidor (Opções > Privacidade)') - break except Exception as e: print(e) await ctx.channel.send('Houve um erro inesperado :/') diff --git a/extensions/commands/Warframe.py b/vulkan/commands/Warframe.py similarity index 92% rename from extensions/commands/Warframe.py rename to vulkan/commands/Warframe.py index 17189ba..dca4bb7 100644 --- a/extensions/commands/Warframe.py +++ b/vulkan/commands/Warframe.py @@ -3,7 +3,7 @@ import json import discord from dotenv import dotenv_values from discord.ext import commands -CETUS_API = dotenv_values('.env')['CETUS_API'] +from config import config class Warframe(commands.Cog): @@ -23,7 +23,7 @@ class Warframe(commands.Cog): @commands.command(name='cetus', help='Informa o tempo atual de Cetus - Warframe') async def get_cetus(self, ctx): try: - response = requests.get(CETUS_API) + response = requests.get(config.CETUS_API) data = json.loads(response.content) short = data['shortString'] diff --git a/extensions/general/Control.py b/vulkan/general/Control.py similarity index 76% rename from extensions/general/Control.py rename to vulkan/general/Control.py index c612c4b..12849cf 100644 --- a/extensions/general/Control.py +++ b/vulkan/general/Control.py @@ -1,5 +1,7 @@ +import discord from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument from discord.ext import commands +from config import config class Control(commands.Cog): @@ -18,7 +20,9 @@ class Control(commands.Cog): @commands.Cog.listener() async def on_ready(self): - print(f'Bot {self.__bot.user.name} inicializado') + print(config.STARTUP_MESSAGE) + await self.__bot.change_presence(status=discord.Status.online, activity=discord.Game(name=f"Vulkan | type {config.BOT_PREFIX}help")) + print(config.STARTUP_COMPLETE_MESSAGE) @commands.Cog.listener() async def on_command_error(self, ctx, error): diff --git a/extensions/commands/Filter.py b/vulkan/general/Filter.py similarity index 100% rename from extensions/commands/Filter.py rename to vulkan/general/Filter.py diff --git a/extensions/music/music.py b/vulkan/music/Music.py similarity index 100% rename from extensions/music/music.py rename to vulkan/music/Music.py