mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Changing the organization of the project
This commit is contained in:
parent
d67997140f
commit
3639ba3280
@ -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
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
discord.py
|
||||
discord.py[voice]
|
||||
youtube_dl
|
||||
PyNaCl
|
||||
spotipy
|
||||
@ -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))
|
||||
33
main.py
33
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)
|
||||
|
||||
@ -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 :/')
|
||||
@ -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']
|
||||
|
||||
@ -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):
|
||||
Loading…
x
Reference in New Issue
Block a user