Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

The modern Lavalink wrapper designed for discord.py

License

NotificationsYou must be signed in to change notification settings

cloudwithax/pomice

Repository files navigation

GPLCode style: blackDiscordRead the Docs

Pomice is a fully asynchronous Python library designed for communicating withLavalink seamlessly within thediscord.py library. It features 100% coverage of theLavalink spec that can be accessed with easy-to-understand functions along with Spotify and Apple Music querying capabilities using built-in custom clients, making it easier to develop your next big music bot.

Quick Links

Install

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

Stable version

pip install pomice

Unstable version (this one gets more frequent changes)

pip install git+https://github.com/cloudwithax/pomice

Support And Documentation

The official documentation ishere

You can join our support serverhere

Examples

In-depth examples are located in theexamples folder

Here's a quick example:

importpomiceimportdiscordimportrefromdiscord.extimportcommandsURL_REG=re.compile(r'https?://(?:www\.)?.+')classMyBot(commands.Bot):def__init__(self)->None:super().__init__(command_prefix='!',activity=discord.Activity(type=discord.ActivityType.listening,name='to music!'))self.add_cog(Music(self))asyncdefon_ready(self)->None:print("I'm online!")awaitself.cogs["Music"].start_nodes()classMusic(commands.Cog):def__init__(self,bot)->None:self.bot=botself.pomice=pomice.NodePool()asyncdefstart_nodes(self):awaitself.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'])asyncdefjoin(self,ctx:commands.Context,*,channel:discord.TextChannel=None)->None:ifnotchannel:channel=getattr(ctx.author.voice,'channel',None)ifnotchannel:raisecommands.CheckFailure('You must be in a voice channel to use this command''without specifying the channel argument.')awaitctx.author.voice.channel.connect(cls=pomice.Player)awaitctx.send(f'Joined the voice channel `{channel}`')@commands.command(name='play')asyncdefplay(self,ctx,*,search:str)->None:ifnotctx.voice_client:awaitctx.invoke(self.join)player=ctx.voice_clientresults=awaitplayer.get_tracks(query=f'{search}')ifnotresults:raisecommands.CommandError('No results were found for that search term.')ifisinstance(results,pomice.Playlist):awaitplayer.play(track=results.tracks[0])else:awaitplayer.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 ithere

What experience do I need?

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

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

  • You need toinstall the package before you can use it

Contributors

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

[8]ページ先頭

©2009-2025 Movatter.jp