Changing file organization

This commit is contained in:
Rafael Vargas 2021-12-24 13:11:43 -04:00
parent 9eda65886e
commit d67997140f
9 changed files with 81 additions and 36 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
__pycache__
examples
.env
.env
errors

View File

@ -1,34 +0,0 @@
from discord.ext.commands.errors import CommandNotFound, MissingRequiredArgument
from discord.ext import commands
class Control(commands.Cog):
"""Control the flow of the Bot"""
def __init__(self, bot):
self.__bot = bot
@property
def bot(self):
return self.__bot
@bot.setter
def bot(self, newBot):
self.__bot = newBot
@commands.Cog.listener()
async def on_ready(self):
print(f'Bot {self.__bot.user.name} inicializado')
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, MissingRequiredArgument):
await ctx.channel.send(f'Falta argumentos. Digite {self.__bot.prefix}help para ver os comandos')
elif isinstance(error, CommandNotFound):
await ctx.channel.send(f'O comando não existe')
else:
raise error
def setup(bot):
bot.add_cog(Control(bot))

63
config/config.py Normal file
View File

@ -0,0 +1,63 @@
from dotenv import dotenv_values
CETUS_API = dotenv_values('.env')['CETUS_API']
BOT_TOKEN = dotenv_values('.env')['BOT_TOKEN']
SPOTIFY_ID = dotenv_values('.env')['SPOTIFY_ID']
SPOTIFY_SECRET = dotenv_values('.env')['SPOTIFY_SECRET']
BOT_PREFIX = '!'
INITIAL_EXTENSIONS = {'cogs'}
VC_TIMEOUT = 600 # seconds
VC_TIMEOUT_DEFAULT = True
STARTUP_MESSAGE = 'Starting Vulkan...'
STARTUP_COMPLETE_MESSAGE = 'Vulkan is now operating.'
USER_NOT_IN_VC_MESSAGE = "Error: Please join the active voice channel to use this command"
NOT_CONNECTED_MESSAGE = "Error: Bot not connected to any voice channel"
ALREADY_CONNECTED_MESSAGE = "Error: Already connected to a voice channel"
CHANNEL_NOT_FOUND_MESSAGE = "Error: Could not find channel"
INFO_HISTORY_TITLE = "Songs Played:"
MAX_HISTORY_LENGTH = 10
MAX_TRACKNAME_HISTORY_LENGTH = 15
SONGINFO_UPLOADER = "Uploader: "
SONGINFO_DURATION = "Duration: "
SONGINFO_SECONDS = "s"
SONGINFO_LIKES = "Likes: "
SONGINFO_DISLIKES = "Dislikes: "
SONGINFO_NOW_PLAYING = "Now Playing"
SONGINFO_QUEUE_ADDED = "Added to queue"
SONGINFO_SONGINFO = "Song info"
SONGINFO_PLAYLIST_QUEUED = "Queued playlist :page_with_curl:"
SONGINFO_UNKNOWN_DURATION = "Unknown"
HELP_HISTORY_LONG = "Shows the " + \
str(MAX_TRACKNAME_HISTORY_LENGTH) + " last played songs."
HELP_PAUSE_LONG = "Pauses the AudioPlayer. Playback can be continued with the resume command."
HELP_VOL_LONG = "Changes the volume of the AudioPlayer. Argument specifies the % to which the volume should be set."
HELP_PREV_LONG = "Plays the previous song again."
HELP_RESUME_LONG = "Resumes the AudioPlayer."
HELP_SKIP_LONG = "Skips the currently playing song and goes to the next item in the queue."
HELP_SONGINFO_LONG = "Shows details about the song currently being played and posts a link to the song."
HELP_STOP_LONG = "Stops the AudioPlayer and clears the songqueue"
HELP_YT_LONG = (
"$p [link/video title/key words/playlist-link/soundcloud link/spotify link/bandcamp link/twitter link]")
HELP_CLEAR_LONG = "Clears the queue."
HELP_LOOP_LONG = "Loops the currently playing song and locks the queue. Use the command again to disable loop."
HELP_QUEUE_LONG = "Shows the number of songs in queue, up to 10."
HELP_SHUFFLE_LONG = "Randomly sort the songs in the current queue"
ABSOLUTE_PATH = ''
COOKIE_PATH = '/config/cookies/cookies.txt'
COLOURS = {
'red': 0xDC143C,
'green': 0x00FF7F,
'grey': 0x708090,
'blue': 0x0000CD
}

View File

View File

@ -2,6 +2,7 @@ import requests
import json
import discord
from discord.ext import commands
from random import random as rand
class Phrases(commands.Cog):
@ -20,6 +21,11 @@ class Phrases(commands.Cog):
@commands.command(name='frase', help='Envia uma frase legal no seu PV')
async def send_phrase(self, ctx):
# There is a chance that the phrase will be send for the dev
sended = await self.calculate_rgn(ctx)
if sended:
return
while True:
try:
response = requests.get(
@ -30,7 +36,7 @@ class Phrases(commands.Cog):
author = data['quoteAuthor']
text = f'{phrase} \nBy: {author}'
await ctx.author.send(text)
await ctx.send(text)
break
except json.decoder.JSONDecodeError:
continue
@ -43,6 +49,15 @@ class Phrases(commands.Cog):
await ctx.channel.send('Houve um erro inesperado :/')
break
async def calculate_rgn(self, ctx):
x = rand()
print(x)
if x < 0.15:
await ctx.send('Se leu seu cu é meu\nBy: Minha Pica')
return True
else:
return False
def setup(bot):
bot.add_cog(Phrases(bot))