Skip to main content

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

Metadata

Release files for obsidianpy 1.0.6.2

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

Source distribution (sdist)

Source distribution for obsidianpy 1.0.6.2
File Size Uploaded
obsidianpy-1.0.6.2.tar.gz 24.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for obsidianpy 1.0.6.2
File Interpreter ABI Platform
obsidianpy-1.0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.7 kB

Release files / obsidianpy-1.0.6.2.tar.gz

Download URL obsidianpy-1.0.6.2.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
65628e8d1fffbe5ebb0977355ece6aec3203b8ed98fcade2fef8555801673187
BLAKE2b-256 checksum
How to use checksums
822b5a77b573856519d01e586b9eda1b82c2a736c6740655ad52637f6647c2e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release files / obsidianpy-1.0.6.2-py3-none-any.whl

Download URL obsidianpy-1.0.6.2-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92975a5688aec393c9f3c127e0335aa6835115e7eba4d9255d835cd5c248e7fe
BLAKE2b-256 checksum
How to use checksums
67cc1b3106b9ef72379153df1843e70763733e245c43a0045d81e6f16b52f219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.6.2 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

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