Removed create view

This commit is contained in:
Choco
2024-02-11 19:52:14 +08:00
parent 9dc6b99338
commit 95ec0970eb
5 changed files with 6 additions and 84 deletions

View File

@@ -21,8 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import discord
import voicelink
import discord, voicelink
from io import StringIO
from discord import app_commands
@@ -30,12 +29,10 @@ from discord.ext import commands
from function import (
time as ctime,
get_playlist,
create_account,
check_roles,
update_playlist,
update_inbox,
get_lang,
PLAYLIST_NAME,
settings,
get_aliases,
cooldown_check
@@ -122,8 +119,7 @@ class Playlists(commands.Cog, name="playlist"):
async def play(self, ctx: commands.Context, name: str = None, value: int = None) -> None:
"Play all songs from your favorite playlist."
result = await check_playlist(ctx, name.lower() if name else None)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
rank, max_p, max_t = check_roles()
@@ -162,8 +158,6 @@ class Playlists(commands.Cog, name="playlist"):
async def view(self, ctx: commands.Context) -> None:
"List all your playlist and all songs in your favourite playlist."
user = await check_playlist(ctx, full=True)
if not user:
return await create_account(ctx)
rank, max_p, max_t = check_roles()
results = []
@@ -219,8 +213,6 @@ class Playlists(commands.Cog, name="playlist"):
rank, max_p, max_t = check_roles()
user = await check_playlist(ctx, full=True)
if not user:
return await create_account(ctx)
if len(user) >= max_p:
return await ctx.send(get_lang(ctx.guild.id, 'overPlaylistCreation').format(max_p), ephemeral=True)
@@ -244,8 +236,6 @@ class Playlists(commands.Cog, name="playlist"):
async def delete(self, ctx: commands.Context, name: str):
"Delete your custom playlist."
result = await check_playlist(ctx, name.lower(), share=False)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
if result['id'] == "200":
@@ -271,8 +261,6 @@ class Playlists(commands.Cog, name="playlist"):
if member.bot:
return await ctx.send(get_lang(ctx.guild.id, 'playlistSendErrorBot'), ephemeral=True)
result = await check_playlist(ctx, name.lower(), share=False)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
@@ -307,8 +295,6 @@ class Playlists(commands.Cog, name="playlist"):
if name.lower() == newname.lower():
return await ctx.send(get_lang(ctx.guild.id, 'playlistSameName'), ephemeral=True)
user = await check_playlist(ctx, full=True)
if not user:
return await create_account(ctx)
found, id = False, 0
for data in user:
if user[data]['name'].lower() == name.lower():
@@ -327,8 +313,6 @@ class Playlists(commands.Cog, name="playlist"):
async def inbox(self, ctx: commands.Context) -> None:
"Show your playlist invitation."
user = await get_playlist(ctx.author.id)
if user is None:
return await create_account(ctx)
if not user['inbox']:
return await ctx.send(get_lang(ctx.guild.id, 'inboxNoMsg'), ephemeral=True)
@@ -359,8 +343,6 @@ class Playlists(commands.Cog, name="playlist"):
async def add(self, ctx: commands.Context, name: str, query: str) -> None:
"Add tracks in to your custom playlist."
result = await check_playlist(ctx, name.lower(), share=False)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
if result['playlist']['type'] in ['share', 'link']:
@@ -393,8 +375,6 @@ class Playlists(commands.Cog, name="playlist"):
async def remove(self, ctx: commands.Context, name: str, position: int):
"Remove song from your favorite playlist."
result = await check_playlist(ctx, name.lower(), share=False)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
if result['playlist']['type'] in ['link', 'share']:
@@ -413,8 +393,6 @@ class Playlists(commands.Cog, name="playlist"):
async def clear(self, ctx: commands.Context, name: str) -> None:
"Remove all songs from your favorite playlist."
result = await check_playlist(ctx, name.lower(), share=False)
if not result:
return await create_account(ctx)
if not result['playlist']:
return await ctx.send(get_lang(ctx.guild.id, 'playlistNotFound').format(name), ephemeral=True)
@@ -463,7 +441,7 @@ class Playlists(commands.Cog, name="playlist"):
temp = "!Remember do not change this file!\n------------->Info<-------------\nPlaylist: {} ({})\nRequester: {} ({})\nTracks: {} - {}\n------------>Tracks<------------\n".format(
tracks['name'], result['playlist']['type'],
ctx.author.name, ctx.author.id,
ctx.author.display_name, ctx.author.id,
len(tracks['tracks']), ctime(total_length)
) + temp
temp += raw
@@ -480,8 +458,6 @@ class Playlists(commands.Cog, name="playlist"):
rank, max_p, max_t = check_roles()
user = await check_playlist(ctx, full=True)
if not user:
return await create_account(ctx)
if len(user) >= max_p:
return await ctx.send(get_lang(ctx.guild.id, 'overPlaylistCreation').format(max_p), ephemeral=True)

View File

@@ -158,28 +158,8 @@ async def update_settings(guild_id: int, data: dict[str, dict[str, Any]]) -> boo
return result.modified_count > 0
async def create_account(ctx: Union[commands.Context, discord.Interaction]) -> None:
author = ctx.author if isinstance(ctx, commands.Context) else ctx.user
if not author:
return
from views import CreateView
view = CreateView()
embed=discord.Embed(title="Do you want to create an account on Vocard?", color=settings.embed_color)
embed.description = f"> Plan: `Default` | `5` Playlist | `500` tracks in each playlist."
embed.add_field(name="Terms of Service:", value=" ➥ We assure you that all your data on Vocard will not be disclosed to any third party\n"
" ➥ We will not perform any data analysis on your data\n"
" ➥ You have the right to immediately stop the services we offer to you\n"
" ➥ Please do not abuse our services, such as affecting other users\n", inline=False)
if isinstance(ctx, commands.Context):
view.response = await ctx.reply(embed=embed, view=view, ephemeral=True)
else:
view.response = await ctx.response.send_message(embed=embed, view=view, ephemeral=True)
async def get_settings(guild_id:int) -> dict[str, Any]:
await view.wait()
if view.value:
try:
await PLAYLISTS_DB.insert_one({'_id':author.id, 'playlist': {'200':{'tracks':[],'perms':{ 'read': [], 'write':[], 'remove': []},'name':'Favourite', 'type':'playlist' }},'inbox':[] })
except:
pass
async def get_playlist(user_id:int, dType:str=None, dId:str=None) -> bool:
user = await PLAYLISTS_DB.find_one({"_id":user_id}, {"_id": 0})

View File

@@ -10,7 +10,7 @@ from .help import HelpView
from .list import ListView
from .lyrics import LyricsView
from .chapter import ChapterView
from .playlist import PlaylistView, CreateView
from .playlist import PlaylistView
from .inbox import InboxView
from .link import LinkView
from .debug import DebugView

View File

@@ -30,7 +30,6 @@ from . import ButtonOnCooldown
from function import (
get_playlist,
update_playlist,
create_account,
check_roles
)
@@ -198,8 +197,6 @@ class Add(ControlButton):
if track.is_stream:
return await self.send(interaction, self.player.get_msg("playlistAddError"))
user = await get_playlist(interaction.user.id, 'playlist')
if not user:
return await create_account(interaction)
rank, max_p, max_t = check_roles()
if len(user['200']['tracks']) >= max_t:
return await self.send(interaction, self.player.get_msg("playlistlimited").format(max_t), ephemeral=True)

View File

@@ -54,20 +54,6 @@ class Select_playlist(discord.ui.Select):
self.view.current_page = 1
await interaction.response.edit_message(embed=self.view.build_embed())
class agree(discord.ui.Button):
def __init__(self) -> None:
self.view: CreateView
super().__init__(label="Agree", style=discord.ButtonStyle.green)
async def callback(self, interaction: discord.Interaction) -> None:
self.label = "Created"
self.disabled = True
self.style=discord.ButtonStyle.primary
embed = discord.Embed(description="Your account has been successfully created", color=0x55e27f)
await interaction.response.edit_message(embed=embed, view=self.view)
self.view.value = True
self.view.stop()
class PlaylistView(discord.ui.View):
def __init__(
self,
@@ -170,21 +156,4 @@ class PlaylistView(discord.ui.View):
@discord.ui.button(emoji='🗑️', style=discord.ButtonStyle.red)
async def stop_button(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
await self.response.delete()
self.stop()
class CreateView(discord.ui.View):
def __init__(self) -> None:
super().__init__(timeout=20)
self.value: bool = None
self.response: discord.Message = None
self.add_item(agree())
self.add_item(discord.ui.Button(label='Support', emoji=':support:915152950471581696', url=func.settings.invite_link))
async def on_timeout(self) -> None:
for child in self.children:
child.disabled = True
try:
await self.response.edit(view=self)
except:
pass
self.stop()