Remove unnecessary code

This commit is contained in:
ekzyis 2021-09-24 22:15:45 +02:00
parent 737919557a
commit d88ab63c2b
1 changed files with 1 additions and 43 deletions

View File

@ -1,7 +1,6 @@
import os import os
import sys import sys
import discord
from discord.ext import commands from discord.ext import commands
from dotenv import load_dotenv from dotenv import load_dotenv
@ -14,37 +13,9 @@ class Music(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@commands.command()
async def join(self, ctx, *, channel: discord.VoiceChannel):
"""Joins a voice channel"""
if ctx.voice_client is not None:
return await ctx.voice_client.move_to(channel)
await channel.connect()
@commands.command()
async def play(self, ctx, *, query):
"""Plays a file from the local filesystem"""
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
ctx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
await ctx.send(f"Now playing: {query}")
@commands.command()
async def yt(self, ctx, *, url):
"""Plays from a url (almost anything youtube_dl supports)"""
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop)
ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None)
await ctx.send(f"Now playing: {player.title}")
@commands.command() @commands.command()
async def stream(self, ctx, *, url): async def stream(self, ctx, *, url):
"""Streams from a url (same as yt, but doesn't predownload)""" """Streams from a url"""
async with ctx.typing(): async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
@ -52,24 +23,11 @@ class Music(commands.Cog):
await ctx.send(f"Now playing: {player.title}") await ctx.send(f"Now playing: {player.title}")
@commands.command()
async def volume(self, ctx, volume: int):
"""Changes the player's volume"""
if ctx.voice_client is None:
return await ctx.send("Not connected to a voice channel.")
ctx.voice_client.source.volume = volume / 100
await ctx.send(f"Changed volume to {volume}%")
@commands.command() @commands.command()
async def stop(self, ctx): async def stop(self, ctx):
"""Stops and disconnects the bot from voice""" """Stops and disconnects the bot from voice"""
await ctx.voice_client.disconnect() await ctx.voice_client.disconnect()
@play.before_invoke
@yt.before_invoke
@stream.before_invoke @stream.before_invoke
async def ensure_voice(self, ctx): async def ensure_voice(self, ctx):
if ctx.voice_client is None: if ctx.voice_client is None: