forked from jojara/JellyfinDiscordBot
removed deprecate play
This commit is contained in:
parent
a8dca7184d
commit
80b47c6d68
78
bot.py
78
bot.py
@ -1,6 +1,5 @@
|
||||
# Imports
|
||||
import os
|
||||
from discord.webhook.async_ import interaction_message_response_params
|
||||
import requests
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
@ -152,83 +151,6 @@ def clearQueue(interaction: discord.Interaction):
|
||||
|
||||
# ----- Commands ----- #
|
||||
|
||||
|
||||
### DEPRECATED START ###
|
||||
|
||||
# Play
|
||||
# Plays a song with the given title in wherever the user is
|
||||
# start play -----
|
||||
@bot.tree.command(name="play", description="Play a song from Jellyfin")
|
||||
@app_commands.describe(title="Song title to play")
|
||||
async def play(interaction: discord.Interaction, title: str):
|
||||
|
||||
# Makes the reaction visible to everyone
|
||||
await interaction.response.defer()
|
||||
|
||||
# Checks if not in a voice channel
|
||||
# Checks if in a voice channel
|
||||
try:
|
||||
# A better way of checking status
|
||||
voice_status = await interaction.user.fetch_voice()
|
||||
user_channel = voice_status.channel
|
||||
voice_client = interaction.guild.voice_client # Enables the voice feature for the bot
|
||||
|
||||
# First check if it is already in a voice channel
|
||||
if voice_client.channel != user_channel:
|
||||
voice_client.disconnect()
|
||||
|
||||
if voice_client.is_playing():
|
||||
voice_client.stop()
|
||||
|
||||
# Finally, connect
|
||||
await user_channel.connect()
|
||||
except discord.errors.NotFound as e:
|
||||
print(f"Error: {e}")
|
||||
await interaction.followup.send("Nope! Not in a voice!")
|
||||
return
|
||||
except discord.errors.Forbidden as e:
|
||||
print(f"Error: {e}")
|
||||
await interaction.followup.send("Not allowed in here!")
|
||||
return
|
||||
|
||||
|
||||
|
||||
# makes a request to the server, and returns the data it acquires
|
||||
data = await make_request(title, interaction)
|
||||
if not data:
|
||||
await interaction.followup.send(f"❌ No song found matching `{title}`.")
|
||||
return
|
||||
|
||||
# Finds the item, and displays information about the location
|
||||
print(f"Found {len(data)} items matching `{title}`.")
|
||||
|
||||
# Deconstructing the dict 'data'
|
||||
query_song = data[0]
|
||||
query_song_id = query_song.get('Id')
|
||||
query_song_title = query_song.get('Name')
|
||||
query_song_artist = query_song.get('AlbumArtist', ['Unknown Artist'])
|
||||
|
||||
|
||||
|
||||
# Check if the guild is not known guilds
|
||||
if guild_queue_dict.get(interaction.guild_id) == None:
|
||||
# add it to the playlist dict
|
||||
guild_queue_dict[interaction.guild_id] = list()
|
||||
|
||||
guild_queue_dict[interaction.guild_id].insert(0, (query_song_id, query_song_title, query_song_artist))
|
||||
|
||||
# If someone is already playing something, we just add to their queue.
|
||||
# Probably a better way of piggybacking
|
||||
if voice_client.is_playing():
|
||||
await interaction.followup.send(f"Queued to front: **{query_song_title}** by *{query_song_artist}*")
|
||||
return
|
||||
|
||||
await playTrack(interaction)
|
||||
# end play -----
|
||||
|
||||
### DEPRECATED END ###
|
||||
|
||||
|
||||
# Connect
|
||||
# Connects to a voice channel
|
||||
@bot.tree.command(name="connect", description="Connects to the current voice channel")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user