Skip to main content

Pomice

The modern Lavalink wrapper designed for nextcord

This library is heavily based off of/uses code from the following libraries:

Install

To install the library, you need the lastest version of pip and minimum Python 3.8

Stable version

pip install nextcord-ext-pomice

Unstable version (this one gets more frequent changes)

pip install git+https://github.com/techpluscraft/nextcord-ext-pomice

Support

The official documentation is here

Examples

In-depth examples are located in the examples folder

Here's a quick example:

from nextcord.ext import pomice
import nextcord
import re

from nextcord.ext import commands

URL_REG = re.compile(r'https?://(?:www\.)?.+')

class MyBot(commands.Bot):
    
    def __init__(self) -> None:
        super().__init__(command_prefix='!', activity=nextcord.Activity(type=nextcord.ActivityType.listening, name='to music!'))
        
        self.add_cog(Music(self))
        
    async def on_ready(self) -> None:
        print("I'm online!")
        await self.cogs["Music"].start_nodes()
     
        
class Music(commands.Cog):
    
    def __init__(self, bot) -> None:
        self.bot = bot
        
        self.pomice = pomice.NodePool()
    
    async def start_nodes(self):
        await self.pomice.create_node(bot=self.bot, host='127.0.0.1', port='3030', 
                                     password='youshallnotpass', identifier='MAIN')
        print(f"Node is ready!")


        
    @commands.command(name='join', aliases=['connect'])
    async def join(self, ctx: commands.Context, *, channel: nextcord.TextChannel = None) -> None:
        
        if not channel:
            channel = getattr(ctx.author.voice, 'channel', None)
            if not channel:
                raise commands.CheckFailure('You must be in a voice channel to use this command'
                                            'without specifying the channel argument.')

        
        await ctx.author.voice.channel.connect(cls=pomice.Player)
        await ctx.send(f'Joined the voice channel `{channel}`')
        
    @commands.command(name='play')
    async def play(self, ctx, *, search: str) -> None:
        
        if not ctx.voice_client:
            await ctx.invoke(self.join) 

        player = ctx.voice_client        

        results = await player.get_tracks(query=f'{search}')
        
        if not results:
            raise commands.CommandError('No results were found for that search term.')
        
        if isinstance(results, pomice.Playlist):
            await player.play(track=results.tracks[0])
        else:
            await player.play(track=results[0])

            
bot = MyBot()
bot.run("token here")

FAQ

Why is it saying "Cannot connect to host"?

  • You need to have a Lavalink node setup before you can use this library. Download it here

What experience do I need?

  • This library requires that you have some experience with Python, asynchronous programming and the nextcord library.

Why is it saying "No module named pomice found"?

  • You need to install the package before you can use it

Contributors

  • Thanks to vveeps for implementing some features I wasn't able to do myself

Release files for nextcord-ext-pomice 1.1.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nextcord-ext-pomice 1.1.7.1
File Size Uploaded
nextcord-ext-pomice-1.1.7.1.tar.gz 18.8 kB Details

Release files / nextcord-ext-pomice-1.1.7.1.tar.gz

Download URL nextcord-ext-pomice-1.1.7.1.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6cc4dd54681627f4def1dfd6c3b20588356df9005e85d3ea8e1bbcf4053470cf
BLAKE2b-256 checksum
How to use checksums
97e3d9a7ce2efc526ba730267906e3d7c94c805a3bdea119188c56ffd3a9ffc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.0

Release history Release notifications | RSS feed

This release

1.1.7.1 This release

1 release file

1.1.7

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page