A discord.py ready wrapper for the audio sending node, Obsidian
Project description
A discord.py ready wrapper for the audio sending node, Obsidian
Install
To install the library, you need the lastest version of pip and minimum Python 3.8
Stable version
pip install obsidianpy
Unstable version (this one gets more frequent changes)
pip install git+https://github.com/cloudwithax/obsidian.py
Support
You can join our support server here
Examples
In-depth examples are located in the examples folder
Here's a quick example:
import obsidian
import discord
import re
from discord.ext import commands
URL_REG = re.compile(r'https?://(?:www\.)?.+')
class MyBot(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))
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.obsidian = obsidian.NodePool()
async def start_nodes(self):
await self.obsidian.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: discord.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=obsidian.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'ytsearch:{search}')
if not results:
raise commands.CommandError('No results were found for that search term.')
if isinstance(results, obsidian.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 an Obsidian node setup before you can use this library. Download it directly here
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 obsidian found"?
- You need to install the package before you can use it
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
obsidianpy-1.0.6.tar.gz
(24.1 kB
view hashes)
Built Distribution
obsidianpy-1.0.6-py3-none-any.whl
(24.6 kB
view hashes)
Close
Hashes for obsidianpy-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2152a68f1a9e178447c34f867d9ea46c1a37212da0a980fe4ac8e894c902a3e4 |
|
MD5 | 662f797e510de2e54a3bdd4e3355a435 |
|
BLAKE2b-256 | 9daba583cc1c13302173dfd8b3608ec5cbfd05b6223ab9c0c8ad926d02522e5d |