initial music commit
This commit is contained in:
1 parent
086f4ce912
commit
e7e9eb468e
4 files changed
+81
No files matched your search
+26
@@ -47,6 +47,14 @@
|
|||||||
"detail": "discord.ext",
|
"detail": "discord.ext",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "commands",
|
||||||
|
"importPath": "discord.ext",
|
||||||
|
"description": "discord.ext",
|
||||||
|
"isExtraImport": true,
|
||||||
|
"detail": "discord.ext",
|
||||||
|
"documentation": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "random",
|
"label": "random",
|
||||||
"kind": 6,
|
"kind": 6,
|
||||||
@@ -101,6 +109,15 @@
|
|||||||
"detail": "psutil",
|
"detail": "psutil",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "wavelink",
|
||||||
|
"kind": 6,
|
||||||
|
"isExtraImport": true,
|
||||||
|
"importPath": "wavelink",
|
||||||
|
"description": "wavelink",
|
||||||
|
"detail": "wavelink",
|
||||||
|
"documentation": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "load_dotenv",
|
"label": "load_dotenv",
|
||||||
"importPath": "dotenv",
|
"importPath": "dotenv",
|
||||||
@@ -181,6 +198,15 @@
|
|||||||
"detail": "cogs.sysinfo",
|
"detail": "cogs.sysinfo",
|
||||||
"documentation": {}
|
"documentation": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label": "Music",
|
||||||
|
"kind": 6,
|
||||||
|
"importPath": "wavelink.music",
|
||||||
|
"description": "wavelink.music",
|
||||||
|
"peekOfCode": "class Music(commands.Cog):\n def __init__(self, bot):\n self.bot = bot\n @commands.Cog.listener()\n async def on_ready(self):\n node = wavelink.Node(uri='http://127.0.0.1:2333', password='yuukabot')\n await wavelink.Pool.connect(nodes=[node], client=self.bot)\n print('✅ Wavelink connected to Lavalink')\n @commands.command()\n async def play(self, ctx, *, query: str):",
|
||||||
|
"detail": "wavelink.music",
|
||||||
|
"documentation": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "intents",
|
"label": "intents",
|
||||||
"kind": 5,
|
"kind": 5,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ async def main():
|
|||||||
await bot.load_extension('cogs.gifs')
|
await bot.load_extension('cogs.gifs')
|
||||||
await bot.load_extension('cogs.copypasta')
|
await bot.load_extension('cogs.copypasta')
|
||||||
await bot.load_extension('cogs.sysinfo')
|
await bot.load_extension('cogs.sysinfo')
|
||||||
|
await bot.load_extension('cogs.wavelink.music')
|
||||||
await bot.start(os.getenv('DISCORD_TOKEN'))
|
await bot.start(os.getenv('DISCORD_TOKEN'))
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|||||||
Whitespace-only changes.
@@ -0,0 +1,54 @@
|
|||||||
|
import wavelink
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
|
||||||
|
class Music(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_ready(self):
|
||||||
|
node = wavelink.Node(uri='http://127.0.0.1:2333', password='yuukabot')
|
||||||
|
await wavelink.Pool.connect(nodes=[node], client=self.bot)
|
||||||
|
print('✅ Wavelink connected to Lavalink')
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def play(self, ctx, *, query: str):
|
||||||
|
if not ctx.author.voice:
|
||||||
|
return await ctx.reply('you need to be in a voice channel!')
|
||||||
|
|
||||||
|
if not ctx.voice_client:
|
||||||
|
vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
|
||||||
|
else:
|
||||||
|
vc: wavelink.Player = ctx.voice_client
|
||||||
|
|
||||||
|
tracks = await wavelink.Playable.search(query)
|
||||||
|
if not tracks:
|
||||||
|
return await ctx.reply('nothing found!')
|
||||||
|
|
||||||
|
track = tracks[0]
|
||||||
|
await vc.play(track)
|
||||||
|
await ctx.reply(f'▶️ now playing: {track.title}')
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def stop(self, ctx):
|
||||||
|
if ctx.voice_client:
|
||||||
|
await ctx.voice_client.disconnect()
|
||||||
|
await ctx.reply('⏹️ stopped!')
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def skip(self, ctx):
|
||||||
|
if ctx.voice_client:
|
||||||
|
await ctx.voice_client.skip()
|
||||||
|
await ctx.reply('⏭️ skipped!')
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def pause(self, ctx):
|
||||||
|
if ctx.voice_client:
|
||||||
|
await ctx.voice_client.pause(not ctx.voice_client.paused)
|
||||||
|
await ctx.reply('⏸️ toggled pause!')
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(Music(bot))
|
||||||
Reference in new issue
Block a user