为discord.py提供一些实用程序。使不和谐的机器人开发更容易。
disputils的Python项目详细描述
disputils提供了一些简洁的功能,使您作为一个机器人开发人员的生活更轻松。
功能
快速概述可用功能。
对于所有功能都有两种使用方法。
- 只是不和谐。py和一个基本的discord.Client
- discord.py命令扩展名(discord.ext.commands)和Bot
在下面我们将使用第二种方法,因为它有点简单。
fromdisputilsimportBotEmbedPaginator,BotConfirmation,BotMultipleChoice
分页
将内容拆分为多个页面,并使用“反应”分页。
@bot.command()asyncdefpaginate(ctx):embeds=[Embed(title="test page 1",description="This is just some test content!",color=0x115599),Embed(title="test page 2",description="Nothing interesting here.",color=0x5599ff),Embed(title="test page 3",description="Why are you still here?",color=0x191638)]paginator=BotEmbedPaginator(ctx,embeds)awaitpaginator.run()
多项选择
让用户决定。提供多种选择!
@bot.command()asyncdefchoice(ctx):multiple_choice=BotMultipleChoice(ctx,['one','two','three','four','five','six'],"Testing stuff")awaitmultiple_choice.run()awaitmultiple_choice.quit(multiple_choice.choice)
确认
用户会做一些不可逆转的事情吗?让他先确认一下!
@bot.command()asyncdefconfirm(ctx):confirmation=BotConfirmation(ctx,0x012345)awaitconfirmation.confirm("Are you sure?")ifconfirmation.confirmed:awaitconfirmation.update("Confirmed",color=0x55ff55)else:awaitconfirmation.update("Not confirmed",hide_author=True,color=0xff5555)
要求
- python 3.6
- discord.py v1.0.0