From d67997140f0d84f3b7775bfb9d53b33e4bcb481f Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Fri, 24 Dec 2021 13:11:43 -0400 Subject: [PATCH] Changing file organization --- .gitignore | 3 +- cogs/control.py | 34 ---------- config/config.py | 63 +++++++++++++++++++ config/cookies/cookies.txt | 0 .../commands/Filter.py | 0 .../commands/Phrases.py | 17 ++++- cogs/talk.py => extensions/commands/Talk.py | 0 .../commands/Warframe.py | 0 {cogs => extensions/music}/music.py | 0 9 files changed, 81 insertions(+), 36 deletions(-) delete mode 100644 cogs/control.py create mode 100644 config/config.py create mode 100644 config/cookies/cookies.txt rename cogs/filter.py => extensions/commands/Filter.py (100%) rename cogs/phrases.py => extensions/commands/Phrases.py (75%) rename cogs/talk.py => extensions/commands/Talk.py (100%) rename cogs/warframe.py => extensions/commands/Warframe.py (100%) rename {cogs => extensions/music}/music.py (100%) diff --git a/.gitignore b/.gitignore index 543bbf4..ebb8b9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__ examples -.env \ No newline at end of file +.env +errors \ No newline at end of file diff --git a/cogs/control.py b/cogs/control.py deleted file mode 100644 index c612c4b..0000000 --- a/cogs/control.py +++ /dev/null @@ -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)) diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..9f838b3 --- /dev/null +++ b/config/config.py @@ -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 +} diff --git a/config/cookies/cookies.txt b/config/cookies/cookies.txt new file mode 100644 index 0000000..e69de29 diff --git a/cogs/filter.py b/extensions/commands/Filter.py similarity index 100% rename from cogs/filter.py rename to extensions/commands/Filter.py diff --git a/cogs/phrases.py b/extensions/commands/Phrases.py similarity index 75% rename from cogs/phrases.py rename to extensions/commands/Phrases.py index 58d1642..6900427 100644 --- a/cogs/phrases.py +++ b/extensions/commands/Phrases.py @@ -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)) diff --git a/cogs/talk.py b/extensions/commands/Talk.py similarity index 100% rename from cogs/talk.py rename to extensions/commands/Talk.py diff --git a/cogs/warframe.py b/extensions/commands/Warframe.py similarity index 100% rename from cogs/warframe.py rename to extensions/commands/Warframe.py diff --git a/cogs/music.py b/extensions/music/music.py similarity index 100% rename from cogs/music.py rename to extensions/music/music.py