Create/Implement CheckPlayerError
error class
This commit is contained in:
parent
3c66d50822
commit
760aac506f
@ -8,6 +8,7 @@ from global_variables import (
|
|||||||
LAVALINK_PASSWORD,
|
LAVALINK_PASSWORD,
|
||||||
LAVALINK_PORT,
|
LAVALINK_PORT,
|
||||||
LOG,
|
LOG,
|
||||||
|
CheckPlayerError,
|
||||||
)
|
)
|
||||||
from ai_recommendations import add_song_recommendations
|
from ai_recommendations import add_song_recommendations
|
||||||
|
|
||||||
@ -135,14 +136,14 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
if not interaction.user.voice or not interaction.user.voice.channel:
|
if not interaction.user.voice or not interaction.user.voice.channel:
|
||||||
if voice_client is not None:
|
if voice_client is not None:
|
||||||
raise app_commands.AppCommandError(
|
raise CheckPlayerError(
|
||||||
{
|
{
|
||||||
"title": "Not in my VC",
|
"title": "Not in my VC",
|
||||||
"description": "You must join my voice channel to run that command.",
|
"description": "You must join my voice channel to run that command.",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
raise app_commands.AppCommandError(
|
raise CheckPlayerError(
|
||||||
{
|
{
|
||||||
"title": "No Channel",
|
"title": "No Channel",
|
||||||
"description": "You must join a voice channel before you can run that command.",
|
"description": "You must join a voice channel before you can run that command.",
|
||||||
@ -151,7 +152,7 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
if voice_client is None:
|
if voice_client is None:
|
||||||
if not should_connect:
|
if not should_connect:
|
||||||
raise app_commands.AppCommandError(
|
raise CheckPlayerError(
|
||||||
{
|
{
|
||||||
"title": "Not Connected",
|
"title": "Not Connected",
|
||||||
"description": "I am not connected and playing music right now, therefore that command will not work.",
|
"description": "I am not connected and playing music right now, therefore that command will not work.",
|
||||||
@ -163,7 +164,7 @@ class Music(commands.Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not permissions.connect or not permissions.speak:
|
if not permissions.connect or not permissions.speak:
|
||||||
raise app_commands.AppCommandError(
|
raise CheckPlayerError(
|
||||||
{
|
{
|
||||||
"title": "Missing Permissions",
|
"title": "Missing Permissions",
|
||||||
"description": "I need the `CONNECT` and `SPEAK` permissions in order to work.",
|
"description": "I need the `CONNECT` and `SPEAK` permissions in order to work.",
|
||||||
@ -173,7 +174,7 @@ class Music(commands.Cog):
|
|||||||
player.store("channel", interaction.channel.id)
|
player.store("channel", interaction.channel.id)
|
||||||
else:
|
else:
|
||||||
if int(player.channel_id) != interaction.user.voice.channel.id:
|
if int(player.channel_id) != interaction.user.voice.channel.id:
|
||||||
raise app_commands.AppCommandError(
|
raise CheckPlayerError(
|
||||||
{
|
{
|
||||||
"title": "Not in my VC",
|
"title": "Not in my VC",
|
||||||
"description": "You must join my voice channel to run that command.",
|
"description": "You must join my voice channel to run that command.",
|
||||||
|
@ -4,7 +4,7 @@ from discord import app_commands
|
|||||||
from discord.ext.commands.errors import *
|
from discord.ext.commands.errors import *
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from global_variables import BOT_COLOR
|
from global_variables import BOT_COLOR, CheckPlayerError
|
||||||
from custom_source import LoadError
|
from custom_source import LoadError
|
||||||
|
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ class slash_handlers(commands.Cog):
|
|||||||
# )
|
# )
|
||||||
# await interaction.response.send_message(embed=embed, ephemeral=True)
|
# await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||||
|
|
||||||
elif isinstance(error, app_commands.AppCommandError):
|
elif isinstance(error, CheckPlayerError):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title=error.args[0]["title"],
|
title=error.info["title"],
|
||||||
description=error.args[0]["description"],
|
description=error.info["description"],
|
||||||
color=BOT_COLOR,
|
color=BOT_COLOR,
|
||||||
)
|
)
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
|
@ -57,3 +57,9 @@ BOT_INVITE_LINK = config["BOT_INFO"]["BOT_INVITE_LINK"]
|
|||||||
LAVALINK_HOST = config["LAVALINK"]["HOST"]
|
LAVALINK_HOST = config["LAVALINK"]["HOST"]
|
||||||
LAVALINK_PORT = config["LAVALINK"]["PORT"]
|
LAVALINK_PORT = config["LAVALINK"]["PORT"]
|
||||||
LAVALINK_PASSWORD = config["LAVALINK"]["PASSWORD"]
|
LAVALINK_PASSWORD = config["LAVALINK"]["PASSWORD"]
|
||||||
|
|
||||||
|
|
||||||
|
class CheckPlayerError(discord.app_commands.AppCommandError):
|
||||||
|
def __init__(self, info) -> None:
|
||||||
|
self.info = info
|
||||||
|
super().__init__()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user