Now using hyperlinks in Queue and adding support message as random string

This commit is contained in:
Rafael Vargas 2022-09-07 21:47:09 -03:00
parent 5f60c12179
commit ba57a3e18d
5 changed files with 19 additions and 4 deletions

View File

@ -24,6 +24,10 @@ class VConfigs(Singleton):
self.COMMANDS_PATH = f'{Folder().rootFolder}{self.COMMANDS_FOLDER_NAME}'
self.VC_TIMEOUT = 300
self.CHANCE_SHOW_PROJECT = 15
self.PROJECT_URL = 'https://github.com/RafaelSolVargas/Vulkan'
self.SUPPORTING_ICON = 'https://i.pinimg.com/originals/d6/05/b4/d605b4f8c5d1c6ae20dc353ef9f091bd.png'
self.MAX_PLAYLIST_LENGTH = 50
self.MAX_PLAYLIST_FORCED_LENGTH = 5
self.MAX_SONGS_IN_PAGE = 10

View File

@ -1,3 +1,4 @@
from random import random
from Config.Messages import Messages
from Config.Exceptions import VulkanError
from discord import Embed
@ -12,6 +13,13 @@ class VEmbeds:
self.__messages = Messages()
self.__colors = VColors()
def __willShowProject(self) -> bool:
return (random() * 100 < self.__config.CHANCE_SHOW_PROJECT)
def __addFooterContent(self, embed: Embed) -> Embed:
footerText = f'\u200b Please support this project by leaving a star: {self.__config.PROJECT_URL}'
return embed.set_footer(text=footerText, icon_url=self.__config.SUPPORTING_ICON)
def ONE_SONG_LOOPING(self, info: dict) -> Embed:
title = self.__messages.ONE_SONG_LOOPING
return self.SONG_INFO(info, title)
@ -113,6 +121,8 @@ class VEmbeds:
value=position,
inline=True)
if self.__willShowProject():
embedvc = self.__addFooterContent(embedvc)
return embedvc
def SONG_MOVED(self, song_name: str, pos1: int, pos2: int) -> Embed:
@ -340,6 +350,9 @@ class VEmbeds:
description=description,
colour=self.__colors.BLUE
)
if self.__willShowProject():
embed = self.__addFooterContent(embed)
return embed
def INVITE(self, bot_id: str) -> Embed:

View File

@ -74,8 +74,8 @@ class QueueHandler(AbstractHandler):
# To work get the correct index of all songs
startIndex = (pageNumber * self.config.MAX_SONGS_IN_PAGE) + 1
for pos, song in enumerate(songs, start=startIndex):
song_name = song.title if song.title else self.messages.SONG_DOWNLOADING
text += f"**`{pos}` - ** {song_name} - `{Utils.format_time(song.duration)}`\n"
song_name = song.title[:50] if song.title else self.messages.SONG_DOWNLOADING
text += f"**`{pos}` - ** [{song_name}]({song.identifier}) - `{Utils.format_time(song.duration)}`\n"
embed = self.embeds.QUEUE(title, text)
# Release the acquired Lock

View File

@ -1,5 +1,4 @@
class Song:
def __init__(self, identifier: str, playlist, requester: str) -> None:
self.__identifier = identifier
self.__info = {'requester': requester}

View File

@ -1,4 +1,3 @@
import os
from random import choices
import string
from discord.bot import Bot