mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Removing some useless modules and spliting config file to help file too
This commit is contained in:
parent
5063c45e87
commit
ea5245cf95
@ -1,13 +1,8 @@
|
||||
from decouple import config
|
||||
|
||||
CETUS_API = config('CETUS_API')
|
||||
CAMBION_API = config('CAMBION_API')
|
||||
FISSURES_API = config('FISSURES_API')
|
||||
BOT_TOKEN = config('BOT_TOKEN')
|
||||
SPOTIFY_ID = config('SPOTIFY_ID')
|
||||
SPOTIFY_SECRET = config('SPOTIFY_SECRET')
|
||||
SECRET_MESSAGE = config('SECRET_MESSAGE')
|
||||
PHRASES_API = config('PHRASES_API')
|
||||
|
||||
BOT_PREFIX = '!'
|
||||
VC_TIMEOUT = 600
|
||||
@ -16,43 +11,17 @@ STARTUP_MESSAGE = 'Starting Vulkan...'
|
||||
STARTUP_COMPLETE_MESSAGE = 'Vulkan is now operating.'
|
||||
|
||||
MAX_PLAYLIST_LENGTH = 50
|
||||
MAX_API_PHRASES_TRIES = 10
|
||||
MAX_API_CETUS_TRIES = 10
|
||||
MAX_API_CAMBION_TRIES = 10
|
||||
MAX_API_FISSURES_TRIES = 10
|
||||
MAX_PRELOAD_SONGS = 10
|
||||
MAX_SONGS_HISTORY = 10
|
||||
MAX_SONGS_HISTORY = 15
|
||||
|
||||
INVITE_MESSAGE = 'To invite Vulkan to your own server, click [here]({})'
|
||||
|
||||
SONGINFO_UPLOADER = "Uploader: "
|
||||
SONGINFO_DURATION = "Duration: "
|
||||
SONGINFO_REQUESTER = 'Requester: '
|
||||
|
||||
HELP_SKIP = 'Skip the current playing song.'
|
||||
HELP_RESUME = 'Resumes the song player.'
|
||||
HELP_CLEAR = 'Clear the queue.'
|
||||
HELP_STOP = 'Stop the song player, removing Vulkan from voice channel.'
|
||||
HELP_LOOP = '(one/all/off) - Control the loop of songs.'
|
||||
HELP_NP = 'Show the info of the current song.'
|
||||
HELP_QUEUE = f'Show the first {MAX_PRELOAD_SONGS} songs in queue.'
|
||||
HELP_PAUSE = 'Pauses the song player.'
|
||||
HELP_PREV = 'Return to play the previous song.'
|
||||
HELP_SHUFFLE = 'Shuffle the songs playing.'
|
||||
HELP_PLAY = '(title/youtube/spotify) - Plays a song.'
|
||||
HELP_HISTORY = f'Show the last {MAX_SONGS_HISTORY} played songs history'
|
||||
HELP_MOVE = '(x, y) - Moves a song from position x to y in queue.'
|
||||
HELP_REMOVE = '(x, -1) - Remove a song in the position x or -1 for the last song.'
|
||||
HELP_RESET = 'Reset the Player of a server.'
|
||||
HELP_WARFRAME = f'({BOT_PREFIX}warframe help for more).'
|
||||
HELP_RANDOM = '(x) - Return a random number between 1 and x.'
|
||||
HELP_ESCOLHA = '(x, y, z...) - Choose randomly one item passed.'
|
||||
HELP_CARA = 'Return cara or coroa.'
|
||||
HELP_DROP = '(user_name) - Try to remove the user from the current voice channel.'
|
||||
HELP_FRASE = "Send a randomly phrase, perhaps you get the secret."
|
||||
HELP_HELP = 'This command :)'
|
||||
HELP_LONG_LOOP = 'Loop Command Help\nOne - Start looping the current song\nAll - Start looping all songs in queue\nOff - Disable the song loop'
|
||||
|
||||
SONGS_ADDED = 'You added {} songs to the queue'
|
||||
SONG_ADDED = 'You added the song {} to the queue'
|
||||
SONG_ADDED = 'You added the song `{}` to the queue'
|
||||
SONG_ADDED_TWO = '🎧 Song added to the queue'
|
||||
SONG_PLAYING = '🎧 Song playing now'
|
||||
SONG_PLAYER = '🎧 Song Player'
|
||||
@ -61,25 +30,11 @@ ONE_SONG_LOOPING = '🎧 Looping One Song'
|
||||
ALL_SONGS_LOOPING = '🎧 Looping All Songs'
|
||||
SONG_PAUSED = '⏸️ Song paused'
|
||||
SONG_RESUMED = '▶️ Song playing'
|
||||
EMPTY_QUEUE = f'❌ Song queue is empty, use {BOT_PREFIX}play to add new songs'
|
||||
EMPTY_QUEUE = f'📜 Song queue is empty, use {BOT_PREFIX}play to add new songs'
|
||||
SONG_DOWNLOADING = '📥 Downloading...'
|
||||
|
||||
HISTORY_TITLE = '🎧 Played Songs'
|
||||
HISTORY_EMPTY = '❌ There is no musics in history'
|
||||
|
||||
|
||||
SONGS_SHUFFLED = '🔀 Songs shuffled successfully'
|
||||
ERROR_SHUFFLING = '❌ Error while shuffling the songs'
|
||||
ERROR_MOVING = '❌ Error while moving the songs'
|
||||
LENGTH_ERROR = '❌ Numbers must be between 1 and queue length, use -1 for the last song'
|
||||
ERROR_NUMBER = '❌ This command require a number'
|
||||
ERROR_PLAYING = '❌ Error while playing songs'
|
||||
COMMAND_NOT_FOUND = f'❌ Command not found, type {BOT_PREFIX}help to see all commands'
|
||||
UNKNOWN_ERROR = '❌ Unknown Error'
|
||||
ERROR_MISSING_ARGUMENTS = f'❌ Missing arguments in this function. Type {BOT_PREFIX}help to see all commands'
|
||||
ERROR_WHILE_REQUESTING = 'O banco de dados dos cara tá off, bando de vagabundo, tenta depois aí bicho'
|
||||
NOT_PREVIOUS = '❌ There is none previous song to play'
|
||||
PLAYER_NOT_PLAYING = f'❌ No song playing. Use {BOT_PREFIX}play to start the player'
|
||||
HISTORY_EMPTY = '📜 There is no musics in history'
|
||||
|
||||
SONG_MOVED_SUCCESSFULLY = 'Song `{}` in position `{}` moved with `{}` in position `{}` successfully'
|
||||
SONG_REMOVED_SUCCESSFULLY = 'Song `{}` removed successfully'
|
||||
@ -94,14 +49,24 @@ LOOP_DISABLE = '➡️ Loop disabled'
|
||||
LOOP_ALREADY_DISABLE = '❌ Loop is already disabled'
|
||||
LOOP_ON = f'❌ This command cannot be invoked with any loop activated. Use {BOT_PREFIX}loop off to disable loop'
|
||||
|
||||
SONGS_PLAYING_TITLES = [ONE_SONG_LOOPING, ALL_SONGS_LOOPING, SONG_PLAYING]
|
||||
|
||||
SONGS_SHUFFLED = '🔀 Songs shuffled successfully'
|
||||
ERROR_SHUFFLING = '❌ Error while shuffling the songs'
|
||||
ERROR_MOVING = '❌ Error while moving the songs'
|
||||
LENGTH_ERROR = '❌ Numbers must be between 1 and queue length, use -1 for the last song'
|
||||
ERROR_NUMBER = '❌ This command require a number'
|
||||
ERROR_PLAYING = '❌ Error while playing songs'
|
||||
COMMAND_NOT_FOUND = f'❌ Command not found, type {BOT_PREFIX}help to see all commands'
|
||||
UNKNOWN_ERROR = f'❌ Unknown Error, if needed, use {BOT_PREFIX}reset to reset the player of your server'
|
||||
ERROR_MISSING_ARGUMENTS = f'❌ Missing arguments in this function. Type {BOT_PREFIX}help to see all commands'
|
||||
NOT_PREVIOUS = '❌ There is none previous song to play'
|
||||
PLAYER_NOT_PLAYING = f'❌ No song playing. Use {BOT_PREFIX}play to start the player'
|
||||
IMPOSSIBLE_MOVE = 'That is impossible :('
|
||||
ERROR_TITLE = 'Error :-('
|
||||
NO_CHANNEL = 'To play some music, connect to any voice channel first.'
|
||||
NO_GUILD = f'This server are not connected to Vulkan, try {BOT_PREFIX}reset'
|
||||
INVALID_INPUT = 'This type of input was too strange, try something better'
|
||||
DOWNLOADING_ERROR = 'An error occurred while downloading'
|
||||
EXTRACTING_ERROR = 'An error ocurred while searching for the songs'
|
||||
NO_GUILD = f'This server does not has a Player, try {BOT_PREFIX}reset'
|
||||
INVALID_INPUT = f'This type of input was too strange, try something better or type {BOT_PREFIX}help play'
|
||||
DOWNLOADING_ERROR = '❌ An error occurred while downloading'
|
||||
EXTRACTING_ERROR = '❌ An error ocurred while searching for the songs'
|
||||
|
||||
COLOURS = {
|
||||
'red': 0xDC143C,
|
||||
|
||||
43
config/help.py
Normal file
43
config/help.py
Normal file
@ -0,0 +1,43 @@
|
||||
from config.config import *
|
||||
|
||||
HELP_SKIP = 'Skip the current playing song.'
|
||||
HELP_SKIP_LONG = 'Skip the playing of the current song, does not work if loop one is activated. \n\nArguments: None.'
|
||||
HELP_RESUME = 'Resumes the song player.'
|
||||
HELP_RESUME_LONG = 'If the player if paused, return the playing. \n\nArguments: None.'
|
||||
HELP_CLEAR = 'Clear the queue and songs history.'
|
||||
HELP_CLEAR_LONG = 'Clear the songs queue and songs history. \n\nArguments: None.'
|
||||
HELP_STOP = 'Stop the song player.'
|
||||
HELP_STOP_LONG = 'Stop the song player, clear queue and history and remove Vulkan from voice channel.\n\nArguments: None.'
|
||||
HELP_LOOP = 'Control the loop of songs.'
|
||||
HELP_LOOP_LONG = 'Controll the loop of songs.\n\n Require: A song being played.\nArguments:\nOne - Start looping the current song. \
|
||||
\nAll - Start looping all songs in queue.\nOff - Disable loop.'
|
||||
HELP_NP = 'Show the info of the current song.'
|
||||
HELP_NP_LONG = 'Show the information of the song being played.\n\nRequire: A song being played.\nArguments: None.'
|
||||
HELP_QUEUE = f'Show the first {MAX_PRELOAD_SONGS} songs in queue.'
|
||||
HELP_QUEUE_LONG = f'Show the first {MAX_PRELOAD_SONGS} song in the queue.\n\nArguments: None.'
|
||||
HELP_PAUSE = 'Pauses the song player.'
|
||||
HELP_PAUSE_LONG = 'If playing, pauses the song player.\n\nArguments: None'
|
||||
HELP_PREV = 'Play the previous song.'
|
||||
HELP_PREV_LONG = 'Play the previous song. If playing, the current song will return to queue.\n\nRequire: Loop to be disable.\nArguments: None.'
|
||||
HELP_SHUFFLE = 'Shuffle the songs playing.'
|
||||
HELP_SHUFFLE_LONG = 'Randomly shuffle the songs in the queue.\n\nArguments: None.'
|
||||
HELP_PLAY = 'Plays a song.'
|
||||
HELP_PLAY_LONG = 'Play a song in discord. \n\nRequire: You to be connected to a voice channel.\nArguments: Youtube or Spotify song/playlist link or the title of the song to be searched in Youtube.'
|
||||
HELP_HISTORY = f'Show the history of played songs.'
|
||||
HELP_HISTORY_LONG = f'Show the last {MAX_SONGS_HISTORY} played songs'
|
||||
HELP_MOVE = 'Moves a song from position x to y in queue.'
|
||||
HELP_MOVE_LONG = 'Moves a song from position x to position y in queue.\n\nRequire: Positions to be both valid numbers.\nArguments: 1º Number => Initial position, 2º Number => Destination position. Both numbers could be -1 to refer to the last song in queue.\nDefault: By default, if the second number is not passed, it will be 1, moving the selected song to 1º position.'
|
||||
HELP_REMOVE = 'Remove a song in position x.'
|
||||
HELP_REMOVE_LONG = 'Remove a song from queue in the position passed.\n\nRequire: Position to be a valid number.\nArguments: 1º Number => Position in queue of the song.'
|
||||
HELP_RESET = 'Reset the Player of the server.'
|
||||
HELP_RESET_LONG = 'Reset the Player of the server. Recommended if you find any type of error.\n\nArguments: None'
|
||||
HELP_HELP = f'Use {BOT_PREFIX}help "command" for more info.'
|
||||
HELP_HELP_LONG = f'Use {BOT_PREFIX}help command for more info about the command selected.'
|
||||
HELP_INVITE = 'Send the invite URL to call Vulkan to your server.'
|
||||
HELP_INVITE_LONG = 'Send an message in text channel with a URL to be used to invite Vulkan to your own server.\n\nArguments: None.'
|
||||
HELP_RANDOM = 'Return a random number between 1 and x.'
|
||||
HELP_RANDOM_LONG = 'Send a randomly selected number between 1 and the number you pass.\n\nRequired: Number to be a valid number.\nArguments: 1º Any number to be used as range.'
|
||||
HELP_CHOOSE = 'Choose randomly one item passed.'
|
||||
HELP_CHOOSE_LONG = 'Choose randomly one item passed in this command.\n\nRequire: Itens to be separated by comma.\nArguments: As much as you want.'
|
||||
HELP_CARA = 'Return cara or coroa.'
|
||||
HELP_CARA_LONG = 'Return cara or coroa.'
|
||||
@ -1,60 +0,0 @@
|
||||
from discord.client import Client
|
||||
import requests
|
||||
import json
|
||||
from config import config
|
||||
from discord.ext import commands
|
||||
from random import random as rand
|
||||
|
||||
|
||||
class Phrases(commands.Cog):
|
||||
"""Deal with the generation of motivational phrases"""
|
||||
|
||||
def __init__(self, bot: Client):
|
||||
self.__bot = bot
|
||||
|
||||
@commands.command(name='frase', help=config.HELP_FRASE)
|
||||
async def phrase(self, ctx):
|
||||
"""Send some phrase to the requester"""
|
||||
secret = await self.__calculate_rgn()
|
||||
if secret != None:
|
||||
await ctx.send(secret)
|
||||
else:
|
||||
phrase = await self.__get_phrase()
|
||||
await ctx.send(phrase)
|
||||
|
||||
async def __calculate_rgn(self):
|
||||
"""Calculate the chance from the phrase function return a secret custom message"""
|
||||
x = rand()
|
||||
if x < 0.15:
|
||||
return config.SECRET_MESSAGE
|
||||
else:
|
||||
return None
|
||||
|
||||
async def __get_phrase(self):
|
||||
"""Get the phrase from the server"""
|
||||
tries = 0
|
||||
while True:
|
||||
tries += 1
|
||||
if tries > config.MAX_API_PHRASES_TRIES:
|
||||
return config.ERROR_WHILE_REQUEST
|
||||
return 'O banco de dados dos cara tá off, bando de vagabundo, tenta depois aí bicho'
|
||||
|
||||
try:
|
||||
response = requests.get(config.PHRASES_API)
|
||||
data = json.loads(response.content)
|
||||
|
||||
phrase = data['quoteText']
|
||||
author = data['quoteAuthor']
|
||||
|
||||
if phrase == '' or author == '':
|
||||
continue
|
||||
|
||||
text = f'{phrase} \nBy: {author}'
|
||||
|
||||
return text
|
||||
except:
|
||||
continue
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Phrases(bot))
|
||||
@ -1,118 +0,0 @@
|
||||
import requests
|
||||
import json
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from config import config
|
||||
from discord import Embed
|
||||
|
||||
|
||||
class Warframe(commands.Cog):
|
||||
"""Deal with the generation of warframe data"""
|
||||
|
||||
def __init__(self, bot: discord.Client):
|
||||
self.__bot = bot
|
||||
self.__open_functions = ['cetus', 'cambion', 'fissures']
|
||||
|
||||
@commands.command(name='warframe', help=config.HELP_WARFRAME)
|
||||
async def warframe(self, ctx, arg) -> Embed:
|
||||
if arg in self.__open_functions:
|
||||
function = getattr(Warframe, f'_Warframe__{arg}')
|
||||
embed = await function(self)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
info = f'Warframe commands: {self.__open_functions}'
|
||||
|
||||
embed = Embed(
|
||||
title='Invalid Command',
|
||||
description=info,
|
||||
colour=config.COLOURS['blue']
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
async def __cetus(self) -> Embed:
|
||||
description = await self.__get_cetus()
|
||||
embed = discord.Embed(
|
||||
title='Warframe Cetus Timing',
|
||||
description=description,
|
||||
colour=config.COLOURS['blue']
|
||||
)
|
||||
return embed
|
||||
|
||||
async def __get_cetus(self) -> str:
|
||||
"""Return the information of the Warframe API"""
|
||||
tries = 0
|
||||
while True:
|
||||
tries += 1
|
||||
if tries > config.MAX_API_CETUS_TRIES:
|
||||
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||
|
||||
try:
|
||||
response = requests.get(config.CETUS_API)
|
||||
data = json.loads(response.content)
|
||||
short = data['shortString']
|
||||
|
||||
return short
|
||||
|
||||
except Exception as e:
|
||||
continue
|
||||
|
||||
async def __cambion(self) -> Embed:
|
||||
description = await self.__get_cambion()
|
||||
embed = discord.Embed(
|
||||
title='Warframe Cambion Timing',
|
||||
description=description,
|
||||
colour=config.COLOURS['blue']
|
||||
)
|
||||
return embed
|
||||
|
||||
async def __get_cambion(self) -> str:
|
||||
"""Return the information of the Warframe API"""
|
||||
tries = 0
|
||||
while True:
|
||||
tries += 1
|
||||
if tries > config.MAX_API_CAMBION_TRIES:
|
||||
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||
|
||||
try:
|
||||
response = requests.get(config.CAMBION_API)
|
||||
data = json.loads(response.content)
|
||||
|
||||
info = f'**Active:** {data["active"]}\n**Time Left:** {data["timeLeft"]}'
|
||||
|
||||
return info
|
||||
except:
|
||||
continue
|
||||
|
||||
async def __fissures(self) -> Embed:
|
||||
description = await self.__get_fissures()
|
||||
embed = discord.Embed(
|
||||
title='Warframe Fissures Status',
|
||||
description=description,
|
||||
colour=config.COLOURS['blue']
|
||||
)
|
||||
return embed
|
||||
|
||||
async def __get_fissures(self) -> str:
|
||||
"""Return the information of the Warframe API"""
|
||||
tries = 0
|
||||
while True:
|
||||
tries += 1
|
||||
if tries > config.MAX_API_FISSURES_TRIES:
|
||||
return 'Os DE baiano não tão com o banco de dados ligado'
|
||||
|
||||
try:
|
||||
response = requests.get(config.FISSURES_API)
|
||||
data = json.loads(response.content)
|
||||
|
||||
info = ''
|
||||
for pos, fissure in enumerate(data, start=1):
|
||||
info += f'`{pos}` - **Mission:** {fissure["missionType"]} | **Type:** {fissure["tier"]} | **Timing:** {fissure["eta"]} | **Storm:** {fissure["isStorm"]}\n'
|
||||
|
||||
return info
|
||||
except Exception as e:
|
||||
continue
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Warframe(bot))
|
||||
Loading…
x
Reference in New Issue
Block a user