一个类似于Lavalink的音频提供商的库,名为Andesite
granitep的Python项目详细描述
花岗石
Lavalink类音频提供程序的库,名为Andesite,用于discord.py
支持连接here,这里支持Official Documentation
安装
库位于pypi上,安装时使用pip install granitepy
但是,github上有一个更新版本,可以与git一起安装
pip install git+https://github.com/twitch0001/granitepy
示例
importdiscordfromdiscord.extimportcommandsimportandesite# import the libbot=commands.Bot(command_prefix="!")bot.andesite=andesite.Client(bot)@bot.eventasyncdefon_ready():awaitbot.andesite.start_node("127.0.0.1",5000,rest_uri="http://127.0.0.1:5000/",password=None,# set as None if andesite password in application.conf is null :smh:identifier="hello-there",# identifier is only for internal use.)@bot.command()asyncdefconnect(ctx):player=bot.andesite.get_player(ctx.guild.id)# fetches the playerifnotctx.author.voice:returnawaitctx.send("Must be connected to a voice channel")awaitplayer.connect(ctx.author.voice.channel.id)# connects to the channel the command invoker is inawaitctx.send(f"Connected to {ctx.author.voice.channel.name}!")@bot.command()asyncdefplay(ctx,*,search):player=bot.andesite.get_player(ctx.guild.id)tracks=awaitplayer.node.get_tracks(f"ytsearch: {search}")# returns a list andesite.Track objects ifnottracks:# andesite returned no tracks.returnawaitctx.send("Nothing found.")awaitplayer.play(tracks[0])# plays the first track from the list.bot.run("token")
这个库很大程度上是基于EvieePy制作的Wavelink非常感谢制作了wavelink,如果不是wavelink的话,可能会被一些连接的东西卡住。