Skip to main content

A properly typehinted lavalink client for discord.py, nextcord, disnake and py-cord.

Project description

Mafic

MIT License Releases Discord Lint Workflow Status PyPI - Status Open Issues Open PRs Read the Docs

A properly typehinted lavalink client for discord.py, nextcord, disnake and py-cord.

Installation

pip install mafic

Note Use python -m, py -m, python3 -m or similar if that is how you install packages. Generally windows uses py -m pip and linux uses python3 -m pip

Discord Server

Join the Discord Server for support and updates.

Documentation

Read the docs.

Features

  • Fully customisable node balancing.
  • Multi-node support.
  • Filters.
  • Full API coverage.
  • Properly typehinted for Pyright strict.

Usage

Go to the Lavalink Repository to set up a Lavalink node.

import os

import mafic
import nextcord
from nextcord.ext import commands


class MyBot(commands.Bot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.pool = mafic.NodePool(self)
        self.loop.create_task(self.add_nodes())

    async def add_nodes(self):
        await self.pool.create_node(
            host="127.0.0.1",
            port=2333,
            label="MAIN",
            password="<password>",
        )


bot = MyBot(intents=nextcord.Intents(guilds=True, voice_states=True))


@bot.slash_command(dm_permission=False)
async def play(inter: nextcord.Interaction, query: str):
    if not inter.guild.voice_client:
        player = await inter.user.voice.channel.connect(cls=mafic.Player)
    else:
        player = inter.guild.voice_client

    tracks = await player.fetch_tracks(query)

    if not tracks:
        return await inter.send("No tracks found.")

    track = tracks[0]

    await player.play(track)

    await inter.send(f"Playing {track.title}.")


bot.run(...)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mafic-2.10.1.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mafic-2.10.1-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file mafic-2.10.1.tar.gz.

File metadata

  • Download URL: mafic-2.10.1.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mafic-2.10.1.tar.gz
Algorithm Hash digest
SHA256 47a8ebe9011931a756b9d47a5fd1cd50760a6c8f07bef70c683b3419bd54474b
MD5 d3dcc0db61b77ad5d3dce29dbffe692d
BLAKE2b-256 1f5e4dae6572b1f865f07051e3281819e7e5737e904c1caae01e7713f3a01368

See more details on using hashes here.

File details

Details for the file mafic-2.10.1-py3-none-any.whl.

File metadata

  • Download URL: mafic-2.10.1-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mafic-2.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fba783e00d2388025e3e62ada845848bc24c89a4404b3fee73f2640647c7d2f0
MD5 9a0b1e6e09a9bc0ed2edc2e9dd05606b
BLAKE2b-256 bb5953a9178fdf1530e8b27958a4e335cc2714e57e28e91ae7043c9730c46b87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page